]> git.saurik.com Git - apple/boot.git/blob - gen/libsa/memcpy.c
a1e4c04255cf1a7d068a57cd895d73fb8600715e
[apple/boot.git] / gen / libsa / memcpy.c
1 /*
2 * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
7 *
8 * This file contains Original Code and/or Modifications of Original Code
9 * as defined in and that are subject to the Apple Public Source License
10 * Version 2.0 (the 'License'). You may not use this file except in
11 * compliance with the License. Please obtain a copy of the License at
12 * http://www.opensource.apple.com/apsl/ and read it before using this
13 * file.
14 *
15 * The Original Code and all software distributed under the License are
16 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
17 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
18 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
20 * Please see the License for the specific language governing rights and
21 * limitations under the License.
22 *
23 * @APPLE_LICENSE_HEADER_END@
24 */
25 /*
26 * more string operations
27 *
28 */
29
30 #import "libsa.h"
31
32 #if defined(NX_CURRENT_COMPILER_RELEASE) && (NX_CURRENT_COMPILER_RELEASE < 320)
33 #define SIREG "e"
34 #else
35 #define SIREG "S"
36 #endif
37
38 #if i386 && !defined(DONT_USE_ASM)
39 /* Simple forward character copy */
40 void *memcpy(void *dst, const void *src, size_t len)
41 {
42 asm("rep; movsb"
43 : /* no outputs */
44 : "&c" (len), "D" (dst), SIREG (src)
45 : "ecx", "esi", "edi");
46 return (void *)src;
47 }
48 #else
49 void *memcpy(
50 void *dst,
51 const void *src,
52 size_t len
53 )
54 {
55 register char *src_c, *dst_c;
56
57 src_c = (char *)src;
58 dst_c = (char *)dst;
59
60 while (len-- > 0)
61 *dst_c++ = *src_c++;
62 return src;
63 }
64 #endif
65
66 /*
67 * copy n bytes from src to dst. Both src and dst are virtual addresses.
68 */
69 char *bcopy(char *src, char *dst, int n)
70 {
71 memcpy(dst, src, n);
72 return 0;
73 }
74
75