Blame | Last modification | View Log | Download | RSS feed
/* ACC -- Automatic Compiler ConfigurationCopyright (C) 1996-2004 Markus Franz Xaver Johannes OberhumerAll Rights Reserved.This software is a copyrighted work licensed under the terms ofthe GNU General Public License. Please consult the file "ACC_LICENSE"for details.Markus F.X.J. Oberhumer<markus@oberhumer.com>http://www.oberhumer.com/*/#define __ACCLIB_HMEMCPY_CH_INCLUDED 1#if !defined(ACCLIB_PUBLIC)# define ACCLIB_PUBLIC(r,f) r __ACCLIB_FUNCNAME(f)#endif/***********************************************************************// memcmp, memcpy, memmove, memset************************************************************************/ACCLIB_PUBLIC(int, acc_hmemcmp) (const acc_hvoid_p s1, const acc_hvoid_p s2, acc_hsize_t len){#if (ACC_HAVE_MM_HUGE_PTR) || !defined(HAVE_MEMCMP)const acc_hbyte_p p1 = (const acc_hbyte_p) s1;const acc_hbyte_p p2 = (const acc_hbyte_p) s2;if (len > 0) do{int d = *p1 - *p2;if (d != 0)return d;p1++; p2++;} while (--len > 0);return 0;#elsereturn memcmp(s1, s2, len);#endif}ACCLIB_PUBLIC(acc_hvoid_p, acc_hmemcpy) (acc_hvoid_p dest, const acc_hvoid_p src, acc_hsize_t len){#if (ACC_HAVE_MM_HUGE_PTR) || !defined(HAVE_MEMCPY)acc_hbyte_p p1 = (acc_hbyte_p) dest;const acc_hbyte_p p2 = (const acc_hbyte_p) src;if (len <= 0 || p1 == p2)return dest;do*p1++ = *p2++;while (--len > 0);return dest;#elsereturn memcpy(dest, src, len);#endif}ACCLIB_PUBLIC(acc_hvoid_p, acc_hmemmove) (acc_hvoid_p dest, const acc_hvoid_p src, acc_hsize_t len){#if (ACC_HAVE_MM_HUGE_PTR) || !defined(HAVE_MEMMOVE)acc_hbyte_p p1 = (acc_hbyte_p) dest;const acc_hbyte_p p2 = (const acc_hbyte_p) src;if (len <= 0 || p1 == p2)return dest;if (p1 < p2){do*p1++ = *p2++;while (--len > 0);}else{p1 += len;p2 += len;do*--p1 = *--p2;while (--len > 0);}return dest;#elsereturn memmove(dest, src, len);#endif}ACCLIB_PUBLIC(acc_hvoid_p, acc_hmemset) (acc_hvoid_p s, int c, acc_hsize_t len){#if (ACC_HAVE_MM_HUGE_PTR) || !defined(HAVE_MEMSET)acc_hbyte_p p = (acc_hbyte_p) s;if (len > 0) do*p++ = (unsigned char) c;while (--len > 0);return s;#elsereturn memset(s, c, len);#endif}/*vi:ts=4:et*/