/*
- * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 1999-2003 Apple Computer, Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
- * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
- *
- * This file contains Original Code and/or Modifications of Original Code
- * as defined in and that are subject to the Apple Public Source License
- * Version 2.0 (the 'License'). You may not use this file except in
- * compliance with the License. Please obtain a copy of the License at
- * http://www.opensource.apple.com/apsl/ and read it before using this
- * file.
+ * Portions Copyright (c) 1999-2003 Apple Computer, Inc. All Rights
+ * Reserved. This file contains Original Code and/or Modifications of
+ * Original Code as defined in and that are subject to the Apple Public
+ * Source License Version 2.0 (the "License"). You may not use this file
+ * except in compliance with the License. Please obtain a copy of the
+ * License at http://www.apple.com/publicsource and read it before using
+ * this file.
*
* The Original Code and all software distributed under the License are
- * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
- * Please see the License for the specific language governing rights and
- * limitations under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
+ * License for the specific language governing rights and limitations
+ * under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
void * memset(void * dst, int val, size_t len)
{
- asm( "rep; stosb"
+ asm volatile ( "rep; stosb"
: "=c" (len), "=D" (dst)
: "0" (len), "1" (dst), "a" (val)
: "memory" );
return dst;
}
+#if 0
void * memcpy(void * dst, const void * src, size_t len)
{
- asm( "rep; movsb"
+ asm volatile ( "rep; movsb"
: "=c" (len), "=D" (dst), "=S" (src)
: "0" (len), "1" (dst), "2" (src)
: "memory" );
memset(dst, 0, len);
}
+#else
+void * memcpy(void * dst, const void * src, size_t len)
+{
+ asm volatile ( "cld \n\t"
+ "movl %%ecx, %%edx \n\t"
+ "shrl $2, %%ecx \n\t"
+ "rep; movsl \n\t"
+ "movl %%edx, %%ecx \n\t"
+ "andl $3, %%ecx \n\t"
+ "rep; movsb \n\t"
+ : "=D" (dst)
+ : "c" (len), "D" (dst), "S" (src)
+ : "memory", "%edx" );
+
+ return dst;
+}
+
+void bcopy(const void * src, void * dst, size_t len)
+{
+ asm volatile ( "cld \n\t"
+ "movl %%ecx, %%edx \n\t"
+ "shrl $2, %%ecx \n\t"
+ "rep; movsl \n\t"
+ "movl %%edx, %%ecx \n\t"
+ "andl $3, %%ecx \n\t"
+ "rep; movsb \n\t"
+ :
+ : "c" (len), "D" (dst), "S" (src)
+ : "memory", "%edx" );
+}
+
+void bzero(void * dst, size_t len)
+{
+ asm volatile ( "xorl %%eax, %%eax \n\t"
+ "cld \n\t"
+ "movl %%ecx, %%edx \n\t"
+ "shrl $2, %%ecx \n\t"
+ "rep; stosl \n\t"
+ "movl %%edx, %%ecx \n\t"
+ "andl $3, %%ecx \n\t"
+ "rep; stosb \n\t"
+ :
+ : "c" (len), "D" (dst)
+ : "memory", "%eax" );
+}
+#endif
+
/* #if DONT_USE_GCC_BUILT_IN_STRLEN */
#define tolower(c) ((int)((c) & ~0x20))