]>
Commit | Line | Data |
---|---|---|
bfff8b1b | 1 | /* Copyright (C) 1991-2017 Free Software Foundation, Inc. |
54d79e99 UD |
2 | This file is part of the GNU C Library. |
3 | ||
4 | The GNU C Library is free software; you can redistribute it and/or | |
41bdb6e2 AJ |
5 | modify it under the terms of the GNU Lesser General Public |
6 | License as published by the Free Software Foundation; either | |
7 | version 2.1 of the License, or (at your option) any later version. | |
54d79e99 UD |
8 | |
9 | The GNU C Library is distributed in the hope that it will be useful, | |
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
41bdb6e2 | 12 | Lesser General Public License for more details. |
54d79e99 | 13 | |
41bdb6e2 | 14 | You should have received a copy of the GNU Lesser General Public |
59ba27a6 PE |
15 | License along with the GNU C Library; if not, see |
16 | <http://www.gnu.org/licenses/>. */ | |
28f540f4 | 17 | |
28f540f4 | 18 | #ifndef _STRINGS_H |
28f540f4 | 19 | #define _STRINGS_H 1 |
5107cf1d | 20 | |
7b037c09 ZW |
21 | #include <features.h> |
22 | #define __need_size_t | |
23 | #include <stddef.h> | |
a5a0310d | 24 | |
8e2e833a | 25 | /* Tell the caller that we provide correct C++ prototypes. */ |
7b037c09 ZW |
26 | #if defined __cplusplus && __GNUC_PREREQ (4, 4) |
27 | # define __CORRECT_ISO_CPP_STRINGS_H_PROTO | |
28 | #endif | |
8585cb74 | 29 | |
a5a0310d UD |
30 | __BEGIN_DECLS |
31 | ||
7b037c09 | 32 | #if defined __USE_MISC || !defined __USE_XOPEN2K8 |
a5a0310d | 33 | /* Compare N bytes of S1 and S2 (same as memcmp). */ |
a784e502 | 34 | extern int bcmp (const void *__s1, const void *__s2, size_t __n) |
7b037c09 | 35 | __THROW __attribute_pure__ __nonnull ((1, 2)); |
a5a0310d UD |
36 | |
37 | /* Copy N bytes of SRC to DEST (like memmove, but args reversed). */ | |
7b037c09 ZW |
38 | extern void bcopy (const void *__src, void *__dest, size_t __n) |
39 | __THROW __nonnull ((1, 2)); | |
a5a0310d UD |
40 | |
41 | /* Set N bytes of S to 0. */ | |
7b037c09 | 42 | extern void bzero (void *__s, size_t __n) __THROW __nonnull ((1)); |
a5a0310d | 43 | |
a5a0310d | 44 | /* Find the first occurrence of C in S (same as strchr). */ |
7b037c09 | 45 | # ifdef __CORRECT_ISO_CPP_STRINGS_H_PROTO |
8585cb74 UD |
46 | extern "C++" |
47 | { | |
48 | extern char *index (char *__s, int __c) | |
49 | __THROW __asm ("index") __attribute_pure__ __nonnull ((1)); | |
a784e502 | 50 | extern const char *index (const char *__s, int __c) |
8585cb74 UD |
51 | __THROW __asm ("index") __attribute_pure__ __nonnull ((1)); |
52 | ||
7b037c09 | 53 | # if defined __OPTIMIZE__ |
8585cb74 UD |
54 | __extern_always_inline char * |
55 | index (char *__s, int __c) __THROW | |
56 | { | |
57 | return __builtin_index (__s, __c); | |
58 | } | |
59 | ||
a784e502 UD |
60 | __extern_always_inline const char * |
61 | index (const char *__s, int __c) __THROW | |
8585cb74 UD |
62 | { |
63 | return __builtin_index (__s, __c); | |
64 | } | |
7b037c09 | 65 | # endif |
8585cb74 | 66 | } |
7b037c09 | 67 | # else |
a784e502 | 68 | extern char *index (const char *__s, int __c) |
8585cb74 | 69 | __THROW __attribute_pure__ __nonnull ((1)); |
7b037c09 | 70 | # endif |
a5a0310d UD |
71 | |
72 | /* Find the last occurrence of C in S (same as strrchr). */ | |
7b037c09 | 73 | # ifdef __CORRECT_ISO_CPP_STRINGS_H_PROTO |
8585cb74 UD |
74 | extern "C++" |
75 | { | |
76 | extern char *rindex (char *__s, int __c) | |
77 | __THROW __asm ("rindex") __attribute_pure__ __nonnull ((1)); | |
a784e502 | 78 | extern const char *rindex (const char *__s, int __c) |
8585cb74 UD |
79 | __THROW __asm ("rindex") __attribute_pure__ __nonnull ((1)); |
80 | ||
7b037c09 | 81 | # if defined __OPTIMIZE__ |
8585cb74 UD |
82 | __extern_always_inline char * |
83 | rindex (char *__s, int __c) __THROW | |
84 | { | |
85 | return __builtin_rindex (__s, __c); | |
86 | } | |
87 | ||
a784e502 UD |
88 | __extern_always_inline const char * |
89 | rindex (const char *__s, int __c) __THROW | |
8585cb74 UD |
90 | { |
91 | return __builtin_rindex (__s, __c); | |
92 | } | |
7b037c09 | 93 | # endif |
8585cb74 | 94 | } |
7b037c09 | 95 | # else |
a784e502 | 96 | extern char *rindex (const char *__s, int __c) |
8585cb74 UD |
97 | __THROW __attribute_pure__ __nonnull ((1)); |
98 | # endif | |
7b037c09 | 99 | #endif |
28f540f4 | 100 | |
cd5c5f70 | 101 | #if defined __USE_MISC || !defined __USE_XOPEN2K8 || defined __USE_XOPEN2K8XSI |
18598ff1 UD |
102 | /* Return the position of the first bit set in I, or 0 if none are set. |
103 | The least-significant bit is position 1, the most-significant 32. */ | |
7b037c09 | 104 | extern int ffs (int __i) __THROW __attribute_const__; |
18598ff1 UD |
105 | #endif |
106 | ||
7b037c09 ZW |
107 | /* The following two functions are non-standard but necessary for non-32 bit |
108 | platforms. */ | |
109 | # ifdef __USE_GNU | |
110 | extern int ffsl (long int __l) __THROW __attribute_const__; | |
111 | __extension__ extern int ffsll (long long int __ll) | |
112 | __THROW __attribute_const__; | |
113 | # endif | |
114 | ||
a5a0310d | 115 | /* Compare S1 and S2, ignoring case. */ |
a784e502 | 116 | extern int strcasecmp (const char *__s1, const char *__s2) |
7b037c09 | 117 | __THROW __attribute_pure__ __nonnull ((1, 2)); |
28f540f4 | 118 | |
a5a0310d | 119 | /* Compare no more than N chars of S1 and S2, ignoring case. */ |
a784e502 | 120 | extern int strncasecmp (const char *__s1, const char *__s2, size_t __n) |
7b037c09 | 121 | __THROW __attribute_pure__ __nonnull ((1, 2)); |
28f540f4 | 122 | |
6cbe890a | 123 | #ifdef __USE_XOPEN2K8 |
f0be25b6 ZW |
124 | /* POSIX.1-2008 extended locale interface (see locale.h). */ |
125 | # include <bits/types/locale_t.h> | |
6cbe890a | 126 | |
7b037c09 | 127 | /* Compare S1 and S2, ignoring case, using collation rules from LOC. */ |
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 | ||
7b037c09 ZW |
131 | /* Compare no more than N chars of S1 and S2, ignoring case, using |
132 | collation rules from LOC. */ | |
a784e502 | 133 | extern int strncasecmp_l (const char *__s1, const char *__s2, |
6cbe890a UD |
134 | size_t __n, __locale_t __loc) |
135 | __THROW __attribute_pure__ __nonnull ((1, 2, 4)); | |
136 | #endif | |
137 | ||
a5a0310d | 138 | __END_DECLS |
28f540f4 | 139 | |
38765ab6 AZ |
140 | #if __GNUC_PREREQ (3,4) && __USE_FORTIFY_LEVEL > 0 \ |
141 | && defined __fortify_function | |
142 | /* Functions with security checks. */ | |
143 | # if defined __USE_MISC || !defined __USE_XOPEN2K8 | |
144 | # include <bits/strings_fortified.h> | |
145 | # endif | |
146 | #endif | |
147 | ||
28f540f4 | 148 | #endif /* strings.h */ |