Files
glibc/string/strings.h
T

149 lines
4.6 KiB
C
Raw Normal View History

/* Copyright (C) 1991-2018 Free Software Foundation, Inc.
1996-11-15 04:08:00 +00:00
This file is part of the GNU C Library.
1995-02-18 01:27:10 +00:00
1996-11-15 04:08:00 +00:00
The GNU C Library is free software; you can redistribute it and/or
2001-07-06 04:58:11 +00:00
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
1995-02-18 01:27:10 +00:00
1996-11-15 04:08:00 +00:00
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
2001-07-06 04:58:11 +00:00
Lesser General Public License for more details.
1995-02-18 01:27:10 +00:00
2001-07-06 04:58:11 +00:00
You should have received a copy of the GNU Lesser General Public
2012-02-09 23:18:22 +00:00
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
1995-02-18 01:27:10 +00:00
#ifndef _STRINGS_H
#define _STRINGS_H 1
1997-06-21 02:59:26 +00:00
#include <features.h>
#define __need_size_t
#include <stddef.h>
1995-02-18 01:27:10 +00:00
/* Tell the caller that we provide correct C++ prototypes. */
#if defined __cplusplus && __GNUC_PREREQ (4, 4)
# define __CORRECT_ISO_CPP_STRINGS_H_PROTO
#endif
1997-09-30 17:10:40 +00:00
__BEGIN_DECLS
1995-02-18 01:27:10 +00:00
#if defined __USE_MISC || !defined __USE_XOPEN2K8
1997-09-30 17:10:40 +00:00
/* Compare N bytes of S1 and S2 (same as memcmp). */
2012-01-07 23:57:22 -05:00
extern int bcmp (const void *__s1, const void *__s2, size_t __n)
__THROW __attribute_pure__ __nonnull ((1, 2));
1995-02-18 01:27:10 +00:00
1997-09-30 17:10:40 +00:00
/* Copy N bytes of SRC to DEST (like memmove, but args reversed). */
extern void bcopy (const void *__src, void *__dest, size_t __n)
__THROW __nonnull ((1, 2));
1997-09-30 17:10:40 +00:00
/* Set N bytes of S to 0. */
extern void bzero (void *__s, size_t __n) __THROW __nonnull ((1));
1997-09-30 17:10:40 +00:00
/* Find the first occurrence of C in S (same as strchr). */
# ifdef __CORRECT_ISO_CPP_STRINGS_H_PROTO
extern "C++"
{
extern char *index (char *__s, int __c)
__THROW __asm ("index") __attribute_pure__ __nonnull ((1));
2012-01-07 23:57:22 -05:00
extern const char *index (const char *__s, int __c)
__THROW __asm ("index") __attribute_pure__ __nonnull ((1));
# if defined __OPTIMIZE__
__extern_always_inline char *
index (char *__s, int __c) __THROW
{
return __builtin_index (__s, __c);
}
2012-01-07 23:57:22 -05:00
__extern_always_inline const char *
index (const char *__s, int __c) __THROW
{
return __builtin_index (__s, __c);
}
# endif
}
# else
2012-01-07 23:57:22 -05:00
extern char *index (const char *__s, int __c)
__THROW __attribute_pure__ __nonnull ((1));
# endif
1997-09-30 17:10:40 +00:00
/* Find the last occurrence of C in S (same as strrchr). */
# ifdef __CORRECT_ISO_CPP_STRINGS_H_PROTO
extern "C++"
{
extern char *rindex (char *__s, int __c)
__THROW __asm ("rindex") __attribute_pure__ __nonnull ((1));
2012-01-07 23:57:22 -05:00
extern const char *rindex (const char *__s, int __c)
__THROW __asm ("rindex") __attribute_pure__ __nonnull ((1));
# if defined __OPTIMIZE__
__extern_always_inline char *
rindex (char *__s, int __c) __THROW
{
return __builtin_rindex (__s, __c);
}
2012-01-07 23:57:22 -05:00
__extern_always_inline const char *
rindex (const char *__s, int __c) __THROW
{
return __builtin_rindex (__s, __c);
}
# endif
}
# else
2012-01-07 23:57:22 -05:00
extern char *rindex (const char *__s, int __c)
__THROW __attribute_pure__ __nonnull ((1));
# endif
#endif
1997-09-30 17:10:40 +00:00
2010-01-14 16:16:21 -08:00
#if defined __USE_MISC || !defined __USE_XOPEN2K8 || defined __USE_XOPEN2K8XSI
2010-01-10 02:08:32 -08:00
/* Return the position of the first bit set in I, or 0 if none are set.
The least-significant bit is position 1, the most-significant 32. */
extern int ffs (int __i) __THROW __attribute_const__;
2010-01-10 02:08:32 -08:00
#endif
/* The following two functions are non-standard but necessary for non-32 bit
platforms. */
# ifdef __USE_MISC
extern int ffsl (long int __l) __THROW __attribute_const__;
__extension__ extern int ffsll (long long int __ll)
__THROW __attribute_const__;
# endif
1997-09-30 17:10:40 +00:00
/* Compare S1 and S2, ignoring case. */
2012-01-07 23:57:22 -05:00
extern int strcasecmp (const char *__s1, const char *__s2)
__THROW __attribute_pure__ __nonnull ((1, 2));
1997-09-30 17:10:40 +00:00
/* Compare no more than N chars of S1 and S2, ignoring case. */
2012-01-07 23:57:22 -05:00
extern int strncasecmp (const char *__s1, const char *__s2, size_t __n)
__THROW __attribute_pure__ __nonnull ((1, 2));
1997-09-30 17:10:40 +00:00
#ifdef __USE_XOPEN2K8
/* POSIX.1-2008 extended locale interface (see locale.h). */
# include <bits/types/locale_t.h>
/* Compare S1 and S2, ignoring case, using collation rules from LOC. */
extern int strcasecmp_l (const char *__s1, const char *__s2, locale_t __loc)
__THROW __attribute_pure__ __nonnull ((1, 2, 3));
/* Compare no more than N chars of S1 and S2, ignoring case, using
collation rules from LOC. */
2012-01-07 23:57:22 -05:00
extern int strncasecmp_l (const char *__s1, const char *__s2,
size_t __n, locale_t __loc)
__THROW __attribute_pure__ __nonnull ((1, 2, 4));
#endif
1997-09-30 17:10:40 +00:00
__END_DECLS
1995-02-18 01:27:10 +00:00
#if __GNUC_PREREQ (3,4) && __USE_FORTIFY_LEVEL > 0 \
&& defined __fortify_function
/* Functions with security checks. */
# if defined __USE_MISC || !defined __USE_XOPEN2K8
# include <bits/strings_fortified.h>
# endif
#endif
1995-02-18 01:27:10 +00:00
#endif /* strings.h */