?login_element?

Subversion Repositories NedoOS

Rev

Blame | Last modification | View Log | Download | RSS feed

  1. /*-------------------------------------------------------------------------
  2.    stdlib.h - General utilities (ISO C 11 7.22)
  3.  
  4.    Copyright (C) 1998, Sandeep Dutta . sandeep.dutta@usa.net
  5.    Copyright (c) 2016, 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_STDLIB_H
  31. #define __SDCC_STDLIB_H 1
  32.  
  33. #if !defined(__SDCC_mcs51) && !defined(__SDCC_ds390) && !defined(__SDCC_ds400) && !defined(__SDCC_hc08) && !defined(__SDCC_s08) && !defined(__SDCC_pic14) && !defined(__SDCC_pic16) && !defined(__SDCC_pdk13) && !defined(__SDCC_pdk14) && !defined(__SDCC_pdk15)
  34. #define __reentrant
  35. #endif
  36.  
  37. #ifndef __SIZE_T_DEFINED
  38. #define __SIZE_T_DEFINED
  39.   typedef unsigned int size_t;
  40. #endif
  41.  
  42. #ifndef __WCHAR_T_DEFINED
  43. #define __WCHAR_T_DEFINED
  44.   typedef unsigned long int wchar_t;
  45. #endif
  46.  
  47. #ifndef NULL
  48. #define NULL (void *)0
  49. #endif
  50.  
  51. #define RAND_MAX 32767
  52.  
  53. #define MB_CUR_MAX 4
  54.  
  55. /* Numeric conversion functions (ISO C11 7.22.1) */
  56. extern float atof (const char *nptr);
  57. extern int atoi (const char *nptr);
  58. extern long int atol (const char *nptr);
  59. #ifdef __SDCC_LONGLONG
  60. extern long long int atoll (const char *nptr);
  61. #endif
  62. extern long int strtol(const char *nptr, char **endptr, int base);
  63. extern unsigned long int strtoul(const char *nptr, char **endptr, int base);
  64.  
  65. /* SDCC extensions */
  66. extern void _uitoa(unsigned int, char*, unsigned char);
  67. extern void _itoa(int, char*, unsigned char);
  68. extern void _ultoa(unsigned long, char*, unsigned char);
  69. extern void _ltoa(long, char*, unsigned char);
  70.  
  71. /* Pseudo-random sequence generation functions (ISO C11 7.22.2) */
  72. int rand(void);
  73. void srand(unsigned int seed);
  74.  
  75. /* Memory management functions (ISO C11 7.22.3) */
  76. #if defined(__SDCC_mcs51) || defined(__SDCC_ds390) || defined(__SDCC_ds400)
  77. void __xdata *calloc (size_t nmemb, size_t size);
  78. void __xdata *malloc (size_t size);
  79. void __xdata *realloc (void *ptr, size_t size);
  80. #else
  81. void *calloc (size_t nmemb, size_t size);
  82. void *malloc (size_t size);
  83. void *realloc (void *ptr, size_t size);
  84. #endif
  85. #if __STDC_VERSION__ >= 201112L
  86. inline void *aligned_alloc(size_t alignment, size_t size)
  87. {
  88.   (void)alignment;
  89.   return malloc(size);
  90. }
  91. #endif
  92. extern void free (void * ptr);
  93.  
  94. /* Searching and sorting utilities (ISO C11 7.22.5) */
  95. extern void *bsearch(const void *key, const void *base, size_t nmemb, size_t size, int (*compar)(const void *, const void *) __reentrant);
  96. extern void qsort(void *base, size_t nmemb, size_t size, int (*compar)(const void *, const void *) __reentrant);
  97.  
  98. /* Integer arithmetic functions (ISO C11 7.22.6) */
  99. #if defined(__SDCC_z80) || defined(__SDCC_z180) || defined(__SDCC_r2k) || defined(__SDCC_r3ka) || defined(__SDCC_tlcs90) || defined (__SDCC_ez80_z80)
  100. int abs(int j) __preserves_regs(b, c, iyl, iyh);
  101. #else
  102. int abs(int j);
  103. #endif
  104. long int labs(long int j);
  105.  
  106. /* C99 Multibyte/wide character conversion functions (ISO C11 7.22.7) */
  107. #if __STDC_VERSION__ >= 199901L
  108. int mblen(const char *s, size_t n);
  109. int mbtowc(wchar_t *restrict pwc, const char *restrict s, size_t n);
  110. int wctomb(char *s, wchar_t wc);
  111. #endif
  112.  
  113. /* C99 Multibyte/wide string conversion functions (ISO C 11 7.22.8) */
  114. #if __STDC_VERSION__ >= 199901L
  115. size_t mbstowcs(wchar_t *restrict pwcs, const char *restrict s, size_t n);
  116. size_t wcstombs(char *restrict s, const wchar_t *restrict pwcs, size_t n);
  117. #endif
  118.  
  119. /* Bounds-checking interfaces from annex K of the C11 standard. */
  120. #if defined (__STDC_WANT_LIB_EXT1__) && __STDC_WANT_LIB_EXT1__
  121.  
  122. #ifndef __RSIZE_T_DEFINED
  123. #define __RSIZE_T_DEFINED
  124. typedef size_t rsize_t;
  125. #endif
  126.  
  127. #ifndef __ERRNO_T_DEFINED
  128. #define __ERRNO_T_DEFINED
  129. typedef int errno_t;
  130. #endif
  131.  
  132. typedef void (*constraint_handler_t)(const char *restrict msg, void *restrict ptr, errno_t error);
  133.  
  134. #endif
  135.  
  136. #endif
  137.  
  138.