📄 hmemcpy.ch
字号:
/* ACC -- Automatic Compiler Configuration Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer All Rights Reserved. This software is a copyrighted work licensed under the terms of the 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;#else return 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;#else return 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;#else return 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;#else return memset(s, c, len);#endif}/*vi:ts=4:et*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -