structcpy.c
上传用户:shenzhenrh
上传日期:2013-05-12
资源大小:2904k
文件大小:1k
源码类别:

信息检索与抽取

开发平台:

Unix_Linux

  1. /* copy structs */
  2. /*
  3.  * Copyright 1995-1999 Bruno Haible, <haible@clisp.cons.org>
  4.  *
  5.  * This is free software distributed under the GNU General Public Licence
  6.  * described in the file COPYING. Contact the author if you don't have this
  7.  * or can't live with it. There is ABSOLUTELY NO WARRANTY, explicit or implied,
  8.  * on this software.
  9.  */
  10. #if defined(__STDC__) || defined(__GNUC__) || defined(__cplusplus)
  11. void __structcpy (void* dest, void* src, unsigned long size, unsigned long alignment)
  12. #else
  13. void __structcpy(dest,src,size,alignment)
  14.   void* dest;
  15.   void* src;
  16.   unsigned long size;
  17.   unsigned long alignment;
  18. #endif
  19. {
  20.   if (alignment % sizeof(long))
  21.     { char* d = (char*)dest;
  22.       char* s = (char*)src;
  23.       do { *d++ = *s++; } while (--size > 0);
  24.     }
  25.   else
  26.     /* If the alignment is a multiple of sizeof(long), the size is as well. */
  27.     { long* d = (long*)dest;
  28.       long* s = (long*)src;
  29.       do { *d++ = *s++; } while ((size -= sizeof(long)) > 0);
  30.     }
  31. }