Rev 4921 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
4349 | Serge | 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 |
||
12 | #include |
||
4921 | Serge | 13 | #include |
4349 | Serge | 14 | |
15 | #define __need_size_t |
||
4921 | Serge | 16 | #define __need_NULL |
4349 | Serge | 17 | #include |
18 | |||
19 | _BEGIN_STD_C |
||
20 | |||
21 | _PTR _EXFUN(memchr,(const _PTR, int, size_t)); |
||
22 | int _EXFUN(memcmp,(const _PTR, const _PTR, size_t)); |
||
4921 | Serge | 23 | _PTR _EXFUN(memcpy,(_PTR __restrict, const _PTR __restrict, size_t)); |
4349 | Serge | 24 | _PTR _EXFUN(memmove,(_PTR, const _PTR, size_t)); |
25 | _PTR _EXFUN(memset,(_PTR, int, size_t)); |
||
4921 | Serge | 26 | char *_EXFUN(strcat,(char *__restrict, const char *__restrict)); |
4349 | Serge | 27 | char *_EXFUN(strchr,(const char *, int)); |
28 | int _EXFUN(strcmp,(const char *, const char *)); |
||
29 | int _EXFUN(strcoll,(const char *, const char *)); |
||
4921 | Serge | 30 | char *_EXFUN(strcpy,(char *__restrict, const char *__restrict)); |
4349 | Serge | 31 | size_t _EXFUN(strcspn,(const char *, const char *)); |
32 | char *_EXFUN(strerror,(int)); |
||
33 | size_t _EXFUN(strlen,(const char *)); |
||
4921 | Serge | 34 | char *_EXFUN(strncat,(char *__restrict, const char *__restrict, size_t)); |
4349 | Serge | 35 | int _EXFUN(strncmp,(const char *, const char *, size_t)); |
4921 | Serge | 36 | char *_EXFUN(strncpy,(char *__restrict, const char *__restrict, size_t)); |
4349 | Serge | 37 | char *_EXFUN(strpbrk,(const char *, const char *)); |
38 | char *_EXFUN(strrchr,(const char *, int)); |
||
39 | size_t _EXFUN(strspn,(const char *, const char *)); |
||
40 | char *_EXFUN(strstr,(const char *, const char *)); |
||
41 | #ifndef _REENT_ONLY |
||
4921 | Serge | 42 | char *_EXFUN(strtok,(char *__restrict, const char *__restrict)); |
4349 | Serge | 43 | #endif |
4921 | Serge | 44 | size_t _EXFUN(strxfrm,(char *__restrict, const char *__restrict, size_t)); |
4349 | Serge | 45 | |
6099 | serge | 46 | #if __POSIX_VISIBLE |
4921 | Serge | 47 | char *_EXFUN(strtok_r,(char *__restrict, const char *__restrict, char **__restrict)); |
6099 | serge | 48 | #endif |
49 | #if __BSD_VISIBLE |
||
4349 | Serge | 50 | int _EXFUN(bcmp,(const void *, const void *, size_t)); |
51 | void _EXFUN(bcopy,(const void *, void *, size_t)); |
||
52 | void _EXFUN(bzero,(void *, size_t)); |
||
53 | int _EXFUN(ffs,(int)); |
||
54 | char *_EXFUN(index,(const char *, int)); |
||
6099 | serge | 55 | #endif |
56 | #if __BSD_VISIBLE || __XSI_VISIBLE |
||
4921 | Serge | 57 | _PTR _EXFUN(memccpy,(_PTR __restrict, const _PTR __restrict, int, size_t)); |
6099 | serge | 58 | #endif |
59 | #if __GNU_VISIBLE |
||
4349 | Serge | 60 | _PTR _EXFUN(mempcpy,(_PTR, const _PTR, size_t)); |
61 | _PTR _EXFUN(memmem, (const _PTR, size_t, const _PTR, size_t)); |
||
6099 | serge | 62 | #endif |
4921 | Serge | 63 | _PTR _EXFUN(memrchr,(const _PTR, int, size_t)); |
6099 | serge | 64 | #if __GNU_VISIBLE |
4921 | Serge | 65 | _PTR _EXFUN(rawmemchr,(const _PTR, int)); |
6099 | serge | 66 | #endif |
67 | #if __BSD_VISIBLE |
||
4349 | Serge | 68 | char *_EXFUN(rindex,(const char *, int)); |
6099 | serge | 69 | #endif |
4921 | Serge | 70 | char *_EXFUN(stpcpy,(char *__restrict, const char *__restrict)); |
71 | char *_EXFUN(stpncpy,(char *__restrict, const char *__restrict, size_t)); |
||
6099 | serge | 72 | #if __BSD_VISIBLE || __POSIX_VISIBLE |
4349 | Serge | 73 | int _EXFUN(strcasecmp,(const char *, const char *)); |
6099 | serge | 74 | #endif |
75 | #if __GNU_VISIBLE |
||
4349 | Serge | 76 | char *_EXFUN(strcasestr,(const char *, const char *)); |
77 | char *_EXFUN(strchrnul,(const char *, int)); |
||
4921 | Serge | 78 | #endif |
6099 | serge | 79 | #if __XSI_VISIBLE >= 500 |
4349 | Serge | 80 | char *_EXFUN(strdup,(const char *)); |
4921 | Serge | 81 | #endif |
82 | #ifndef __STRICT_ANSI__ |
||
4349 | Serge | 83 | char *_EXFUN(_strdup_r,(struct _reent *, const char *)); |
4921 | Serge | 84 | #endif |
6099 | serge | 85 | #if __XSI_VISIBLE >= 700 |
4349 | Serge | 86 | char *_EXFUN(strndup,(const char *, size_t)); |
4921 | Serge | 87 | #endif |
6099 | serge | 88 | |
4921 | Serge | 89 | #ifndef __STRICT_ANSI__ |
4349 | Serge | 90 | char *_EXFUN(_strndup_r,(struct _reent *, const char *, size_t)); |
6099 | serge | 91 | #endif |
92 | |||
93 | #if __GNU_VISIBLE |
||
94 | int _EXFUN(ffsl,(long)); |
||
95 | int _EXFUN(ffsll, (long long)); |
||
96 | #endif |
||
97 | |||
4349 | Serge | 98 | /* There are two common strerror_r variants. If you request |
99 | _GNU_SOURCE, you get the GNU version; otherwise you get the POSIX |
||
100 | version. POSIX requires that #undef strerror_r will still let you |
||
101 | invoke the underlying function, but that requires gcc support. */ |
||
6099 | serge | 102 | #if __GNU_VISIBLE |
103 | char *_EXFUN(strerror_r,(int, char *, size_t)); |
||
4349 | Serge | 104 | #else |
105 | # ifdef __GNUC__ |
||
6099 | serge | 106 | int _EXFUN(strerror_r,(int, char *, size_t)) |
107 | #ifdef __ASMNAME |
||
108 | __asm__ (__ASMNAME ("__xpg_strerror_r")) |
||
109 | #endif |
||
110 | ; |
||
4349 | Serge | 111 | # else |
6099 | serge | 112 | int _EXFUN(__xpg_strerror_r,(int, char *, size_t)); |
4349 | Serge | 113 | # define strerror_r __xpg_strerror_r |
114 | # endif |
||
115 | #endif |
||
6099 | serge | 116 | |
117 | /* Reentrant version of strerror. */ |
||
118 | char * _EXFUN(_strerror_r, (struct _reent *, int, int, int *)); |
||
119 | |||
120 | #if __BSD_VISIBLE |
||
121 | size_t _EXFUN(strlcat,(char *, const char *, size_t)); |
||
122 | size_t _EXFUN(strlcpy,(char *, const char *, size_t)); |
||
123 | #endif |
||
124 | #if __BSD_VISIBLE || __POSIX_VISIBLE |
||
125 | int _EXFUN(strncasecmp,(const char *, const char *, size_t)); |
||
126 | #endif |
||
127 | #if !defined(__STRICT_ANSI__) || __POSIX_VISIBLE >= 200809 || \ |
||
128 | __XSI_VISIBLE >= 700 |
||
4349 | Serge | 129 | size_t _EXFUN(strnlen,(const char *, size_t)); |
6099 | serge | 130 | #endif |
131 | #if __BSD_VISIBLE |
||
4349 | Serge | 132 | char *_EXFUN(strsep,(char **, const char *)); |
6099 | serge | 133 | #endif |
134 | |||
135 | /* |
||
136 | * The origin of these is unknown to me so I am conditionalizing them |
||
137 | * on __STRICT_ANSI__. Finetuning this is definitely needed. --joel |
||
138 | */ |
||
139 | #if !defined(__STRICT_ANSI__) |
||
4349 | Serge | 140 | char *_EXFUN(strlwr,(char *)); |
141 | char *_EXFUN(strupr,(char *)); |
||
6099 | serge | 142 | #endif |
143 | |||
4349 | Serge | 144 | #ifndef DEFS_H /* Kludge to work around problem compiling in gdb */ |
6099 | serge | 145 | char *_EXFUN(strsignal, (int __signo)); |
4349 | Serge | 146 | #endif |
6099 | serge | 147 | |
4349 | Serge | 148 | #ifdef __CYGWIN__ |
6099 | serge | 149 | int _EXFUN(strtosigno, (const char *__name)); |
4349 | Serge | 150 | #endif |
151 | |||
152 | #if defined _GNU_SOURCE && defined __GNUC__ |
||
153 | #define strdupa(__s) \ |
||
154 | (__extension__ ({const char *__in = (__s); \ |
||
155 | size_t __len = strlen (__in) + 1; \ |
||
156 | char * __out = (char *) __builtin_alloca (__len); \ |
||
157 | (char *) memcpy (__out, __in, __len);})) |
||
158 | #define strndupa(__s, __n) \ |
||
159 | (__extension__ ({const char *__in = (__s); \ |
||
160 | size_t __len = strnlen (__in, (__n)) + 1; \ |
||
161 | char *__out = (char *) __builtin_alloca (__len); \ |
||
162 | __out[__len-1] = '\0'; \ |
||
163 | (char *) memcpy (__out, __in, __len-1);})) |
||
164 | #endif /* _GNU_SOURCE && __GNUC__ */ |
||
165 | |||
6099 | serge | 166 | /* There are two common basename variants. If you do NOT #include |
167 | and you do |
||
168 | |||
169 | #define _GNU_SOURCE |
||
170 | #include |
||
171 | |||
172 | you get the GNU version. Otherwise you get the POSIX versionfor which you |
||
173 | should #include |
||
174 | #undef basename will still let you invoke the underlying function. However, |
||
175 | this also implies that the POSIX version is used in this case. That's made |
||
176 | sure here. */ |
||
177 | #if __GNU_VISIBLE && !defined(basename) |
||
178 | # define basename basename |
||
179 | char *_EXFUN(__nonnull (1) basename,(const char *)) __asm__(__ASMNAME("__gnu_basename")); |
||
4349 | Serge | 180 | #endif |
181 | |||
182 | #include |
||
183 | |||
184 | _END_STD_C |
||
185 | |||
186 | #endif /* _STRING_H_ */ |