x86: Move wcschr SSE2 implementation to multiarch/wcschr-sse2.S
[glibc.git] / string / strings.h
bloba2a2efd4f4e208231036e921a645da49f3781dd8
1 /* Copyright (C) 1991-2022 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
4 The GNU C Library is free software; you can redistribute it and/or
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.
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
12 Lesser General Public License for more details.
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <https://www.gnu.org/licenses/>. */
18 #ifndef _STRINGS_H
19 #define _STRINGS_H 1
21 #include <features.h>
22 #define __need_size_t
23 #include <stddef.h>
25 /* Tell the caller that we provide correct C++ prototypes. */
26 #if defined __cplusplus && __GNUC_PREREQ (4, 4)
27 # define __CORRECT_ISO_CPP_STRINGS_H_PROTO
28 #endif
30 __BEGIN_DECLS
32 #if defined __USE_MISC || !defined __USE_XOPEN2K8
33 /* Compare N bytes of S1 and S2 (same as memcmp). */
34 extern int bcmp (const void *__s1, const void *__s2, size_t __n)
35 __THROW __attribute_pure__ __nonnull ((1, 2));
37 /* Copy N bytes of SRC to DEST (like memmove, but args reversed). */
38 extern void bcopy (const void *__src, void *__dest, size_t __n)
39 __THROW __nonnull ((1, 2));
41 /* Set N bytes of S to 0. */
42 extern void bzero (void *__s, size_t __n) __THROW __nonnull ((1));
44 /* Find the first occurrence of C in S (same as strchr). */
45 # ifdef __CORRECT_ISO_CPP_STRINGS_H_PROTO
46 extern "C++"
48 extern char *index (char *__s, int __c)
49 __THROW __asm ("index") __attribute_pure__ __nonnull ((1));
50 extern const char *index (const char *__s, int __c)
51 __THROW __asm ("index") __attribute_pure__ __nonnull ((1));
53 # if defined __OPTIMIZE__
54 __extern_always_inline char *
55 index (char *__s, int __c) __THROW
57 return __builtin_index (__s, __c);
60 __extern_always_inline const char *
61 index (const char *__s, int __c) __THROW
63 return __builtin_index (__s, __c);
65 # endif
67 # else
68 extern char *index (const char *__s, int __c)
69 __THROW __attribute_pure__ __nonnull ((1));
70 # endif
72 /* Find the last occurrence of C in S (same as strrchr). */
73 # ifdef __CORRECT_ISO_CPP_STRINGS_H_PROTO
74 extern "C++"
76 extern char *rindex (char *__s, int __c)
77 __THROW __asm ("rindex") __attribute_pure__ __nonnull ((1));
78 extern const char *rindex (const char *__s, int __c)
79 __THROW __asm ("rindex") __attribute_pure__ __nonnull ((1));
81 # if defined __OPTIMIZE__
82 __extern_always_inline char *
83 rindex (char *__s, int __c) __THROW
85 return __builtin_rindex (__s, __c);
88 __extern_always_inline const char *
89 rindex (const char *__s, int __c) __THROW
91 return __builtin_rindex (__s, __c);
93 # endif
95 # else
96 extern char *rindex (const char *__s, int __c)
97 __THROW __attribute_pure__ __nonnull ((1));
98 # endif
99 #endif
101 #if defined __USE_MISC || !defined __USE_XOPEN2K8 || defined __USE_XOPEN2K8XSI
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. */
104 extern int ffs (int __i) __THROW __attribute_const__;
105 #endif
107 /* The following two functions are non-standard but necessary for non-32 bit
108 platforms. */
109 # ifdef __USE_MISC
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
115 /* Compare S1 and S2, ignoring case. */
116 extern int strcasecmp (const char *__s1, const char *__s2)
117 __THROW __attribute_pure__ __nonnull ((1, 2));
119 /* Compare no more than N chars of S1 and S2, ignoring case. */
120 extern int strncasecmp (const char *__s1, const char *__s2, size_t __n)
121 __THROW __attribute_pure__ __nonnull ((1, 2));
123 #ifdef __USE_XOPEN2K8
124 /* POSIX.1-2008 extended locale interface (see locale.h). */
125 # include <bits/types/locale_t.h>
127 /* Compare S1 and S2, ignoring case, using collation rules from LOC. */
128 extern int strcasecmp_l (const char *__s1, const char *__s2, locale_t __loc)
129 __THROW __attribute_pure__ __nonnull ((1, 2, 3));
131 /* Compare no more than N chars of S1 and S2, ignoring case, using
132 collation rules from LOC. */
133 extern int strncasecmp_l (const char *__s1, const char *__s2,
134 size_t __n, locale_t __loc)
135 __THROW __attribute_pure__ __nonnull ((1, 2, 4));
136 #endif
138 __END_DECLS
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
148 #endif /* strings.h */