Subversion Repositories Kolibri OS

Rev

Rev 6099 | Blame | Compare with Previous | Last modification | View Log | RSS feed

  1. /*
  2.  * string.h
  3.  *
  4.  * Definitions for memory and string functions.
  5.  */
  6.  
  7. #ifndef _STRING_H_
  8. #define _STRING_H_
  9.  
  10. #include "_ansi.h"
  11. #include <sys/reent.h>
  12. #include <sys/cdefs.h>
  13. #include <sys/features.h>
  14.  
  15. #define __need_size_t
  16. #define __need_NULL
  17. #include <stddef.h>
  18.  
  19. _BEGIN_STD_C
  20.  
  21. _PTR     _EXFUN(memchr,(const _PTR, int, size_t));
  22. int      _EXFUN(memcmp,(const _PTR, const _PTR, size_t));
  23. _PTR     _EXFUN(memcpy,(_PTR __restrict, const _PTR __restrict, size_t));
  24. _PTR     _EXFUN(memmove,(_PTR, const _PTR, size_t));
  25. _PTR     _EXFUN(memset,(_PTR, int, size_t));
  26. char    *_EXFUN(strcat,(char *__restrict, const char *__restrict));
  27. char    *_EXFUN(strchr,(const char *, int));
  28. int      _EXFUN(strcmp,(const char *, const char *));
  29. int      _EXFUN(strcoll,(const char *, const char *));
  30. char    *_EXFUN(strcpy,(char *__restrict, const char *__restrict));
  31. size_t   _EXFUN(strcspn,(const char *, const char *));
  32. char    *_EXFUN(strerror,(int));
  33. size_t   _EXFUN(strlen,(const char *));
  34. char    *_EXFUN(strncat,(char *__restrict, const char *__restrict, size_t));
  35. int      _EXFUN(strncmp,(const char *, const char *, size_t));
  36. char    *_EXFUN(strncpy,(char *__restrict, const char *__restrict, size_t));
  37. char    *_EXFUN(strpbrk,(const char *, const char *));
  38. char    *_EXFUN(strrchr,(const char *, int));
  39. size_t   _EXFUN(strspn,(const char *, const char *));
  40. char    *_EXFUN(strstr,(const char *, const char *));
  41. #ifndef _REENT_ONLY
  42. char    *_EXFUN(strtok,(char *__restrict, const char *__restrict));
  43. #endif
  44. size_t   _EXFUN(strxfrm,(char *__restrict, const char *__restrict, size_t));
  45.  
  46. #if __MISC_VISIBLE || __POSIX_VISIBLE
  47. char    *_EXFUN(strtok_r,(char *__restrict, const char *__restrict, char **__restrict));
  48. #endif
  49. #if __BSD_VISIBLE || (__POSIX_VISIBLE && __POSIX_VISIBLE < 200809)
  50. int      _EXFUN(bcmp,(const void *, const void *, size_t));
  51. void     _EXFUN(bcopy,(const void *, void *, size_t));
  52. void     _EXFUN(bzero,(void *, size_t));
  53. #endif
  54. #if __BSD_VISIBLE
  55. void     _EXFUN(explicit_bzero,(void *, size_t));
  56. int      _EXFUN(timingsafe_bcmp,(const void *, const void *, size_t));
  57. int      _EXFUN(timingsafe_memcmp,(const void *, const void *, size_t));
  58. #endif
  59. #if __MISC_VISIBLE || __POSIX_VISIBLE >= 200809
  60. int      _EXFUN(ffs,(int));
  61. #endif
  62. #if __BSD_VISIBLE || (__POSIX_VISIBLE && __POSIX_VISIBLE < 200809)
  63. char    *_EXFUN(index,(const char *, int));
  64. #endif
  65. #if __MISC_VISIBLE || __POSIX_VISIBLE
  66. _PTR     _EXFUN(memccpy,(_PTR __restrict, const _PTR __restrict, int, size_t));
  67. #endif
  68. #if __GNU_VISIBLE
  69. _PTR     _EXFUN(mempcpy,(_PTR, const _PTR, size_t));
  70. _PTR     _EXFUN(memmem, (const _PTR, size_t, const _PTR, size_t));
  71. _PTR     _EXFUN(memrchr,(const _PTR, int, size_t));
  72. _PTR     _EXFUN(rawmemchr,(const _PTR, int));
  73. #endif
  74. #if __BSD_VISIBLE || (__POSIX_VISIBLE && __POSIX_VISIBLE < 200809)
  75. char    *_EXFUN(rindex,(const char *, int));
  76. #endif
  77. char    *_EXFUN(stpcpy,(char *__restrict, const char *__restrict));
  78. char    *_EXFUN(stpncpy,(char *__restrict, const char *__restrict, size_t));
  79. #if __BSD_VISIBLE || __POSIX_VISIBLE
  80. int      _EXFUN(strcasecmp,(const char *, const char *));
  81. #endif
  82. #if __GNU_VISIBLE
  83. char    *_EXFUN(strcasestr,(const char *, const char *));
  84. char    *_EXFUN(strchrnul,(const char *, int));
  85. #endif
  86. #if __MISC_VISIBLE || __POSIX_VISIBLE >= 200809 || __XSI_VISIBLE >= 4
  87. char    *_EXFUN(strdup,(const char *));
  88. #endif
  89. char    *_EXFUN(_strdup_r,(struct _reent *, const char *));
  90. #if __POSIX_VISIBLE >= 200809
  91. char    *_EXFUN(strndup,(const char *, size_t));
  92. #endif
  93. char    *_EXFUN(_strndup_r,(struct _reent *, const char *, size_t));
  94.  
  95. #if __GNU_VISIBLE
  96. int      _EXFUN(ffsl,(long));
  97. int      _EXFUN(ffsll, (long long));
  98. #endif
  99.  
  100. /* There are two common strerror_r variants.  If you request
  101.    _GNU_SOURCE, you get the GNU version; otherwise you get the POSIX
  102.    version.  POSIX requires that #undef strerror_r will still let you
  103.    invoke the underlying function, but that requires gcc support.  */
  104. #if __GNU_VISIBLE
  105. char    *_EXFUN(strerror_r,(int, char *, size_t));
  106. #elif __POSIX_VISIBLE >= 200112
  107. # ifdef __GNUC__
  108. int     _EXFUN(strerror_r,(int, char *, size_t))
  109. #ifdef __ASMNAME
  110.              __asm__ (__ASMNAME ("__xpg_strerror_r"))
  111. #endif
  112.   ;
  113. # else
  114. int     _EXFUN(__xpg_strerror_r,(int, char *, size_t));
  115. #  define strerror_r __xpg_strerror_r
  116. # endif
  117. #endif
  118.  
  119. /* Reentrant version of strerror.  */
  120. char *  _EXFUN(_strerror_r, (struct _reent *, int, int, int *));
  121.  
  122. #if __BSD_VISIBLE
  123. size_t  _EXFUN(strlcat,(char *, const char *, size_t));
  124. size_t  _EXFUN(strlcpy,(char *, const char *, size_t));
  125. #endif
  126. #if __BSD_VISIBLE || __POSIX_VISIBLE
  127. int     _EXFUN(strncasecmp,(const char *, const char *, size_t));
  128. #endif
  129. #if __POSIX_VISIBLE >= 200809
  130. size_t   _EXFUN(strnlen,(const char *, size_t));
  131. #endif
  132. #if __BSD_VISIBLE
  133. char    *_EXFUN(strsep,(char **, const char *));
  134. #endif
  135.  
  136. #if __MISC_VISIBLE
  137. char    *_EXFUN(strlwr,(char *));
  138. char    *_EXFUN(strupr,(char *));
  139. #endif
  140.  
  141. #ifndef DEFS_H  /* Kludge to work around problem compiling in gdb */
  142. char    *_EXFUN(strsignal, (int __signo));
  143. #endif
  144.  
  145. #ifdef __CYGWIN__
  146. int     _EXFUN(strtosigno, (const char *__name));
  147. #endif
  148.  
  149. #if __GNU_VISIBLE && defined(__GNUC__)
  150. #define strdupa(__s) \
  151.         (__extension__ ({const char *__in = (__s); \
  152.                          size_t __len = strlen (__in) + 1; \
  153.                          char * __out = (char *) __builtin_alloca (__len); \
  154.                          (char *) memcpy (__out, __in, __len);}))
  155. #define strndupa(__s, __n) \
  156.         (__extension__ ({const char *__in = (__s); \
  157.                          size_t __len = strnlen (__in, (__n)) + 1; \
  158.                          char *__out = (char *) __builtin_alloca (__len); \
  159.                          __out[__len-1] = '\0'; \
  160.                          (char *) memcpy (__out, __in, __len-1);}))
  161. #endif /* __GNU_VISIBLE && __GNUC__ */
  162.  
  163. /* There are two common basename variants.  If you do NOT #include <libgen.h>
  164.    and you do
  165.  
  166.      #define _GNU_SOURCE
  167.      #include <string.h>
  168.  
  169.    you get the GNU version.  Otherwise you get the POSIX versionfor which you
  170.    should #include <libgen.h>i for the function prototype.  POSIX requires that
  171.    #undef basename will still let you invoke the underlying function.  However,
  172.    this also implies that the POSIX version is used in this case.  That's made
  173.    sure here. */
  174. #if __GNU_VISIBLE && !defined(basename)
  175. # define basename basename
  176. char    *_EXFUN(__nonnull (1) basename,(const char *)) __asm__(__ASMNAME("__gnu_basename"));
  177. #endif
  178.  
  179. #include <sys/string.h>
  180.  
  181. _END_STD_C
  182.  
  183. #endif /* _STRING_H_ */
  184.