stdlib.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  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. #if !defined(_WCHAR_T_DEFINED_) && !defined(__cplusplus)
  42. #define _WCHAR_T_DEFINED_
  43. #ifndef __WCHAR_TYPE__
  44. #define __WCHAR_TYPE__ int
  45. #endif
  46. typedef __WCHAR_TYPE__ wchar_t;
  47. #endif
  48. #ifndef _DIV_T_DEFINED
  49. typedef struct {
  50. int quot; /* quotient */
  51. int rem; /* remainder */
  52. } div_t;
  53. typedef struct {
  54. long quot; /* quotient */
  55. long rem; /* remainder */
  56. } ldiv_t;
  57. typedef struct {
  58. long long quot; /* quotient */
  59. long long rem; /* remainder */
  60. } lldiv_t;
  61. #define _DIV_T_DEFINED
  62. #endif
  63. #ifndef NULL
  64. #ifdef __cplusplus
  65. #define NULL 0
  66. #else
  67. #define NULL ((void *)0)
  68. #endif
  69. #endif
  70. #define EXIT_FAILURE 1
  71. #define EXIT_SUCCESS 0
  72. #define RAND_MAX 0x7fffffff
  73. #define MB_CUR_MAX 1
  74. __BEGIN_DECLS
  75. _TLIBC_NORETURN_ void _TLIBC_CDECL_ abort(void);
  76. int _TLIBC_CDECL_ atexit(void (*)(void));
  77. int _TLIBC_CDECL_ abs(int);
  78. double _TLIBC_CDECL_ atof(const char *);
  79. int _TLIBC_CDECL_ atoi(const char *);
  80. long _TLIBC_CDECL_ atol(const char *);
  81. void * _TLIBC_CDECL_ bsearch(const void *, const void *, size_t, size_t, int (*)(const void *, const void *));
  82. void * _TLIBC_CDECL_ calloc(size_t, size_t);
  83. div_t _TLIBC_CDECL_ div(int, int);
  84. void _TLIBC_CDECL_ free(void *);
  85. long _TLIBC_CDECL_ labs(long);
  86. ldiv_t _TLIBC_CDECL_ ldiv(long, long);
  87. void * _TLIBC_CDECL_ malloc(size_t);
  88. void * _TLIBC_CDECL_ memalign(size_t, size_t);
  89. void _TLIBC_CDECL_ qsort(void *, size_t, size_t, int (*)(const void *, const void *));
  90. void * _TLIBC_CDECL_ realloc(void *, size_t);
  91. double _TLIBC_CDECL_ strtod(const char *, char **);
  92. long _TLIBC_CDECL_ strtol(const char *, char **, int);
  93. float _TLIBC_CDECL_ strtof(const char *, char **);
  94. long long
  95. _TLIBC_CDECL_ atoll(const char *);
  96. long long
  97. _TLIBC_CDECL_ llabs(long long);
  98. lldiv_t
  99. _TLIBC_CDECL_ lldiv(long long, long long);
  100. long long
  101. _TLIBC_CDECL_ strtoll(const char *, char **, int);
  102. unsigned long
  103. _TLIBC_CDECL_ strtoul(const char *, char **, int);
  104. long double
  105. _TLIBC_CDECL_ strtold(const char *, char **);
  106. unsigned long long
  107. _TLIBC_CDECL_ strtoull(const char *, char **, int);
  108. int _TLIBC_CDECL_ mblen(const char *, size_t);
  109. size_t _TLIBC_CDECL_ mbstowcs(wchar_t *, const char *, size_t);
  110. int _TLIBC_CDECL_ wctomb(char *, wchar_t);
  111. int _TLIBC_CDECL_ mbtowc(wchar_t *, const char *, size_t);
  112. size_t _TLIBC_CDECL_ wcstombs(char *, const wchar_t *, size_t);
  113. /*
  114. * Deprecated C99.
  115. */
  116. _TLIBC_DEPRECATED_FUNCTION_(int _TLIBC_CDECL_, atexit, void (_TLIBC_CDECL_ *)(void));
  117. _TLIBC_DEPRECATED_FUNCTION_(int _TLIBC_CDECL_, rand, void);
  118. _TLIBC_DEPRECATED_FUNCTION_(void _TLIBC_CDECL_, srand, unsigned);
  119. _TLIBC_DEPRECATED_FUNCTION_(void _TLIBC_CDECL_, exit, int);
  120. _TLIBC_DEPRECATED_FUNCTION_(void _TLIBC_CDECL_, _Exit, int);
  121. _TLIBC_DEPRECATED_FUNCTION_(char * _TLIBC_CDECL_, getenv, const char *);
  122. _TLIBC_DEPRECATED_FUNCTION_(int _TLIBC_CDECL_, system, const char *);
  123. /*
  124. * Non-C99 Functions.
  125. */
  126. void * _TLIBC_CDECL_ alloca(size_t);
  127. /*
  128. * Deprecated Non-C99.
  129. */
  130. //_TLIBC_DEPRECATED_FUNCTION_(void _TLIBC_CDECL_, _exit, int);
  131. __END_DECLS
  132. #endif /* !_STDLIB_H_ */