summaryrefslogtreecommitdiff
path: root/string/string.h
diff options
context:
space:
mode:
Diffstat (limited to 'string/string.h')
-rw-r--r--string/string.h200
1 files changed, 20 insertions, 180 deletions
diff --git a/string/string.h b/string/string.h
index 1f3e348834..150cfd8b13 100644
--- a/string/string.h
+++ b/string/string.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991-2016 Free Software Foundation, Inc.
+/* Copyright (C) 1991-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -22,7 +22,8 @@
#ifndef _STRING_H
#define _STRING_H 1
-#include <features.h>
+#define __GLIBC_INTERNAL_STARTING_HEADER_IMPLEMENTATION
+#include <bits/libc-header-start.h>
__BEGIN_DECLS
@@ -37,7 +38,6 @@ __BEGIN_DECLS
#endif
-__BEGIN_NAMESPACE_STD
/* Copy N bytes of SRC to DEST. */
extern void *memcpy (void *__restrict __dest, const void *__restrict __src,
size_t __n) __THROW __nonnull ((1, 2));
@@ -45,7 +45,6 @@ extern void *memcpy (void *__restrict __dest, const void *__restrict __src,
correct behavior for overlapping strings. */
extern void *memmove (void *__dest, const void *__src, size_t __n)
__THROW __nonnull ((1, 2));
-__END_NAMESPACE_STD
/* Copy no more than N bytes of SRC to DEST, stopping when C is found.
Return the position in DEST one byte past where C was copied,
@@ -57,7 +56,6 @@ extern void *memccpy (void *__restrict __dest, const void *__restrict __src,
#endif /* Misc || X/Open. */
-__BEGIN_NAMESPACE_STD
/* Set N bytes of S to C. */
extern void *memset (void *__s, int __c, size_t __n) __THROW __nonnull ((1));
@@ -92,7 +90,6 @@ memchr (const void *__s, int __c, size_t __n) __THROW
extern void *memchr (const void *__s, int __c, size_t __n)
__THROW __attribute_pure__ __nonnull ((1));
#endif
-__END_NAMESPACE_STD
#ifdef __USE_GNU
/* Search in S for C. This is similar to `memchr' but there is no
@@ -120,7 +117,6 @@ extern void *memrchr (const void *__s, int __c, size_t __n)
#endif
-__BEGIN_NAMESPACE_STD
/* Copy SRC to DEST. */
extern char *strcpy (char *__restrict __dest, const char *__restrict __src)
__THROW __nonnull ((1, 2));
@@ -150,23 +146,22 @@ extern int strcoll (const char *__s1, const char *__s2)
extern size_t strxfrm (char *__restrict __dest,
const char *__restrict __src, size_t __n)
__THROW __nonnull ((2));
-__END_NAMESPACE_STD
#ifdef __USE_XOPEN2K8
-/* The following functions are equivalent to the both above but they
- take the locale they use for the collation as an extra argument.
- This is not standardsized but something like will come. */
-# include <xlocale.h>
+/* POSIX.1-2008 extended locale interface (see locale.h). */
+# include <bits/types/locale_t.h>
-/* Compare the collated forms of S1 and S2 using rules from L. */
-extern int strcoll_l (const char *__s1, const char *__s2, __locale_t __l)
+/* Compare the collated forms of S1 and S2, using sorting rules from L. */
+extern int strcoll_l (const char *__s1, const char *__s2, locale_t __l)
__THROW __attribute_pure__ __nonnull ((1, 2, 3));
-/* Put a transformation of SRC into no more than N bytes of DEST. */
+/* Put a transformation of SRC into no more than N bytes of DEST,
+ using sorting rules from L. */
extern size_t strxfrm_l (char *__dest, const char *__src, size_t __n,
- __locale_t __l) __THROW __nonnull ((2, 4));
+ locale_t __l) __THROW __nonnull ((2, 4));
#endif
-#if defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K8
+#if (defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K8 \
+ || __GLIBC_USE (LIB_EXT2))
/* Duplicate S, returning an identical malloc'd string. */
extern char *strdup (const char *__s)
__THROW __attribute_malloc__ __nonnull ((1));
@@ -175,7 +170,7 @@ extern char *strdup (const char *__s)
/* Return a malloc'd copy of at most N bytes of STRING. The
resultant string is terminated even if no null terminator
appears before STRING[N]. */
-#if defined __USE_XOPEN2K8
+#if defined __USE_XOPEN2K8 || __GLIBC_USE (LIB_EXT2)
extern char *strndup (const char *__string, size_t __n)
__THROW __attribute_malloc__ __nonnull ((1));
#endif
@@ -203,7 +198,6 @@ extern char *strndup (const char *__string, size_t __n)
}))
#endif
-__BEGIN_NAMESPACE_STD
/* Find the first occurrence of C in S. */
#ifdef __CORRECT_ISO_CPP_STRING_H_PROTO
extern "C++"
@@ -258,7 +252,6 @@ strrchr (const char *__s, int __c) __THROW
extern char *strrchr (const char *__s, int __c)
__THROW __attribute_pure__ __nonnull ((1));
#endif
-__END_NAMESPACE_STD
#ifdef __USE_GNU
/* This function is similar to `strchr'. But it returns a pointer to
@@ -274,7 +267,6 @@ extern char *strchrnul (const char *__s, int __c)
# endif
#endif
-__BEGIN_NAMESPACE_STD
/* Return the length of the initial segment of S which
consists entirely of characters not in REJECT. */
extern size_t strcspn (const char *__s, const char *__reject)
@@ -342,7 +334,6 @@ extern char *strstr (const char *__haystack, const char *__needle)
/* Divide S into tokens separated by characters in DELIM. */
extern char *strtok (char *__restrict __s, const char *__restrict __delim)
__THROW __nonnull ((2));
-__END_NAMESPACE_STD
/* Divide S into tokens separated by characters in DELIM. Information
passed between calls are stored in SAVE_PTR. */
@@ -389,11 +380,9 @@ extern void *mempcpy (void *__restrict __dest,
#endif
-__BEGIN_NAMESPACE_STD
/* Return the length of S. */
extern size_t strlen (const char *__s)
__THROW __attribute_pure__ __nonnull ((1));
-__END_NAMESPACE_STD
#ifdef __USE_XOPEN2K8
/* Find the length of STRING, but scan at most MAXLEN characters.
@@ -403,10 +392,8 @@ extern size_t strnlen (const char *__string, size_t __maxlen)
#endif
-__BEGIN_NAMESPACE_STD
/* Return a string describing the meaning of the `errno' code in ERRNUM. */
extern char *strerror (int __errnum) __THROW;
-__END_NAMESPACE_STD
#ifdef __USE_XOPEN2K
/* Reentrant version of `strerror'.
There are 2 flavors of `strerror_r', GNU which returns the string
@@ -437,116 +424,16 @@ extern char *strerror_r (int __errnum, char *__buf, size_t __buflen)
#ifdef __USE_XOPEN2K8
/* Translate error number to string according to the locale L. */
-extern char *strerror_l (int __errnum, __locale_t __l) __THROW;
+extern char *strerror_l (int __errnum, locale_t __l) __THROW;
#endif
-
-/* We define this function always since `bzero' is sometimes needed when
- the namespace rules does not allow this. */
-extern void __bzero (void *__s, size_t __n) __THROW __nonnull ((1));
-
#ifdef __USE_MISC
-/* 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));
-
-/* Set N bytes of S to 0. */
-extern void bzero (void *__s, size_t __n) __THROW __nonnull ((1));
-
-/* Compare N bytes of S1 and S2 (same as memcmp). */
-extern int bcmp (const void *__s1, const void *__s2, size_t __n)
- __THROW __attribute_pure__ __nonnull ((1, 2));
-
-/* Find the first occurrence of C in S (same as strchr). */
-# ifdef __CORRECT_ISO_CPP_STRING_H_PROTO
-extern "C++"
-{
-extern char *index (char *__s, int __c)
- __THROW __asm ("index") __attribute_pure__ __nonnull ((1));
-extern const char *index (const char *__s, int __c)
- __THROW __asm ("index") __attribute_pure__ __nonnull ((1));
+# include <strings.h>
-# if defined __OPTIMIZE__ && !defined __CORRECT_ISO_CPP_STRINGS_H_PROTO
-__extern_always_inline char *
-index (char *__s, int __c) __THROW
-{
- return __builtin_index (__s, __c);
-}
+/* Set N bytes of S to 0. The compiler will not delete a call to this
+ function, even if S is dead after the call. */
+extern void explicit_bzero (void *__s, size_t __n) __THROW __nonnull ((1));
-__extern_always_inline const char *
-index (const char *__s, int __c) __THROW
-{
- return __builtin_index (__s, __c);
-}
-# endif
-}
-# else
-extern char *index (const char *__s, int __c)
- __THROW __attribute_pure__ __nonnull ((1));
-# endif
-
-/* Find the last occurrence of C in S (same as strrchr). */
-# ifdef __CORRECT_ISO_CPP_STRING_H_PROTO
-extern "C++"
-{
-extern char *rindex (char *__s, int __c)
- __THROW __asm ("rindex") __attribute_pure__ __nonnull ((1));
-extern const char *rindex (const char *__s, int __c)
- __THROW __asm ("rindex") __attribute_pure__ __nonnull ((1));
-
-# if defined __OPTIMIZE__ && !defined __CORRECT_ISO_CPP_STRINGS_H_PROTO
-__extern_always_inline char *
-rindex (char *__s, int __c) __THROW
-{
- return __builtin_rindex (__s, __c);
-}
-
-__extern_always_inline const char *
-rindex (const char *__s, int __c) __THROW
-{
- return __builtin_rindex (__s, __c);
-}
-#endif
-}
-# else
-extern char *rindex (const char *__s, int __c)
- __THROW __attribute_pure__ __nonnull ((1));
-# endif
-
-/* 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__));
-
-/* The following two functions are non-standard but necessary for non-32 bit
- platforms. */
-# ifdef __USE_GNU
-extern int ffsl (long int __l) __THROW __attribute__ ((__const__));
-__extension__ extern int ffsll (long long int __ll)
- __THROW __attribute__ ((__const__));
-# endif
-
-/* Compare S1 and S2, ignoring case. */
-extern int strcasecmp (const char *__s1, const char *__s2)
- __THROW __attribute_pure__ __nonnull ((1, 2));
-
-/* Compare no more than N chars of S1 and S2, ignoring case. */
-extern int strncasecmp (const char *__s1, const char *__s2, size_t __n)
- __THROW __attribute_pure__ __nonnull ((1, 2));
-#endif /* Use misc. */
-
-#ifdef __USE_GNU
-/* Again versions of a few functions which use the given locale instead
- of the global one. */
-extern int strcasecmp_l (const char *__s1, const char *__s2,
- __locale_t __loc)
- __THROW __attribute_pure__ __nonnull ((1, 2, 3));
-
-extern int strncasecmp_l (const char *__s1, const char *__s2,
- size_t __n, __locale_t __loc)
- __THROW __attribute_pure__ __nonnull ((1, 2, 4));
-#endif
-
-#ifdef __USE_MISC
/* Return the next DELIM-delimited token from *STRINGP,
terminating it with a '\0', and update *STRINGP to point past it. */
extern char *strsep (char **__restrict __stringp,
@@ -601,57 +488,10 @@ extern char *basename (const char *__filename) __THROW __nonnull ((1));
# endif
#endif
-
-#if defined __GNUC__ && __GNUC__ >= 2
-# if defined __OPTIMIZE__ && !defined __OPTIMIZE_SIZE__ \
- && !defined __NO_INLINE__ && !defined __cplusplus
-/* When using GNU CC we provide some optimized versions of selected
- functions from this header. There are two kinds of optimizations:
-
- - machine-dependent optimizations, most probably using inline
- assembler code; these might be quite expensive since the code
- size can increase significantly.
- These optimizations are not used unless the symbol
- __USE_STRING_INLINES
- is defined before including this header.
-
- - machine-independent optimizations which do not increase the
- code size significantly and which optimize mainly situations
- where one or more arguments are compile-time constants.
- These optimizations are used always when the compiler is
- taught to optimize.
-
- One can inhibit all optimizations by defining __NO_STRING_INLINES. */
-
-/* Get the machine-dependent optimizations (if any). */
-# include <bits/string.h>
-
-/* These are generic optimizations which do not add too much inline code. */
-# include <bits/string2.h>
-# endif
-
+#if __GNUC_PREREQ (3,4)
# if __USE_FORTIFY_LEVEL > 0 && defined __fortify_function
/* Functions with security checks. */
-# include <bits/string3.h>
-# endif
-#endif
-
-#if defined __USE_GNU && defined __OPTIMIZE__ \
- && defined __extern_always_inline && __GNUC_PREREQ (3,2)
-# if !defined _FORCE_INLINES && !defined _HAVE_STRING_ARCH_mempcpy
-
-#undef mempcpy
-#undef __mempcpy
-#define mempcpy(dest, src, n) __mempcpy_inline (dest, src, n)
-#define __mempcpy(dest, src, n) __mempcpy_inline (dest, src, n)
-
-__extern_always_inline void *
-__mempcpy_inline (void *__restrict __dest,
- const void *__restrict __src, size_t __n)
-{
- return (char *) memcpy (__dest, __src, __n) + __n;
-}
-
+# include <bits/string_fortified.h>
# endif
#endif