File: structcpy.c

package info (click to toggle)
clisp 1999-07-22-5
  • links: PTS
  • area: main
  • in suites: potato
  • size: 36,876 kB
  • ctags: 19,900
  • sloc: ansic: 76,750; lisp: 65,522; asm: 16,504; sh: 8,971; fortran: 8,277; makefile: 3,251; objc: 2,481; perl: 1,744; java: 553; sed: 96
file content (33 lines) | stat: -rw-r--r-- 983 bytes parent folder | download | duplicates (9)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/* copy structs */

/*
 * Copyright 1995-1999 Bruno Haible, <haible@clisp.cons.org>
 *
 * This is free software distributed under the GNU General Public Licence
 * described in the file COPYING. Contact the author if you don't have this
 * or can't live with it. There is ABSOLUTELY NO WARRANTY, explicit or implied,
 * on this software.
 */

#if defined(__STDC__) || defined(__GNUC__) || defined(__cplusplus)
void __structcpy (void* dest, void* src, unsigned long size, unsigned long alignment)
#else
void __structcpy(dest,src,size,alignment)
  void* dest;
  void* src;
  unsigned long size;
  unsigned long alignment;
#endif
{
  if (alignment % sizeof(long))
    { char* d = (char*)dest;
      char* s = (char*)src;
      do { *d++ = *s++; } while (--size > 0);
    }
  else
    /* If the alignment is a multiple of sizeof(long), the size is as well. */
    { long* d = (long*)dest;
      long* s = (long*)src;
      do { *d++ = *s++; } while ((size -= sizeof(long)) > 0);
    }
}