string.h 5.2 KB

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