source: trunk/libs/newlib/src/newlib/libc/include/string.h @ 444

Last change on this file since 444 was 444, checked in by satin@…, 6 years ago

add newlib,libalmos-mkh, restructure shared_syscalls.h and mini-libc

File size: 5.4 KB
Line 
1/*
2 * string.h
3 *
4 * Definitions for memory and string functions.
5 */
6
7#ifndef _STRING_H_
8#define _STRING_H_
9
10#include "_ansi.h"
11#include <sys/reent.h>
12#include <sys/cdefs.h>
13#include <sys/features.h>
14
15#define __need_size_t
16#define __need_NULL
17#include <stddef.h>
18
19#if __POSIX_VISIBLE >= 200809
20#include <xlocale.h>
21#endif
22
23#if __BSD_VISIBLE
24#include <strings.h>
25#endif
26
27_BEGIN_STD_C
28
29void *   memchr (const void *, int, size_t);
30int      memcmp (const void *, const void *, size_t);
31void *   memcpy (void *__restrict, const void *__restrict, size_t);
32void *   memmove (void *, const void *, size_t);
33void *   memset (void *, int, size_t);
34char    *strcat (char *__restrict, const char *__restrict);
35char    *strchr (const char *, int);
36int      strcmp (const char *, const char *);
37int      strcoll (const char *, const char *);
38char    *strcpy (char *__restrict, const char *__restrict);
39size_t   strcspn (const char *, const char *);
40char    *strerror (int);
41size_t   strlen (const char *);
42char    *strncat (char *__restrict, const char *__restrict, size_t);
43int      strncmp (const char *, const char *, size_t);
44char    *strncpy (char *__restrict, const char *__restrict, size_t);
45char    *strpbrk (const char *, const char *);
46char    *strrchr (const char *, int);
47size_t   strspn (const char *, const char *);
48char    *strstr (const char *, const char *);
49#ifndef _REENT_ONLY
50char    *strtok (char *__restrict, const char *__restrict);
51#endif
52size_t   strxfrm (char *__restrict, const char *__restrict, size_t);
53
54#if __POSIX_VISIBLE >= 200809
55int      strcoll_l (const char *, const char *, locale_t);
56char    *strerror_l (int, locale_t);
57size_t   strxfrm_l (char *__restrict, const char *__restrict, size_t, locale_t);
58#endif
59#if __MISC_VISIBLE || __POSIX_VISIBLE
60char    *strtok_r (char *__restrict, const char *__restrict, char **__restrict);
61#endif
62#if __BSD_VISIBLE
63int      timingsafe_bcmp (const void *, const void *, size_t);
64int      timingsafe_memcmp (const void *, const void *, size_t);
65#endif
66#if __MISC_VISIBLE || __POSIX_VISIBLE
67void *   memccpy (void *__restrict, const void *__restrict, int, size_t);
68#endif
69#if __GNU_VISIBLE
70void *   mempcpy (void *, const void *, size_t);
71void *   memmem (const void *, size_t, const void *, size_t);
72void *   memrchr (const void *, int, size_t);
73void *   rawmemchr (const void *, int);
74#endif
75#if __POSIX_VISIBLE >= 200809
76char    *stpcpy (char *__restrict, const char *__restrict);
77char    *stpncpy (char *__restrict, const char *__restrict, size_t);
78#endif
79#if __GNU_VISIBLE
80char    *strcasestr (const char *, const char *);
81char    *strchrnul (const char *, int);
82#endif
83#if __MISC_VISIBLE || __POSIX_VISIBLE >= 200809 || __XSI_VISIBLE >= 4
84char    *strdup (const char *);
85#endif
86char    *_strdup_r (struct _reent *, const char *);
87#if __POSIX_VISIBLE >= 200809
88char    *strndup (const char *, size_t);
89#endif
90char    *_strndup_r (struct _reent *, const char *, size_t);
91
92/* There are two common strerror_r variants.  If you request
93   _GNU_SOURCE, you get the GNU version; otherwise you get the POSIX
94   version.  POSIX requires that #undef strerror_r will still let you
95   invoke the underlying function, but that requires gcc support.  */
96#if __GNU_VISIBLE
97char    *strerror_r (int, char *, size_t);
98#elif __POSIX_VISIBLE >= 200112
99# ifdef __GNUC__
100int     strerror_r (int, char *, size_t)
101#ifdef __ASMNAME
102             __asm__ (__ASMNAME ("__xpg_strerror_r"))
103#endif
104  ;
105# else
106int     __xpg_strerror_r (int, char *, size_t);
107#  define strerror_r __xpg_strerror_r
108# endif
109#endif
110
111/* Reentrant version of strerror.  */
112char *  _strerror_r (struct _reent *, int, int, int *);
113
114#if __BSD_VISIBLE
115size_t  strlcat (char *, const char *, size_t);
116size_t  strlcpy (char *, const char *, size_t);
117#endif
118#if __POSIX_VISIBLE >= 200809
119size_t   strnlen (const char *, size_t);
120#endif
121#if __BSD_VISIBLE
122char    *strsep (char **, const char *);
123#endif
124#if __BSD_VISIBLE
125char    *strnstr(const char *, const char *, size_t) __pure;
126#endif
127
128#if __MISC_VISIBLE
129char    *strlwr (char *);
130char    *strupr (char *);
131#endif
132
133#ifndef DEFS_H  /* Kludge to work around problem compiling in gdb */
134char    *strsignal (int __signo);
135#endif
136
137#ifdef __CYGWIN__
138int     strtosigno (const char *__name);
139#endif
140
141#if __GNU_VISIBLE
142int      strverscmp (const char *, const char *);
143#endif
144
145#if __GNU_VISIBLE && defined(__GNUC__)
146#define strdupa(__s) \
147        (__extension__ ({const char *__sin = (__s); \
148                         size_t __len = strlen (__sin) + 1; \
149                         char * __sout = (char *) __builtin_alloca (__len); \
150                         (char *) memcpy (__sout, __sin, __len);}))
151#define strndupa(__s, __n) \
152        (__extension__ ({const char *__sin = (__s); \
153                         size_t __len = strnlen (__sin, (__n)) + 1; \
154                         char *__sout = (char *) __builtin_alloca (__len); \
155                         __sout[__len-1] = '\0'; \
156                         (char *) memcpy (__sout, __sin, __len-1);}))
157#endif /* __GNU_VISIBLE && __GNUC__ */
158
159/* There are two common basename variants.  If you do NOT #include <libgen.h>
160   and you do
161
162     #define _GNU_SOURCE
163     #include <string.h>
164
165   you get the GNU version.  Otherwise you get the POSIX versionfor which you
166   should #include <libgen.h>i for the function prototype.  POSIX requires that
167   #undef basename will still let you invoke the underlying function.  However,
168   this also implies that the POSIX version is used in this case.  That's made
169   sure here. */
170#if __GNU_VISIBLE && !defined(basename)
171# define basename basename
172char    *__nonnull ((1)) basename (const char *) __asm__(__ASMNAME("__gnu_basename"));
173#endif
174
175#include <sys/string.h>
176
177_END_STD_C
178
179#if __SSP_FORTIFY_LEVEL > 0
180#include <ssp/string.h>
181#endif
182
183#endif /* _STRING_H_ */
Note: See TracBrowser for help on using the repository browser.