stdlib.h 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. /* $OpenBSD: stdlib.h,v 1.47 2010/05/18 22:24:55 tedu Exp $ */
  2. /* $NetBSD: stdlib.h,v 1.25 1995/12/27 21:19:08 jtc Exp $ */
  3. /*-
  4. * Copyright (c) 1990 The Regents of the University of California.
  5. * All rights reserved.
  6. *
  7. * Redistribution and use in source and binary forms, with or without
  8. * modification, are permitted provided that the following conditions
  9. * are met:
  10. * 1. Redistributions of source code must retain the above copyright
  11. * notice, this list of conditions and the following disclaimer.
  12. * 2. Redistributions in binary form must reproduce the above copyright
  13. * notice, this list of conditions and the following disclaimer in the
  14. * documentation and/or other materials provided with the distribution.
  15. * 3. Neither the name of the University nor the names of its contributors
  16. * may be used to endorse or promote products derived from this software
  17. * without specific prior written permission.
  18. *
  19. * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  20. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  21. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  22. * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  23. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  24. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  25. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  26. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  27. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  28. * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  29. * SUCH DAMAGE.
  30. *
  31. * @(#)stdlib.h 5.13 (Berkeley) 6/4/91
  32. */
  33. #ifndef _STDLIB_H_
  34. #define _STDLIB_H_
  35. #include <sys/cdefs.h>
  36. #include <sys/_types.h>
  37. #ifndef _SIZE_T_DEFINED_
  38. #define _SIZE_T_DEFINED_
  39. typedef __size_t size_t;
  40. #endif
  41. #ifdef _TLIBC_WIN_
  42. #if !defined(_WCHAR_T_DEFINED) && !defined (_NATIVE_WCHAR_T_DEFINED)
  43. #define _WCHAR_T_DEFINED
  44. typedef unsigned short wchar_t;
  45. #endif
  46. #else
  47. #if !defined(_WCHAR_T_DEFINED_) && !defined(__cplusplus)
  48. #define _WCHAR_T_DEFINED_
  49. #ifndef __WCHAR_TYPE__
  50. #define __WCHAR_TYPE__ int
  51. #endif
  52. typedef __WCHAR_TYPE__ wchar_t;
  53. #endif
  54. #endif
  55. #ifndef _DIV_T_DEFINED
  56. typedef struct {
  57. int quot; /* quotient */
  58. int rem; /* remainder */
  59. } div_t;
  60. typedef struct {
  61. long quot; /* quotient */
  62. long rem; /* remainder */
  63. } ldiv_t;
  64. typedef struct {
  65. long long quot; /* quotient */
  66. long long rem; /* remainder */
  67. } lldiv_t;
  68. #define _DIV_T_DEFINED
  69. #endif
  70. #ifndef NULL
  71. #ifdef __cplusplus
  72. #define NULL 0
  73. #else
  74. #define NULL ((void *)0)
  75. #endif
  76. #endif
  77. #define EXIT_FAILURE 1
  78. #define EXIT_SUCCESS 0
  79. #define RAND_MAX 0x7fffffff
  80. #define MB_CUR_MAX 1
  81. __BEGIN_DECLS
  82. _TLIBC_NORETURN_ void _TLIBC_CDECL_ abort(void);
  83. int _TLIBC_CDECL_ atexit(void (*)(void));
  84. int _TLIBC_CDECL_ abs(int);
  85. double _TLIBC_CDECL_ atof(const char *);
  86. int _TLIBC_CDECL_ atoi(const char *);
  87. long _TLIBC_CDECL_ atol(const char *);
  88. void * _TLIBC_CDECL_ bsearch(const void *, const void *, size_t, size_t, int (*)(const void *, const void *));
  89. void * _TLIBC_CDECL_ calloc(size_t, size_t);
  90. div_t _TLIBC_CDECL_ div(int, int);
  91. void _TLIBC_CDECL_ free(void *);
  92. long _TLIBC_CDECL_ labs(long);
  93. ldiv_t _TLIBC_CDECL_ ldiv(long, long);
  94. void * _TLIBC_CDECL_ malloc(size_t);
  95. void * _TLIBC_CDECL_ memalign(size_t, size_t);
  96. void _TLIBC_CDECL_ qsort(void *, size_t, size_t, int (*)(const void *, const void *));
  97. void * _TLIBC_CDECL_ realloc(void *, size_t);
  98. double _TLIBC_CDECL_ strtod(const char *, char **);
  99. long _TLIBC_CDECL_ strtol(const char *, char **, int);
  100. float _TLIBC_CDECL_ strtof(const char *, char **);
  101. long long
  102. _TLIBC_CDECL_ atoll(const char *);
  103. long long
  104. _TLIBC_CDECL_ llabs(long long);
  105. lldiv_t
  106. _TLIBC_CDECL_ lldiv(long long, long long);
  107. long long
  108. _TLIBC_CDECL_ strtoll(const char *, char **, int);
  109. unsigned long
  110. _TLIBC_CDECL_ strtoul(const char *, char **, int);
  111. long double
  112. _TLIBC_CDECL_ strtold(const char *, char **);
  113. unsigned long long
  114. _TLIBC_CDECL_ strtoull(const char *, char **, int);
  115. int _TLIBC_CDECL_ mblen(const char *, size_t);
  116. size_t _TLIBC_CDECL_ mbstowcs(wchar_t *, const char *, size_t);
  117. int _TLIBC_CDECL_ wctomb(char *, wchar_t);
  118. int _TLIBC_CDECL_ mbtowc(wchar_t *, const char *, size_t);
  119. size_t _TLIBC_CDECL_ wcstombs(char *, const wchar_t *, size_t);
  120. /*
  121. * Deprecated C99.
  122. */
  123. _TLIBC_DEPRECATED_FUNCTION_(int _TLIBC_CDECL_, atexit, void (_TLIBC_CDECL_ *)(void));
  124. _TLIBC_DEPRECATED_FUNCTION_(int _TLIBC_CDECL_, rand, void);
  125. _TLIBC_DEPRECATED_FUNCTION_(void _TLIBC_CDECL_, srand, unsigned);
  126. _TLIBC_DEPRECATED_FUNCTION_(void _TLIBC_CDECL_, exit, int);
  127. _TLIBC_DEPRECATED_FUNCTION_(void _TLIBC_CDECL_, _Exit, int);
  128. _TLIBC_DEPRECATED_FUNCTION_(char * _TLIBC_CDECL_, getenv, const char *);
  129. _TLIBC_DEPRECATED_FUNCTION_(int _TLIBC_CDECL_, system, const char *);
  130. /*
  131. * Non-C99 Functions.
  132. */
  133. void * _TLIBC_CDECL_ alloca(size_t);
  134. /*
  135. * Deprecated Non-C99.
  136. */
  137. //_TLIBC_DEPRECATED_FUNCTION_(void _TLIBC_CDECL_, _exit, int);
  138. __END_DECLS
  139. #endif /* !_STDLIB_H_ */