2000-02-18 03:39:52 +08:00
|
|
|
/*
|
|
|
|
* string.h
|
|
|
|
*
|
|
|
|
* Definitions for memory and string functions.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _STRING_H_
|
|
|
|
#define _STRING_H_
|
|
|
|
|
|
|
|
#include "_ansi.h"
|
|
|
|
#include <sys/reent.h>
|
2011-03-03 19:11:41 +08:00
|
|
|
#include <sys/cdefs.h>
|
2012-10-22 23:16:48 +08:00
|
|
|
#include <sys/features.h>
|
2000-02-18 03:39:52 +08:00
|
|
|
|
|
|
|
#define __need_size_t
|
2012-11-01 19:51:12 +08:00
|
|
|
#define __need_NULL
|
2000-02-18 03:39:52 +08:00
|
|
|
#include <stddef.h>
|
|
|
|
|
2016-07-25 17:47:36 +08:00
|
|
|
#if __POSIX_VISIBLE >= 200809
|
2017-03-22 04:21:30 +08:00
|
|
|
#include <xlocale.h>
|
2016-07-25 02:00:34 +08:00
|
|
|
#endif
|
|
|
|
|
2017-07-04 17:49:58 +08:00
|
|
|
#if __BSD_VISIBLE
|
|
|
|
#include <strings.h>
|
|
|
|
#endif
|
|
|
|
|
2002-06-28 07:58:38 +08:00
|
|
|
_BEGIN_STD_C
|
|
|
|
|
2000-02-18 03:39:52 +08:00
|
|
|
_PTR _EXFUN(memchr,(const _PTR, int, size_t));
|
|
|
|
int _EXFUN(memcmp,(const _PTR, const _PTR, size_t));
|
* libc/sys/linux/include/netdb.h, libc/sys/linux/net/getaddrinfo.c,
libc/sys/linux/net/getnameinfo.c: Add restrict keyword to getnameinfo()
and getaddrinfo() to increase standards compliance and match glibc.
* libc/include/string.h, libc/string/memccpy.c, libc/string/memcpy.c,
libc/string/stpcpy.c, libc/string/stpncpy.c, libc/string/strcat.c,
libc/string/strncat.c, libc/string/strncpy.c, libc/string/strtok.c,
libc/string/strtok_r.c, libc/string/strxfrm.c
libc/machine/microblaze/strcpy.c, libc/machine/xscale/memcpy.c,
libc/machine/cris/memcpy.c: Add __restrict to prototype to
increase standards compliance.
2013-07-23 15:05:31 +08:00
|
|
|
_PTR _EXFUN(memcpy,(_PTR __restrict, const _PTR __restrict, size_t));
|
2000-02-18 03:39:52 +08:00
|
|
|
_PTR _EXFUN(memmove,(_PTR, const _PTR, size_t));
|
|
|
|
_PTR _EXFUN(memset,(_PTR, int, size_t));
|
* libc/sys/linux/include/netdb.h, libc/sys/linux/net/getaddrinfo.c,
libc/sys/linux/net/getnameinfo.c: Add restrict keyword to getnameinfo()
and getaddrinfo() to increase standards compliance and match glibc.
* libc/include/string.h, libc/string/memccpy.c, libc/string/memcpy.c,
libc/string/stpcpy.c, libc/string/stpncpy.c, libc/string/strcat.c,
libc/string/strncat.c, libc/string/strncpy.c, libc/string/strtok.c,
libc/string/strtok_r.c, libc/string/strxfrm.c
libc/machine/microblaze/strcpy.c, libc/machine/xscale/memcpy.c,
libc/machine/cris/memcpy.c: Add __restrict to prototype to
increase standards compliance.
2013-07-23 15:05:31 +08:00
|
|
|
char *_EXFUN(strcat,(char *__restrict, const char *__restrict));
|
2000-02-18 03:39:52 +08:00
|
|
|
char *_EXFUN(strchr,(const char *, int));
|
|
|
|
int _EXFUN(strcmp,(const char *, const char *));
|
|
|
|
int _EXFUN(strcoll,(const char *, const char *));
|
* libc/sys/linux/include/netdb.h, libc/sys/linux/net/getaddrinfo.c,
libc/sys/linux/net/getnameinfo.c: Add restrict keyword to getnameinfo()
and getaddrinfo() to increase standards compliance and match glibc.
* libc/include/string.h, libc/string/memccpy.c, libc/string/memcpy.c,
libc/string/stpcpy.c, libc/string/stpncpy.c, libc/string/strcat.c,
libc/string/strncat.c, libc/string/strncpy.c, libc/string/strtok.c,
libc/string/strtok_r.c, libc/string/strxfrm.c
libc/machine/microblaze/strcpy.c, libc/machine/xscale/memcpy.c,
libc/machine/cris/memcpy.c: Add __restrict to prototype to
increase standards compliance.
2013-07-23 15:05:31 +08:00
|
|
|
char *_EXFUN(strcpy,(char *__restrict, const char *__restrict));
|
2000-02-18 03:39:52 +08:00
|
|
|
size_t _EXFUN(strcspn,(const char *, const char *));
|
|
|
|
char *_EXFUN(strerror,(int));
|
|
|
|
size_t _EXFUN(strlen,(const char *));
|
* libc/sys/linux/include/netdb.h, libc/sys/linux/net/getaddrinfo.c,
libc/sys/linux/net/getnameinfo.c: Add restrict keyword to getnameinfo()
and getaddrinfo() to increase standards compliance and match glibc.
* libc/include/string.h, libc/string/memccpy.c, libc/string/memcpy.c,
libc/string/stpcpy.c, libc/string/stpncpy.c, libc/string/strcat.c,
libc/string/strncat.c, libc/string/strncpy.c, libc/string/strtok.c,
libc/string/strtok_r.c, libc/string/strxfrm.c
libc/machine/microblaze/strcpy.c, libc/machine/xscale/memcpy.c,
libc/machine/cris/memcpy.c: Add __restrict to prototype to
increase standards compliance.
2013-07-23 15:05:31 +08:00
|
|
|
char *_EXFUN(strncat,(char *__restrict, const char *__restrict, size_t));
|
2000-02-18 03:39:52 +08:00
|
|
|
int _EXFUN(strncmp,(const char *, const char *, size_t));
|
* libc/sys/linux/include/netdb.h, libc/sys/linux/net/getaddrinfo.c,
libc/sys/linux/net/getnameinfo.c: Add restrict keyword to getnameinfo()
and getaddrinfo() to increase standards compliance and match glibc.
* libc/include/string.h, libc/string/memccpy.c, libc/string/memcpy.c,
libc/string/stpcpy.c, libc/string/stpncpy.c, libc/string/strcat.c,
libc/string/strncat.c, libc/string/strncpy.c, libc/string/strtok.c,
libc/string/strtok_r.c, libc/string/strxfrm.c
libc/machine/microblaze/strcpy.c, libc/machine/xscale/memcpy.c,
libc/machine/cris/memcpy.c: Add __restrict to prototype to
increase standards compliance.
2013-07-23 15:05:31 +08:00
|
|
|
char *_EXFUN(strncpy,(char *__restrict, const char *__restrict, size_t));
|
2000-02-18 03:39:52 +08:00
|
|
|
char *_EXFUN(strpbrk,(const char *, const char *));
|
|
|
|
char *_EXFUN(strrchr,(const char *, int));
|
|
|
|
size_t _EXFUN(strspn,(const char *, const char *));
|
|
|
|
char *_EXFUN(strstr,(const char *, const char *));
|
|
|
|
#ifndef _REENT_ONLY
|
* libc/sys/linux/include/netdb.h, libc/sys/linux/net/getaddrinfo.c,
libc/sys/linux/net/getnameinfo.c: Add restrict keyword to getnameinfo()
and getaddrinfo() to increase standards compliance and match glibc.
* libc/include/string.h, libc/string/memccpy.c, libc/string/memcpy.c,
libc/string/stpcpy.c, libc/string/stpncpy.c, libc/string/strcat.c,
libc/string/strncat.c, libc/string/strncpy.c, libc/string/strtok.c,
libc/string/strtok_r.c, libc/string/strxfrm.c
libc/machine/microblaze/strcpy.c, libc/machine/xscale/memcpy.c,
libc/machine/cris/memcpy.c: Add __restrict to prototype to
increase standards compliance.
2013-07-23 15:05:31 +08:00
|
|
|
char *_EXFUN(strtok,(char *__restrict, const char *__restrict));
|
2000-02-18 03:39:52 +08:00
|
|
|
#endif
|
* libc/sys/linux/include/netdb.h, libc/sys/linux/net/getaddrinfo.c,
libc/sys/linux/net/getnameinfo.c: Add restrict keyword to getnameinfo()
and getaddrinfo() to increase standards compliance and match glibc.
* libc/include/string.h, libc/string/memccpy.c, libc/string/memcpy.c,
libc/string/stpcpy.c, libc/string/stpncpy.c, libc/string/strcat.c,
libc/string/strncat.c, libc/string/strncpy.c, libc/string/strtok.c,
libc/string/strtok_r.c, libc/string/strxfrm.c
libc/machine/microblaze/strcpy.c, libc/machine/xscale/memcpy.c,
libc/machine/cris/memcpy.c: Add __restrict to prototype to
increase standards compliance.
2013-07-23 15:05:31 +08:00
|
|
|
size_t _EXFUN(strxfrm,(char *__restrict, const char *__restrict, size_t));
|
2000-02-18 03:39:52 +08:00
|
|
|
|
2016-07-25 02:00:34 +08:00
|
|
|
#if __POSIX_VISIBLE >= 200809
|
2016-08-25 04:36:31 +08:00
|
|
|
int strcoll_l (const char *, const char *, locale_t);
|
|
|
|
char *strerror_l (int, locale_t);
|
|
|
|
size_t strxfrm_l (char *__restrict, const char *__restrict, size_t, locale_t);
|
|
|
|
#endif
|
2016-03-15 06:13:42 +08:00
|
|
|
#if __MISC_VISIBLE || __POSIX_VISIBLE
|
* libc/sys/linux/include/netdb.h, libc/sys/linux/net/getaddrinfo.c,
libc/sys/linux/net/getnameinfo.c: Add restrict keyword to getnameinfo()
and getaddrinfo() to increase standards compliance and match glibc.
* libc/include/string.h, libc/string/memccpy.c, libc/string/memcpy.c,
libc/string/stpcpy.c, libc/string/stpncpy.c, libc/string/strcat.c,
libc/string/strncat.c, libc/string/strncpy.c, libc/string/strtok.c,
libc/string/strtok_r.c, libc/string/strxfrm.c
libc/machine/microblaze/strcpy.c, libc/machine/xscale/memcpy.c,
libc/machine/cris/memcpy.c: Add __restrict to prototype to
increase standards compliance.
2013-07-23 15:05:31 +08:00
|
|
|
char *_EXFUN(strtok_r,(char *__restrict, const char *__restrict, char **__restrict));
|
2014-08-18 22:18:10 +08:00
|
|
|
#endif
|
2016-03-18 18:49:25 +08:00
|
|
|
#if __BSD_VISIBLE
|
2016-03-18 18:49:26 +08:00
|
|
|
int _EXFUN(timingsafe_bcmp,(const void *, const void *, size_t));
|
2016-03-18 18:49:27 +08:00
|
|
|
int _EXFUN(timingsafe_memcmp,(const void *, const void *, size_t));
|
2016-03-18 18:49:25 +08:00
|
|
|
#endif
|
2016-03-15 06:13:42 +08:00
|
|
|
#if __MISC_VISIBLE || __POSIX_VISIBLE
|
* libc/sys/linux/include/netdb.h, libc/sys/linux/net/getaddrinfo.c,
libc/sys/linux/net/getnameinfo.c: Add restrict keyword to getnameinfo()
and getaddrinfo() to increase standards compliance and match glibc.
* libc/include/string.h, libc/string/memccpy.c, libc/string/memcpy.c,
libc/string/stpcpy.c, libc/string/stpncpy.c, libc/string/strcat.c,
libc/string/strncat.c, libc/string/strncpy.c, libc/string/strtok.c,
libc/string/strtok_r.c, libc/string/strxfrm.c
libc/machine/microblaze/strcpy.c, libc/machine/xscale/memcpy.c,
libc/machine/cris/memcpy.c: Add __restrict to prototype to
increase standards compliance.
2013-07-23 15:05:31 +08:00
|
|
|
_PTR _EXFUN(memccpy,(_PTR __restrict, const _PTR __restrict, int, size_t));
|
2014-08-18 22:18:10 +08:00
|
|
|
#endif
|
|
|
|
#if __GNU_VISIBLE
|
2002-07-24 05:38:00 +08:00
|
|
|
_PTR _EXFUN(mempcpy,(_PTR, const _PTR, size_t));
|
2008-01-12 12:25:55 +08:00
|
|
|
_PTR _EXFUN(memmem, (const _PTR, size_t, const _PTR, size_t));
|
2012-05-10 16:34:08 +08:00
|
|
|
_PTR _EXFUN(memrchr,(const _PTR, int, size_t));
|
2013-06-24 23:11:24 +08:00
|
|
|
_PTR _EXFUN(rawmemchr,(const _PTR, int));
|
2014-08-18 22:18:10 +08:00
|
|
|
#endif
|
2016-04-14 12:50:11 +08:00
|
|
|
#if __POSIX_VISIBLE >= 200809
|
* libc/sys/linux/include/netdb.h, libc/sys/linux/net/getaddrinfo.c,
libc/sys/linux/net/getnameinfo.c: Add restrict keyword to getnameinfo()
and getaddrinfo() to increase standards compliance and match glibc.
* libc/include/string.h, libc/string/memccpy.c, libc/string/memcpy.c,
libc/string/stpcpy.c, libc/string/stpncpy.c, libc/string/strcat.c,
libc/string/strncat.c, libc/string/strncpy.c, libc/string/strtok.c,
libc/string/strtok_r.c, libc/string/strxfrm.c
libc/machine/microblaze/strcpy.c, libc/machine/xscale/memcpy.c,
libc/machine/cris/memcpy.c: Add __restrict to prototype to
increase standards compliance.
2013-07-23 15:05:31 +08:00
|
|
|
char *_EXFUN(stpcpy,(char *__restrict, const char *__restrict));
|
|
|
|
char *_EXFUN(stpncpy,(char *__restrict, const char *__restrict, size_t));
|
2016-04-14 12:50:11 +08:00
|
|
|
#endif
|
2014-08-18 22:18:10 +08:00
|
|
|
#if __GNU_VISIBLE
|
2007-06-09 02:38:51 +08:00
|
|
|
char *_EXFUN(strcasestr,(const char *, const char *));
|
2011-03-28 22:51:28 +08:00
|
|
|
char *_EXFUN(strchrnul,(const char *, int));
|
2012-10-22 23:16:48 +08:00
|
|
|
#endif
|
2016-03-15 06:13:42 +08:00
|
|
|
#if __MISC_VISIBLE || __POSIX_VISIBLE >= 200809 || __XSI_VISIBLE >= 4
|
2000-02-18 03:39:52 +08:00
|
|
|
char *_EXFUN(strdup,(const char *));
|
2012-10-22 23:16:48 +08:00
|
|
|
#endif
|
2000-02-18 03:39:52 +08:00
|
|
|
char *_EXFUN(_strdup_r,(struct _reent *, const char *));
|
2016-03-15 06:13:42 +08:00
|
|
|
#if __POSIX_VISIBLE >= 200809
|
2002-07-24 05:38:00 +08:00
|
|
|
char *_EXFUN(strndup,(const char *, size_t));
|
2012-10-22 23:16:48 +08:00
|
|
|
#endif
|
2002-07-24 05:38:00 +08:00
|
|
|
char *_EXFUN(_strndup_r,(struct _reent *, const char *, size_t));
|
2014-08-18 22:18:10 +08:00
|
|
|
|
2011-02-11 00:48:18 +08:00
|
|
|
/* There are two common strerror_r variants. If you request
|
|
|
|
_GNU_SOURCE, you get the GNU version; otherwise you get the POSIX
|
|
|
|
version. POSIX requires that #undef strerror_r will still let you
|
|
|
|
invoke the underlying function, but that requires gcc support. */
|
2014-08-18 22:18:10 +08:00
|
|
|
#if __GNU_VISIBLE
|
|
|
|
char *_EXFUN(strerror_r,(int, char *, size_t));
|
2016-03-15 06:13:42 +08:00
|
|
|
#elif __POSIX_VISIBLE >= 200112
|
2011-02-11 00:48:18 +08:00
|
|
|
# ifdef __GNUC__
|
2014-08-18 22:18:10 +08:00
|
|
|
int _EXFUN(strerror_r,(int, char *, size_t))
|
2015-02-07 00:14:04 +08:00
|
|
|
#ifdef __ASMNAME
|
|
|
|
__asm__ (__ASMNAME ("__xpg_strerror_r"))
|
|
|
|
#endif
|
|
|
|
;
|
2011-02-11 00:48:18 +08:00
|
|
|
# else
|
2014-08-18 22:18:10 +08:00
|
|
|
int _EXFUN(__xpg_strerror_r,(int, char *, size_t));
|
2011-02-11 00:48:18 +08:00
|
|
|
# define strerror_r __xpg_strerror_r
|
|
|
|
# endif
|
|
|
|
#endif
|
2014-08-18 22:18:10 +08:00
|
|
|
|
|
|
|
/* Reentrant version of strerror. */
|
|
|
|
char * _EXFUN(_strerror_r, (struct _reent *, int, int, int *));
|
|
|
|
|
|
|
|
#if __BSD_VISIBLE
|
|
|
|
size_t _EXFUN(strlcat,(char *, const char *, size_t));
|
|
|
|
size_t _EXFUN(strlcpy,(char *, const char *, size_t));
|
|
|
|
#endif
|
2016-03-15 06:13:42 +08:00
|
|
|
#if __POSIX_VISIBLE >= 200809
|
2002-05-25 07:44:39 +08:00
|
|
|
size_t _EXFUN(strnlen,(const char *, size_t));
|
2014-08-18 22:18:10 +08:00
|
|
|
#endif
|
|
|
|
#if __BSD_VISIBLE
|
2000-02-18 03:39:52 +08:00
|
|
|
char *_EXFUN(strsep,(char **, const char *));
|
2014-08-18 22:18:10 +08:00
|
|
|
#endif
|
|
|
|
|
2016-03-15 06:13:42 +08:00
|
|
|
#if __MISC_VISIBLE
|
2000-02-18 03:39:52 +08:00
|
|
|
char *_EXFUN(strlwr,(char *));
|
|
|
|
char *_EXFUN(strupr,(char *));
|
2014-08-18 22:18:10 +08:00
|
|
|
#endif
|
|
|
|
|
2000-06-03 11:03:03 +08:00
|
|
|
#ifndef DEFS_H /* Kludge to work around problem compiling in gdb */
|
2014-08-18 22:18:10 +08:00
|
|
|
char *_EXFUN(strsignal, (int __signo));
|
2000-06-03 11:03:03 +08:00
|
|
|
#endif
|
2014-08-18 22:18:10 +08:00
|
|
|
|
2011-01-10 18:59:42 +08:00
|
|
|
#ifdef __CYGWIN__
|
2014-08-18 22:18:10 +08:00
|
|
|
int _EXFUN(strtosigno, (const char *__name));
|
2000-02-18 03:39:52 +08:00
|
|
|
#endif
|
|
|
|
|
2017-06-15 04:22:00 +08:00
|
|
|
#if __GNU_VISIBLE
|
|
|
|
int _EXFUN(strverscmp,(const char *, const char *));
|
|
|
|
#endif
|
|
|
|
|
2016-03-15 06:13:42 +08:00
|
|
|
#if __GNU_VISIBLE && defined(__GNUC__)
|
2011-06-11 02:30:38 +08:00
|
|
|
#define strdupa(__s) \
|
2017-07-07 16:47:02 +08:00
|
|
|
(__extension__ ({const char *__sin = (__s); \
|
|
|
|
size_t __len = strlen (__sin) + 1; \
|
|
|
|
char * __sout = (char *) __builtin_alloca (__len); \
|
|
|
|
(char *) memcpy (__sout, __sin, __len);}))
|
2011-06-11 02:30:38 +08:00
|
|
|
#define strndupa(__s, __n) \
|
2017-07-07 16:47:02 +08:00
|
|
|
(__extension__ ({const char *__sin = (__s); \
|
|
|
|
size_t __len = strnlen (__sin, (__n)) + 1; \
|
|
|
|
char *__sout = (char *) __builtin_alloca (__len); \
|
|
|
|
__sout[__len-1] = '\0'; \
|
|
|
|
(char *) memcpy (__sout, __sin, __len-1);}))
|
2016-03-15 06:13:42 +08:00
|
|
|
#endif /* __GNU_VISIBLE && __GNUC__ */
|
2011-06-11 02:30:38 +08:00
|
|
|
|
2015-04-22 16:05:16 +08:00
|
|
|
/* There are two common basename variants. If you do NOT #include <libgen.h>
|
|
|
|
and you do
|
|
|
|
|
|
|
|
#define _GNU_SOURCE
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
you get the GNU version. Otherwise you get the POSIX versionfor which you
|
|
|
|
should #include <libgen.h>i for the function prototype. POSIX requires that
|
|
|
|
#undef basename will still let you invoke the underlying function. However,
|
|
|
|
this also implies that the POSIX version is used in this case. That's made
|
|
|
|
sure here. */
|
|
|
|
#if __GNU_VISIBLE && !defined(basename)
|
2015-07-07 03:58:51 +08:00
|
|
|
# define basename basename
|
|
|
|
char *_EXFUN(__nonnull (1) basename,(const char *)) __asm__(__ASMNAME("__gnu_basename"));
|
2015-03-26 07:19:38 +08:00
|
|
|
#endif
|
|
|
|
|
2005-01-25 02:46:09 +08:00
|
|
|
#include <sys/string.h>
|
|
|
|
|
2002-06-28 07:58:38 +08:00
|
|
|
_END_STD_C
|
|
|
|
|
2000-02-18 03:39:52 +08:00
|
|
|
#endif /* _STRING_H_ */
|