]>
Commit | Line | Data |
---|---|---|
a784e502 | 1 | /* Copyright (C) 1991,1992,1996,1997,1999,2000,2001,2009,2010,2012 |
18598ff1 | 2 | Free Software Foundation, Inc. |
54d79e99 UD |
3 | This file is part of the GNU C Library. |
4 | ||
5 | The GNU C Library is free software; you can redistribute it and/or | |
41bdb6e2 AJ |
6 | modify it under the terms of the GNU Lesser General Public |
7 | License as published by the Free Software Foundation; either | |
8 | version 2.1 of the License, or (at your option) any later version. | |
54d79e99 UD |
9 | |
10 | The GNU C Library is distributed in the hope that it will be useful, | |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
41bdb6e2 | 13 | Lesser General Public License for more details. |
54d79e99 | 14 | |
41bdb6e2 AJ |
15 | You should have received a copy of the GNU Lesser General Public |
16 | License along with the GNU C Library; if not, write to the Free | |
17 | Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA | |
18 | 02111-1307 USA. */ | |
28f540f4 | 19 | |
28f540f4 | 20 | #ifndef _STRINGS_H |
28f540f4 | 21 | #define _STRINGS_H 1 |
5107cf1d | 22 | |
c1422e5b | 23 | /* We don't need and should not read this file if <string.h> was already |
fb0dd050 UD |
24 | read. The one exception being that if __USE_BSD isn't defined, then |
25 | these aren't defined in string.h, so we need to define them here. */ | |
26 | #if !defined _STRING_H || !defined __USE_BSD | |
c1422e5b UD |
27 | |
28 | # include <features.h> | |
29 | # define __need_size_t | |
30 | # include <stddef.h> | |
a5a0310d | 31 | |
8585cb74 UD |
32 | /* Tell the caller that we provide correct C++ prototypes. */ |
33 | # if defined __cplusplus && __GNUC_PREREQ (4, 4) | |
34 | # define __CORRECT_ISO_CPP_STRINGS_H_PROTO | |
35 | # endif | |
36 | ||
a5a0310d UD |
37 | __BEGIN_DECLS |
38 | ||
cd5c5f70 | 39 | # if defined __USE_MISC || !defined __USE_XOPEN2K8 |
a5a0310d | 40 | /* Compare N bytes of S1 and S2 (same as memcmp). */ |
a784e502 | 41 | extern int bcmp (const void *__s1, const void *__s2, size_t __n) |
e656498e | 42 | __THROW __attribute_pure__; |
a5a0310d UD |
43 | |
44 | /* Copy N bytes of SRC to DEST (like memmove, but args reversed). */ | |
a784e502 | 45 | extern void bcopy (const void *__src, void *__dest, size_t __n) __THROW; |
a5a0310d UD |
46 | |
47 | /* Set N bytes of S to 0. */ | |
c1422e5b | 48 | extern void bzero (void *__s, size_t __n) __THROW; |
a5a0310d | 49 | |
a5a0310d | 50 | /* Find the first occurrence of C in S (same as strchr). */ |
18598ff1 | 51 | # ifdef __CORRECT_ISO_CPP_STRINGS_H_PROTO |
8585cb74 UD |
52 | extern "C++" |
53 | { | |
54 | extern char *index (char *__s, int __c) | |
55 | __THROW __asm ("index") __attribute_pure__ __nonnull ((1)); | |
a784e502 | 56 | extern const char *index (const char *__s, int __c) |
8585cb74 UD |
57 | __THROW __asm ("index") __attribute_pure__ __nonnull ((1)); |
58 | ||
18598ff1 | 59 | # if defined __OPTIMIZE__ && !defined __CORRECT_ISO_CPP_STRING_H_PROTO |
8585cb74 UD |
60 | __extern_always_inline char * |
61 | index (char *__s, int __c) __THROW | |
62 | { | |
63 | return __builtin_index (__s, __c); | |
64 | } | |
65 | ||
a784e502 UD |
66 | __extern_always_inline const char * |
67 | index (const char *__s, int __c) __THROW | |
8585cb74 UD |
68 | { |
69 | return __builtin_index (__s, __c); | |
70 | } | |
18598ff1 | 71 | # endif |
8585cb74 | 72 | } |
18598ff1 | 73 | # else |
a784e502 | 74 | extern char *index (const char *__s, int __c) |
8585cb74 | 75 | __THROW __attribute_pure__ __nonnull ((1)); |
18598ff1 | 76 | # endif |
a5a0310d UD |
77 | |
78 | /* Find the last occurrence of C in S (same as strrchr). */ | |
18598ff1 | 79 | # ifdef __CORRECT_ISO_CPP_STRINGS_H_PROTO |
8585cb74 UD |
80 | extern "C++" |
81 | { | |
82 | extern char *rindex (char *__s, int __c) | |
83 | __THROW __asm ("rindex") __attribute_pure__ __nonnull ((1)); | |
a784e502 | 84 | extern const char *rindex (const char *__s, int __c) |
8585cb74 UD |
85 | __THROW __asm ("rindex") __attribute_pure__ __nonnull ((1)); |
86 | ||
18598ff1 | 87 | # if defined __OPTIMIZE__ && !defined __CORRECT_ISO_CPP_STRING_H_PROTO |
8585cb74 UD |
88 | __extern_always_inline char * |
89 | rindex (char *__s, int __c) __THROW | |
90 | { | |
91 | return __builtin_rindex (__s, __c); | |
92 | } | |
93 | ||
a784e502 UD |
94 | __extern_always_inline const char * |
95 | rindex (const char *__s, int __c) __THROW | |
8585cb74 UD |
96 | { |
97 | return __builtin_rindex (__s, __c); | |
98 | } | |
18598ff1 | 99 | # endif |
8585cb74 | 100 | } |
18598ff1 | 101 | # else |
a784e502 | 102 | extern char *rindex (const char *__s, int __c) |
8585cb74 | 103 | __THROW __attribute_pure__ __nonnull ((1)); |
18598ff1 | 104 | # endif |
8585cb74 | 105 | # endif |
28f540f4 | 106 | |
cd5c5f70 | 107 | #if defined __USE_MISC || !defined __USE_XOPEN2K8 || defined __USE_XOPEN2K8XSI |
18598ff1 UD |
108 | /* Return the position of the first bit set in I, or 0 if none are set. |
109 | The least-significant bit is position 1, the most-significant 32. */ | |
110 | extern int ffs (int __i) __THROW __attribute__ ((const)); | |
111 | #endif | |
112 | ||
a5a0310d | 113 | /* Compare S1 and S2, ignoring case. */ |
a784e502 | 114 | extern int strcasecmp (const char *__s1, const char *__s2) |
e656498e | 115 | __THROW __attribute_pure__; |
28f540f4 | 116 | |
a5a0310d | 117 | /* Compare no more than N chars of S1 and S2, ignoring case. */ |
a784e502 | 118 | extern int strncasecmp (const char *__s1, const char *__s2, size_t __n) |
e656498e | 119 | __THROW __attribute_pure__; |
28f540f4 | 120 | |
6cbe890a UD |
121 | #ifdef __USE_XOPEN2K8 |
122 | /* The following functions are equivalent to the both above but they | |
123 | take the locale they use for the collation as an extra argument. | |
124 | This is not standardsized but something like will come. */ | |
125 | # include <xlocale.h> | |
126 | ||
127 | /* Again versions of a few functions which use the given locale instead | |
128 | of the global one. */ | |
a784e502 | 129 | extern int strcasecmp_l (const char *__s1, const char *__s2, __locale_t __loc) |
6cbe890a UD |
130 | __THROW __attribute_pure__ __nonnull ((1, 2, 3)); |
131 | ||
a784e502 | 132 | extern int strncasecmp_l (const char *__s1, const char *__s2, |
6cbe890a UD |
133 | size_t __n, __locale_t __loc) |
134 | __THROW __attribute_pure__ __nonnull ((1, 2, 4)); | |
135 | #endif | |
136 | ||
a5a0310d | 137 | __END_DECLS |
28f540f4 | 138 | |
c1422e5b UD |
139 | #endif /* string.h */ |
140 | ||
28f540f4 | 141 | #endif /* strings.h */ |