]>
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 | 15 | You should have received a copy of the GNU Lesser General Public |
59ba27a6 PE |
16 | License along with the GNU C Library; if not, see |
17 | <http://www.gnu.org/licenses/>. */ | |
28f540f4 | 18 | |
28f540f4 | 19 | #ifndef _STRINGS_H |
28f540f4 | 20 | #define _STRINGS_H 1 |
5107cf1d | 21 | |
c1422e5b | 22 | /* We don't need and should not read this file if <string.h> was already |
fb0dd050 UD |
23 | read. The one exception being that if __USE_BSD isn't defined, then |
24 | these aren't defined in string.h, so we need to define them here. */ | |
25 | #if !defined _STRING_H || !defined __USE_BSD | |
c1422e5b UD |
26 | |
27 | # include <features.h> | |
28 | # define __need_size_t | |
29 | # include <stddef.h> | |
a5a0310d | 30 | |
8585cb74 UD |
31 | /* Tell the caller that we provide correct C++ prototypes. */ |
32 | # if defined __cplusplus && __GNUC_PREREQ (4, 4) | |
33 | # define __CORRECT_ISO_CPP_STRINGS_H_PROTO | |
34 | # endif | |
35 | ||
a5a0310d UD |
36 | __BEGIN_DECLS |
37 | ||
cd5c5f70 | 38 | # if defined __USE_MISC || !defined __USE_XOPEN2K8 |
a5a0310d | 39 | /* Compare N bytes of S1 and S2 (same as memcmp). */ |
a784e502 | 40 | extern int bcmp (const void *__s1, const void *__s2, size_t __n) |
e656498e | 41 | __THROW __attribute_pure__; |
a5a0310d UD |
42 | |
43 | /* Copy N bytes of SRC to DEST (like memmove, but args reversed). */ | |
a784e502 | 44 | extern void bcopy (const void *__src, void *__dest, size_t __n) __THROW; |
a5a0310d UD |
45 | |
46 | /* Set N bytes of S to 0. */ | |
c1422e5b | 47 | extern void bzero (void *__s, size_t __n) __THROW; |
a5a0310d | 48 | |
a5a0310d | 49 | /* Find the first occurrence of C in S (same as strchr). */ |
18598ff1 | 50 | # ifdef __CORRECT_ISO_CPP_STRINGS_H_PROTO |
8585cb74 UD |
51 | extern "C++" |
52 | { | |
53 | extern char *index (char *__s, int __c) | |
54 | __THROW __asm ("index") __attribute_pure__ __nonnull ((1)); | |
a784e502 | 55 | extern const char *index (const char *__s, int __c) |
8585cb74 UD |
56 | __THROW __asm ("index") __attribute_pure__ __nonnull ((1)); |
57 | ||
18598ff1 | 58 | # if defined __OPTIMIZE__ && !defined __CORRECT_ISO_CPP_STRING_H_PROTO |
8585cb74 UD |
59 | __extern_always_inline char * |
60 | index (char *__s, int __c) __THROW | |
61 | { | |
62 | return __builtin_index (__s, __c); | |
63 | } | |
64 | ||
a784e502 UD |
65 | __extern_always_inline const char * |
66 | index (const char *__s, int __c) __THROW | |
8585cb74 UD |
67 | { |
68 | return __builtin_index (__s, __c); | |
69 | } | |
18598ff1 | 70 | # endif |
8585cb74 | 71 | } |
18598ff1 | 72 | # else |
a784e502 | 73 | extern char *index (const char *__s, int __c) |
8585cb74 | 74 | __THROW __attribute_pure__ __nonnull ((1)); |
18598ff1 | 75 | # endif |
a5a0310d UD |
76 | |
77 | /* Find the last occurrence of C in S (same as strrchr). */ | |
18598ff1 | 78 | # ifdef __CORRECT_ISO_CPP_STRINGS_H_PROTO |
8585cb74 UD |
79 | extern "C++" |
80 | { | |
81 | extern char *rindex (char *__s, int __c) | |
82 | __THROW __asm ("rindex") __attribute_pure__ __nonnull ((1)); | |
a784e502 | 83 | extern const char *rindex (const char *__s, int __c) |
8585cb74 UD |
84 | __THROW __asm ("rindex") __attribute_pure__ __nonnull ((1)); |
85 | ||
18598ff1 | 86 | # if defined __OPTIMIZE__ && !defined __CORRECT_ISO_CPP_STRING_H_PROTO |
8585cb74 UD |
87 | __extern_always_inline char * |
88 | rindex (char *__s, int __c) __THROW | |
89 | { | |
90 | return __builtin_rindex (__s, __c); | |
91 | } | |
92 | ||
a784e502 UD |
93 | __extern_always_inline const char * |
94 | rindex (const char *__s, int __c) __THROW | |
8585cb74 UD |
95 | { |
96 | return __builtin_rindex (__s, __c); | |
97 | } | |
18598ff1 | 98 | # endif |
8585cb74 | 99 | } |
18598ff1 | 100 | # else |
a784e502 | 101 | extern char *rindex (const char *__s, int __c) |
8585cb74 | 102 | __THROW __attribute_pure__ __nonnull ((1)); |
18598ff1 | 103 | # endif |
8585cb74 | 104 | # endif |
28f540f4 | 105 | |
cd5c5f70 | 106 | #if defined __USE_MISC || !defined __USE_XOPEN2K8 || defined __USE_XOPEN2K8XSI |
18598ff1 UD |
107 | /* Return the position of the first bit set in I, or 0 if none are set. |
108 | The least-significant bit is position 1, the most-significant 32. */ | |
109 | extern int ffs (int __i) __THROW __attribute__ ((const)); | |
110 | #endif | |
111 | ||
a5a0310d | 112 | /* Compare S1 and S2, ignoring case. */ |
a784e502 | 113 | extern int strcasecmp (const char *__s1, const char *__s2) |
e656498e | 114 | __THROW __attribute_pure__; |
28f540f4 | 115 | |
a5a0310d | 116 | /* Compare no more than N chars of S1 and S2, ignoring case. */ |
a784e502 | 117 | extern int strncasecmp (const char *__s1, const char *__s2, size_t __n) |
e656498e | 118 | __THROW __attribute_pure__; |
28f540f4 | 119 | |
6cbe890a UD |
120 | #ifdef __USE_XOPEN2K8 |
121 | /* The following functions are equivalent to the both above but they | |
122 | take the locale they use for the collation as an extra argument. | |
123 | This is not standardsized but something like will come. */ | |
124 | # include <xlocale.h> | |
125 | ||
126 | /* Again versions of a few functions which use the given locale instead | |
127 | of the global one. */ | |
a784e502 | 128 | extern int strcasecmp_l (const char *__s1, const char *__s2, __locale_t __loc) |
6cbe890a UD |
129 | __THROW __attribute_pure__ __nonnull ((1, 2, 3)); |
130 | ||
a784e502 | 131 | extern int strncasecmp_l (const char *__s1, const char *__s2, |
6cbe890a UD |
132 | size_t __n, __locale_t __loc) |
133 | __THROW __attribute_pure__ __nonnull ((1, 2, 4)); | |
134 | #endif | |
135 | ||
a5a0310d | 136 | __END_DECLS |
28f540f4 | 137 | |
c1422e5b UD |
138 | #endif /* string.h */ |
139 | ||
28f540f4 | 140 | #endif /* strings.h */ |