?login_element?

Subversion Repositories NedoOS

Rev

Blame | Last modification | View Log | Download

  1. /*-------------------------------------------------------------------------
  2.    string.h - ISO header for string library functions
  3.  
  4.    Copyright (C) 1998, Sandeep Dutta
  5.    Copyright (C) 2009-2011, Philipp Klaus Krause pkk@spth.de
  6.  
  7.    This library is free software; you can redistribute it and/or modify it
  8.    under the terms of the GNU General Public License as published by the
  9.    Free Software Foundation; either version 2, or (at your option) any
  10.    later version.
  11.  
  12.    This library is distributed in the hope that it will be useful,
  13.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  14.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15.    GNU General Public License for more details.
  16.  
  17.    You should have received a copy of the GNU General Public License
  18.    along with this library; see the file COPYING. If not, write to the
  19.    Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston,
  20.    MA 02110-1301, USA.
  21.  
  22.    As a special exception, if you link this library with other files,
  23.    some of which are compiled with SDCC, to produce an executable,
  24.    this library does not by itself cause the resulting executable to
  25.    be covered by the GNU General Public License. This exception does
  26.    not however invalidate any other reasons why the executable file
  27.    might be covered by the GNU General Public License.
  28. -------------------------------------------------------------------------*/
  29.  
  30. #ifndef __SDCC_STRING_H
  31. #define __SDCC_STRING_H 1
  32.  
  33. #ifndef NULL
  34. # define NULL (void *)0
  35. #endif
  36.  
  37. #ifndef __SIZE_T_DEFINED
  38. # define __SIZE_T_DEFINED
  39.   typedef unsigned int size_t;
  40. #endif
  41.  
  42. /* Bounds-checking interfaces from annex K of the C11 standard. */
  43. #if defined (__STDC_WANT_LIB_EXT1__) && __STDC_WANT_LIB_EXT1__
  44.  
  45. #ifndef __RSIZE_T_DEFINED
  46. #define __RSIZE_T_DEFINED
  47. typedef size_t rsize_t;
  48. #endif
  49.  
  50. #ifndef __ERRNO_T_DEFINED
  51. #define __ERRNO_T_DEFINED
  52. typedef int errno_t;
  53. #endif
  54.  
  55. #endif
  56.  
  57. #if defined(__SDCC_mcs51) || defined(__SDCC_hc08) || defined(__SDCC_ds390) || defined(__SDCC_pic14) || defined(__SDCC_pic16)
  58. #define __SDCC_BROKEN_STRING_FUNCTIONS
  59. #endif
  60.  
  61. /* The function prototypes are ordered as in the ISO C99 standard. */
  62.  
  63. /* Todo: fix the "restrict" stuff for C99 compliance. */
  64.  
  65. /* Copying functions: */
  66. extern void *memcpy (void * /*restrict */ dest, const void * /*restrict*/ src, size_t n);
  67. #if defined(__SDCC_z80) || defined(__SDCC_z180) || defined(__SDCC_r2k) || defined(__SDCC_r3ka)
  68. extern void *memmove (void *dest, const void *src, size_t n) __preserves_regs(iyl, iyh);
  69. #else
  70. extern void *memmove (void *dest, const void *src, size_t n);
  71. #endif
  72. #if defined(__SDCC_z80) || defined(__SDCC_z180) || defined(__SDCC_r2k) || defined(__SDCC_r3ka) || defined(__SDCC_tlcs90) || defined (__SDCC_ez80_z80)
  73. extern char *strcpy (char * /*restrict*/ dest, const char * /*restrict*/ src) __preserves_regs(iyl, iyh);
  74. #else
  75. extern char *strcpy (char * /*restrict*/ dest, const char * /*restrict*/ src);
  76. #endif
  77. extern char *strncpy(char * /*restrict*/ dest, const char * /*restrict*/ src, size_t n);
  78.  
  79. /* Concatenation functions: */
  80. extern char *strcat (char * /*restrict*/ dest, const char * /*restrict*/ src);
  81. extern char *strncat(char * /*restrict*/ dest, const char * /*restrict*/ src, size_t n);
  82.  
  83. /* Comparison functions: */
  84. extern int memcmp (const void *s1, const void *s2, size_t n);
  85. extern int strcmp (const char *s1, const char *s2);
  86. #define strcoll(s1, s2) strcmp(s1, s2)
  87. /*int strcoll(const char *s1, const char *s2) {return strcmp(s1, s2);}*/
  88. extern int strncmp(const char *s1, const char *s2, size_t n);
  89. extern size_t strxfrm(char *dest, const char *src, size_t n);
  90.  
  91. /* Search functions: */
  92. extern void *memchr (const void *s, int c, size_t n);
  93. #ifdef __SDCC_BROKEN_STRING_FUNCTIONS
  94. extern char *strchr (const char *s, char c); /* c should be int according to standard. */
  95. #else
  96. extern char *strchr (const char *s, int c);
  97. #endif
  98. extern size_t strcspn(const char *s, const char *reject);
  99. extern char *strpbrk(const char *s, const char *accept);
  100. #ifdef __SDCC_BROKEN_STRING_FUNCTIONS
  101. extern char *strrchr(const char *s, char c); /* c should be int according to standard. */
  102. #else
  103. extern char *strrchr(const char *s, int c);
  104. #endif
  105. extern size_t strspn (const char *s, const char *accept);
  106. extern char *strstr (const char *haystack, const char *needle);
  107. extern char *strtok (char * /* restrict*/ str, const char * /*restrict*/ delim);
  108.  
  109. /* Miscanelleous functions: */
  110. #ifdef __SDCC_BROKEN_STRING_FUNCTIONS
  111. extern void *memset (void *s, unsigned char c, size_t n); /* c should be int according to standard. */
  112. #else
  113. extern void *memset (void *s, int c, size_t n);
  114. #endif
  115.  
  116. /* extern char *strerror(int errnum); */
  117. #if defined(__SDCC_z80) || defined(__SDCC_z180) || defined(__SDCC_tlcs90) || defined (__SDCC_ez80_z80)
  118. extern size_t strlen (const char *s) __preserves_regs(d, e, iyl, iyh);
  119. #else
  120. extern size_t strlen (const char *s);
  121. #endif
  122.  
  123. #ifdef __SDCC_ds390
  124. extern void __xdata * memcpyx(void __xdata *, void __xdata *, int) __naked;
  125. #endif
  126.  
  127. #if defined(__SDCC_z80) || defined(__SDCC_z180) || defined(__SDCC_r2k) || defined(__SDCC_r3ka) || defined (__SDCC_ez80_z80)
  128. #define memcpy(dst, src, n) __builtin_memcpy(dst, src, n)
  129. #define strcpy(dst, src) __builtin_strcpy(dst, src)
  130. #define strncpy(dst, src, n) __builtin_strncpy(dst, src, n)
  131. #define strchr(s, c) __builtin_strchr(s, c)
  132. #define memset(dst, c, n) __builtin_memset(dst, c, n)
  133. #else
  134. extern void *__memcpy (void * /*restrict */ dest, const void * /*restrict*/ src, size_t n);
  135. #define memcpy(dst, src, n) __memcpy(dst, src, n)
  136. #endif
  137.  
  138. #endif
  139.  
  140.