2 * (C) Copyright 2007-2010 Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
4 * This file is released under the GPLv2. See the COPYING file for more
13 #define memset(d,s,l) __builtin_memset((d),(s),(l))
14 #define memcpy(d,s,l) __builtin_memcpy((d),(s),(l))
15 extern void *memmove(void *dest
, const void *src
, size_t count
);
16 #define memcmp(d,s,l) __builtin_memcmp((d),(s),(l))
17 extern size_t strnlen(const char *s
, size_t count
);
18 extern int strcmp(const char *cs
, const char *ct
);
19 extern int strncmp(const char *cs
, const char *ct
, int len
);
20 extern int strcasecmp(const char *s1
, const char *s2
);
21 extern char *strncpy(char *dest
, const char *src
, size_t count
);
22 extern char *strpbrk(const char *cs
, const char *ct
);
23 extern size_t strspn(const char *s
, const char *accept
);
24 extern char *strsep(char **s
, const char *ct
);
25 extern char *strmsep(char **s
, const char *ct
);
27 static inline int toupper(int c
)
30 * TODO: This would break if we ever tried to compile within an EBCDIC
33 if ((c
>= 'a') && (c
<= 'z'))
38 static inline int tolower(int c
)
41 * TODO: This would break if we ever tried to compile within an EBCDIC
44 if ((c
>= 'A') && (c
<= 'Z'))
50 * NOTE! This ctype does not handle EOF like the standard C
51 * library is required to. (Taken from include/linux/ctype.h)
54 #define _U 0x01 /* upper */
55 #define _L 0x02 /* lower */
56 #define _D 0x04 /* digit */
57 #define _C 0x08 /* cntrl */
58 #define _P 0x10 /* punct */
59 #define _S 0x20 /* white space (space/lf/tab) */
60 #define _X 0x40 /* hex digit */
61 #define _SP 0x80 /* hard space (0x20) */
63 extern unsigned char _ascii_ctype
[];
65 #define __ismask(x) (_ascii_ctype[(int)(unsigned char)(x)])
67 #define isalnum(c) ((__ismask(c)&(_U|_L|_D)) != 0)
68 #define isalpha(c) ((__ismask(c)&(_U|_L)) != 0)
69 #define iscntrl(c) ((__ismask(c)&(_C)) != 0)
70 #define isdigit(c) ((__ismask(c)&(_D)) != 0)
71 #define isgraph(c) ((__ismask(c)&(_P|_U|_L|_D)) != 0)
72 #define islower(c) ((__ismask(c)&(_L)) != 0)
73 #define isprint(c) ((__ismask(c)&(_P|_U|_L|_D|_SP)) != 0)
74 #define ispunct(c) ((__ismask(c)&(_P)) != 0)
75 #define isspace(c) ((__ismask(c)&(_S)) != 0)
76 #define isupper(c) ((__ismask(c)&(_U)) != 0)
77 #define isxdigit(c) ((__ismask(c)&(_D|_X)) != 0)