Subversion Repositories Kolibri OS

Rev

Rev 4921 | Go to most recent revision | 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 __POSIX_VISIBLE
  47. char    *_EXFUN(strtok_r,(char *__restrict, const char *__restrict, char **__restrict));
  48. #endif
  49. #if __BSD_VISIBLE
  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. int      _EXFUN(ffs,(int));
  54. char    *_EXFUN(index,(const char *, int));
  55. #endif
  56. #if __BSD_VISIBLE || __XSI_VISIBLE
  57. _PTR     _EXFUN(memccpy,(_PTR __restrict, const _PTR __restrict, int, size_t));
  58. #endif
  59. #if __GNU_VISIBLE
  60. _PTR     _EXFUN(mempcpy,(_PTR, const _PTR, size_t));
  61. _PTR     _EXFUN(memmem, (const _PTR, size_t, const _PTR, size_t));
  62. #endif
  63. _PTR     _EXFUN(memrchr,(const _PTR, int, size_t));
  64. #if __GNU_VISIBLE
  65. _PTR     _EXFUN(rawmemchr,(const _PTR, int));
  66. #endif
  67. #if __BSD_VISIBLE
  68. char    *_EXFUN(rindex,(const char *, int));
  69. #endif
  70. char    *_EXFUN(stpcpy,(char *__restrict, const char *__restrict));
  71. char    *_EXFUN(stpncpy,(char *__restrict, const char *__restrict, size_t));
  72. #if __BSD_VISIBLE || __POSIX_VISIBLE
  73. int      _EXFUN(strcasecmp,(const char *, const char *));
  74. #endif
  75. #if __GNU_VISIBLE
  76. char    *_EXFUN(strcasestr,(const char *, const char *));
  77. char    *_EXFUN(strchrnul,(const char *, int));
  78. #endif
  79. #if __XSI_VISIBLE >= 500
  80. char    *_EXFUN(strdup,(const char *));
  81. #endif
  82. #ifndef __STRICT_ANSI__
  83. char    *_EXFUN(_strdup_r,(struct _reent *, const char *));
  84. #endif
  85. #if __XSI_VISIBLE >= 700
  86. char    *_EXFUN(strndup,(const char *, size_t));
  87. #endif
  88.  
  89. #ifndef __STRICT_ANSI__
  90. char    *_EXFUN(_strndup_r,(struct _reent *, const char *, size_t));
  91. #endif
  92.  
  93. #if __GNU_VISIBLE
  94. int      _EXFUN(ffsl,(long));
  95. int      _EXFUN(ffsll, (long long));
  96. #endif
  97.  
  98. /* There are two common strerror_r variants.  If you request
  99.    _GNU_SOURCE, you get the GNU version; otherwise you get the POSIX
  100.    version.  POSIX requires that #undef strerror_r will still let you
  101.    invoke the underlying function, but that requires gcc support.  */
  102. #if __GNU_VISIBLE
  103. char    *_EXFUN(strerror_r,(int, char *, size_t));
  104. #else
  105. # ifdef __GNUC__
  106. int     _EXFUN(strerror_r,(int, char *, size_t))
  107. #ifdef __ASMNAME
  108.              __asm__ (__ASMNAME ("__xpg_strerror_r"))
  109. #endif
  110.   ;
  111. # else
  112. int     _EXFUN(__xpg_strerror_r,(int, char *, size_t));
  113. #  define strerror_r __xpg_strerror_r
  114. # endif
  115. #endif
  116.  
  117. /* Reentrant version of strerror.  */
  118. char *  _EXFUN(_strerror_r, (struct _reent *, int, int, int *));
  119.  
  120. #if __BSD_VISIBLE
  121. size_t  _EXFUN(strlcat,(char *, const char *, size_t));
  122. size_t  _EXFUN(strlcpy,(char *, const char *, size_t));
  123. #endif
  124. #if __BSD_VISIBLE || __POSIX_VISIBLE
  125. int     _EXFUN(strncasecmp,(const char *, const char *, size_t));
  126. #endif
  127. #if !defined(__STRICT_ANSI__) || __POSIX_VISIBLE >= 200809 || \
  128.     __XSI_VISIBLE >= 700
  129. size_t   _EXFUN(strnlen,(const char *, size_t));
  130. #endif
  131. #if __BSD_VISIBLE
  132. char    *_EXFUN(strsep,(char **, const char *));
  133. #endif
  134.  
  135. /*
  136.  * The origin of these is unknown to me so I am conditionalizing them
  137.  * on __STRICT_ANSI__. Finetuning this is definitely needed. --joel
  138.  */
  139. #if !defined(__STRICT_ANSI__)
  140. char    *_EXFUN(strlwr,(char *));
  141. char    *_EXFUN(strupr,(char *));
  142. #endif
  143.  
  144. #ifndef DEFS_H  /* Kludge to work around problem compiling in gdb */
  145. char    *_EXFUN(strsignal, (int __signo));
  146. #endif
  147.  
  148. #ifdef __CYGWIN__
  149. int     _EXFUN(strtosigno, (const char *__name));
  150. #endif
  151.  
  152. #if defined _GNU_SOURCE && defined __GNUC__
  153. #define strdupa(__s) \
  154.         (__extension__ ({const char *__in = (__s); \
  155.                          size_t __len = strlen (__in) + 1; \
  156.                          char * __out = (char *) __builtin_alloca (__len); \
  157.                          (char *) memcpy (__out, __in, __len);}))
  158. #define strndupa(__s, __n) \
  159.         (__extension__ ({const char *__in = (__s); \
  160.                          size_t __len = strnlen (__in, (__n)) + 1; \
  161.                          char *__out = (char *) __builtin_alloca (__len); \
  162.                          __out[__len-1] = '\0'; \
  163.                          (char *) memcpy (__out, __in, __len-1);}))
  164. #endif /* _GNU_SOURCE && __GNUC__ */
  165.  
  166. /* There are two common basename variants.  If you do NOT #include <libgen.h>
  167.    and you do
  168.  
  169.      #define _GNU_SOURCE
  170.      #include <string.h>
  171.  
  172.    you get the GNU version.  Otherwise you get the POSIX versionfor which you
  173.    should #include <libgen.h>i for the function prototype.  POSIX requires that
  174.    #undef basename will still let you invoke the underlying function.  However,
  175.    this also implies that the POSIX version is used in this case.  That's made
  176.    sure here. */
  177. #if __GNU_VISIBLE && !defined(basename)
  178. # define basename basename
  179. char    *_EXFUN(__nonnull (1) basename,(const char *)) __asm__(__ASMNAME("__gnu_basename"));
  180. #endif
  181.  
  182. #include <sys/string.h>
  183.  
  184. _END_STD_C
  185.  
  186. #endif /* _STRING_H_ */
  187.