master
  1/* Copyright (C) 1991-2025 Free Software Foundation, Inc.
  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
  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.
  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
 12   Lesser General Public License for more details.
 13
 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/>.  */
 17
 18#ifndef	_STRINGS_H
 19#define	_STRINGS_H	1
 20
 21#include <features.h>
 22#define __need_size_t
 23#include <stddef.h>
 24
 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
 29
 30__BEGIN_DECLS
 31
 32#if defined __USE_MISC || !defined __USE_XOPEN2K8
 33/* Compare N bytes of S1 and S2 (same as memcmp).  */
 34extern int bcmp (const void *__s1, const void *__s2, size_t __n)
 35     __THROW __attribute_pure__ __nonnull ((1, 2));
 36
 37/* Copy N bytes of SRC to DEST (like memmove, but args reversed).  */
 38extern void bcopy (const void *__src, void *__dest, size_t __n)
 39  __THROW __nonnull ((1, 2));
 40
 41/* Set N bytes of S to 0.  */
 42extern void bzero (void *__s, size_t __n) __THROW __nonnull ((1));
 43
 44/* Find the first occurrence of C in S (same as strchr).  */
 45# ifdef __CORRECT_ISO_CPP_STRINGS_H_PROTO
 46extern "C++"
 47{
 48extern char *index (char *__s, int __c)
 49     __THROW __asm ("index") __attribute_pure__ __nonnull ((1));
 50extern const char *index (const char *__s, int __c)
 51     __THROW __asm ("index") __attribute_pure__ __nonnull ((1));
 52
 53#  if defined __OPTIMIZE__
 54__extern_always_inline char *
 55index (char *__s, int __c) __THROW
 56{
 57  return __builtin_index (__s, __c);
 58}
 59
 60__extern_always_inline const char *
 61index (const char *__s, int __c) __THROW
 62{
 63  return __builtin_index (__s, __c);
 64}
 65#  endif
 66}
 67# else
 68extern char *index (const char *__s, int __c)
 69     __THROW __attribute_pure__ __nonnull ((1));
 70# endif
 71
 72/* Find the last occurrence of C in S (same as strrchr).  */
 73# ifdef __CORRECT_ISO_CPP_STRINGS_H_PROTO
 74extern "C++"
 75{
 76extern char *rindex (char *__s, int __c)
 77     __THROW __asm ("rindex") __attribute_pure__ __nonnull ((1));
 78extern const char *rindex (const char *__s, int __c)
 79     __THROW __asm ("rindex") __attribute_pure__ __nonnull ((1));
 80
 81#  if defined __OPTIMIZE__
 82__extern_always_inline char *
 83rindex (char *__s, int __c) __THROW
 84{
 85  return __builtin_rindex (__s, __c);
 86}
 87
 88__extern_always_inline const char *
 89rindex (const char *__s, int __c) __THROW
 90{
 91  return __builtin_rindex (__s, __c);
 92}
 93#  endif
 94}
 95# else
 96extern char *rindex (const char *__s, int __c)
 97     __THROW __attribute_pure__ __nonnull ((1));
 98# endif
 99#endif
100
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.  */
104extern int ffs (int __i) __THROW __attribute_const__;
105#endif
106
107/* The following two functions are non-standard but necessary for non-32 bit
108   platforms.  */
109# ifdef	__USE_MISC
110extern int ffsl (long int __l) __THROW __attribute_const__;
111__extension__ extern int ffsll (long long int __ll)
112     __THROW __attribute_const__;
113# endif
114
115/* Compare S1 and S2, ignoring case.  */
116extern int strcasecmp (const char *__s1, const char *__s2)
117     __THROW __attribute_pure__ __nonnull ((1, 2));
118
119/* Compare no more than N chars of S1 and S2, ignoring case.  */
120extern int strncasecmp (const char *__s1, const char *__s2, size_t __n)
121     __THROW __attribute_pure__ __nonnull ((1, 2));
122
123#ifdef	__USE_XOPEN2K8
124/* POSIX.1-2008 extended locale interface (see locale.h).  */
125# include <bits/types/locale_t.h>
126
127/* Compare S1 and S2, ignoring case, using collation rules from LOC.  */
128extern int strcasecmp_l (const char *__s1, const char *__s2, locale_t __loc)
129     __THROW __attribute_pure__ __nonnull ((1, 2, 3));
130
131/* Compare no more than N chars of S1 and S2, ignoring case, using
132   collation rules from LOC.  */
133extern 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
137
138__END_DECLS
139
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
148#endif	/* strings.h  */