libroot/posix/stdio: Remove unused portions.
[haiku.git] / src / system / libroot / posix / glibc / include / string.h
blobeb7cf24e8a880652ea10f4b231cec1af337d6266
1 #ifndef _LIBC_STRING_H
2 #define _LIBC_STRING_H
4 #include_next <string.h>
6 /* map the internal glibc interface to the public one */
7 #define __memcpy(to, from, size) memcpy(to, from, size)
8 #define __strchrnul(string, character) strchrnul(string, character)
9 #define __strnlen strnlen
10 #define __strdup strdup
11 #define __strndup strndup
12 #define __stpcpy stpcpy
13 #define __strtok_r strtok_r
14 #define __strcasecmp strcasecmp
16 static inline char *
17 __strerror_r(int error, char *buffer, size_t bufferSize)
19 if (strerror_r(error, buffer, bufferSize) != 0)
20 strlcpy(buffer, "Unknown Error", bufferSize);
22 return buffer;
25 static inline void *
26 __mempcpy(void *to, const void *from, size_t size)
28 memcpy(to, from, size);
29 return (unsigned char *)to + size;
32 #undef strdupa
33 #define strdupa(s) \
34 (__extension__ \
35 ({ \
36 __const char *__old = (s); \
37 size_t __len = strlen (__old) + 1; \
38 char *__new = (char *) __builtin_alloca (__len); \
39 (char *) memcpy (__new, __old, __len); \
40 }))
42 /* Alternative version which doesn't pollute glibc's namespace. */
43 #undef strndupa
44 #define strndupa(s, n) \
45 (__extension__ \
46 ({ \
47 __const char *__old = (s); \
48 size_t __len = __strnlen (__old, (n)); \
49 char *__new = (char *) __builtin_alloca (__len + 1); \
50 __new[__len] = '\0'; \
51 (char *) memcpy (__new, __old, __len); \
52 }))
54 #endif /* _LIBC_STRING_H */