at_wini also needs a pci_reserve() for the pci compatability device, if
[minix3.git] / lib / other / memccpy.c
blob59ddb711d8be7fe85989417d7f94cee79d189200
1 #include <lib.h>
2 /* memccpy - copy bytes up to a certain char
4 * CHARBITS should be defined only if the compiler lacks "unsigned char".
5 * It should be a mask, e.g. 0377 for an 8-bit machine.
6 */
8 #include <ansi.h>
9 #include <stddef.h>
11 _PROTOTYPE( void *memccpy, (void *dst, const void *src,
12 int ucharstop, size_t size));
13 #ifndef CHARBITS
14 # define UNSCHAR(c) ((unsigned char)(c))
15 #else
16 # define UNSCHAR(c) ((c)&CHARBITS)
17 #endif
19 void *memccpy(dst, src, ucharstop, size)
20 void * dst;
21 _CONST void * src;
22 int ucharstop;
23 _SIZET size;
25 register char *d;
26 register _CONST char *s;
27 register _SIZET n;
28 register int uc;
30 if (size <= 0) return( (void *) NULL);
32 s = (char *) src;
33 d = (char *) dst;
34 uc = UNSCHAR(ucharstop);
35 for (n = size; n > 0; n--)
36 if (UNSCHAR(*d++ = *s++) == (char) uc) return( (void *) d);
38 return( (void *) NULL);