VirtualBox

source: vbox/trunk/src/VBox/Runtime/string/memcpy.cpp@ 2981

Last change on this file since 2981 was 2981, checked in by vboxsync, 18 years ago

InnoTek -> innotek: all the headers and comments.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 2.1 KB
Line 
1/* $Id: memcpy.cpp 2981 2007-06-01 16:01:28Z vboxsync $ */
2/** @file
3 * innotek Portable Runtime - CRT Strings, memcpy().
4 */
5
6/*
7 * Copyright (C) 2006-2007 innotek GmbH
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License as published by the Free Software Foundation,
13 * in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
14 * distribution. VirtualBox OSE is distributed in the hope that it will
15 * be useful, but WITHOUT ANY WARRANTY of any kind.
16 *
17 * If you received this file as part of a commercial VirtualBox
18 * distribution, then only the terms of your commercial VirtualBox
19 * license agreement apply instead of the previous paragraph.
20 */
21
22
23/*******************************************************************************
24* Header Files *
25*******************************************************************************/
26#include <iprt/string.h>
27
28
29/**
30 * Copies a memory.
31 *
32 * @returns pvDst.
33 * @param pvDst Pointer to the target block.
34 * @param pvSrc Pointer to the source block.
35 * @param cb The size of the block.
36 */
37#ifdef _MSC_VER
38# if _MSC_VER >= 1400
39_CRT_INSECURE_DEPRECATE_MEMORY(memcpy_s) void * __cdecl memcpy(__out_bcount_full_opt(_Size) void * pvDst, __in_bcount_opt(_Size) const void * pvSrc, __in size_t cb)
40# else
41void *memcpy(void *pvDst, const void *pvSrc, size_t cb)
42# endif
43#else
44void *memcpy(void *pvDst, const void *pvSrc, size_t cb)
45#endif
46{
47 register union
48 {
49 uint8_t *pu8;
50 uint32_t *pu32;
51 void *pv;
52 } uTrg;
53 uTrg.pv = pvDst;
54
55 register union
56 {
57 uint8_t const *pu8;
58 uint32_t const *pu32;
59 void const *pv;
60 } uSrc;
61 uSrc.pv = pvSrc;
62
63 /* 32-bit word moves. */
64 register size_t c = cb >> 2;
65 while (c-- > 0)
66 *uTrg.pu32++ = *uSrc.pu32++;
67
68 /* Remaining byte moves. */
69 c = cb & 3;
70 while (c-- > 0)
71 *uTrg.pu8++ = *uSrc.pu8++;
72
73 return pvDst;
74}
75
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette