PSP2SDK  dirty-f9e4f2d
The free SDK for PSP2
include/stdlib.h
00001 /*
00002  * Copyright (C) 2015 PSP2SDK Project
00003  *
00004  * This Source Code Form is subject to the terms of the Mozilla Public
00005  * License, v. 2.0. If a copy of the MPL was not distributed with this
00006  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
00007  *
00008  * Modified for PSP2 by PSP2SDK Team
00009  *
00010  * stdlib.h
00011  *
00012  * Definitions for common types, variables, and functions.
00013  */
00014 
00015 #ifndef _STDLIB_H_
00016 #define _STDLIB_H_
00017 
00018 #include <machine/ieeefp.h>
00019 #include "_ansi.h"
00020 
00021 #define __need_size_t
00022 #define __need_wchar_t
00023 #define __need_NULL
00024 #include <stddef.h>
00025 
00026 #include <sys/cdefs.h>
00027 #include <machine/stdlib.h>
00028 #ifndef __STRICT_ANSI__
00029 #include <alloca.h>
00030 #endif
00031 
00032 #ifdef __CYGWIN__
00033 #include <cygwin/stdlib.h>
00034 #endif
00035 
00036 _BEGIN_STD_C
00037 
00038 typedef struct 
00039 {
00040   int quot; /* quotient */
00041   int rem; /* remainder */
00042 } div_t;
00043 
00044 typedef struct 
00045 {
00046   long quot; /* quotient */
00047   long rem; /* remainder */
00048 } ldiv_t;
00049 
00050 #if !defined(__STRICT_ANSI__) || \
00051   (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || \
00052   (defined(__cplusplus) && __cplusplus >= 201103L)
00053 typedef struct
00054 {
00055   long long int quot; /* quotient */
00056   long long int rem; /* remainder */
00057 } lldiv_t;
00058 #endif
00059 
00060 #ifndef __compar_fn_t_defined
00061 #define __compar_fn_t_defined
00062 typedef int (*__compar_fn_t) (const _PTR, const _PTR);
00063 #endif
00064 
00065 #define EXIT_FAILURE 1
00066 #define EXIT_SUCCESS 0
00067 
00068 #define RAND_MAX __RAND_MAX
00069 
00070 int _EXFUN(__locale_mb_cur_max,(_VOID));
00071 
00072 #define MB_CUR_MAX __locale_mb_cur_max()
00073 
00074 _VOID   _EXFUN(abort,(_VOID) _ATTRIBUTE ((__noreturn__)));
00075 int _EXFUN(abs,(int));
00076 int _EXFUN(__aeabi_atexit,(_VOID (*__func)(_VOID)));
00077 
00078 #define atexit(__func) __aeabi_atexit(__func)
00079 
00080 double  _EXFUN(atof,(const char *__nptr));
00081 #ifndef __STRICT_ANSI__
00082 float   _EXFUN(atoff,(const char *__nptr));
00083 #endif
00084 int _EXFUN(atoi,(const char *__nptr));
00085 long    _EXFUN(atol,(const char *__nptr));
00086 _PTR    _EXFUN(bsearch,(const _PTR __key,
00087                const _PTR __base,
00088                size_t __nmemb,
00089                size_t __size,
00090                __compar_fn_t _compar));
00091 _PTR    _EXFUN_NOTHROW(calloc,(size_t __nmemb, size_t __size));
00092 div_t   _EXFUN(div,(int __numer, int __denom));
00093 _VOID   _EXFUN(exit,(int __status) _ATTRIBUTE ((__noreturn__)));
00094 _VOID   _EXFUN_NOTHROW(free,(_PTR));
00095 char *  _EXFUN(getenv,(const char *__string));
00096 char *  _EXFUN(_findenv,(_CONST char *, int *));
00097 #ifndef __STRICT_ANSI__
00098 extern char *suboptarg;         /* getsubopt(3) external variable */
00099 int _EXFUN(getsubopt,(char **, char * const *, char **));
00100 #endif
00101 long    _EXFUN(labs,(long));
00102 ldiv_t  _EXFUN(ldiv,(long __numer, long __denom));
00103 _PTR    _EXFUN_NOTHROW(malloc,(size_t __size));
00104 int _EXFUN(mblen,(const char *, size_t));
00105 int _EXFUN(mbtowc,(wchar_t *__restrict, const char *__restrict, size_t));
00106 int _EXFUN(wctomb,(char *, wchar_t));
00107 size_t  _EXFUN(mbstowcs,(wchar_t *__restrict, const char *__restrict, size_t));
00108 size_t  _EXFUN(wcstombs,(char *__restrict, const wchar_t *__restrict, size_t));
00109 #ifndef __STRICT_ANSI__
00110 #ifndef _REENT_ONLY
00111 char *  _EXFUN(mkdtemp,(char *));
00112 int _EXFUN(mkostemp,(char *, int));
00113 int _EXFUN(mkostemps,(char *, int, int));
00114 int _EXFUN(mkstemp,(char *));
00115 int _EXFUN(mkstemps,(char *, int));
00116 char *  _EXFUN(mktemp,(char *) _ATTRIBUTE ((__warning__ ("the use of `mktemp' is dangerous; use `mkstemp' instead"))));
00117 #endif
00118 #endif
00119 _VOID   _EXFUN(qsort,(_PTR __base, size_t __nmemb, size_t __size, __compar_fn_t _compar));
00120 int _EXFUN(rand,(_VOID));
00121 _PTR    _EXFUN_NOTHROW(realloc,(_PTR __r, size_t __size));
00122 #ifndef __STRICT_ANSI__
00123 _PTR    _EXFUN(reallocf,(_PTR __r, size_t __size));
00124 char *  _EXFUN(realpath, (const char *__restrict path, char *__restrict resolved_path));
00125 #endif
00126 _VOID   _EXFUN(srand,(unsigned __seed));
00127 double  _EXFUN(strtod,(const char *__restrict __n, char **__restrict __end_PTR));
00128 #if !defined(__STRICT_ANSI__) || \
00129   (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || \
00130   (defined(__cplusplus) && __cplusplus >= 201103L)
00131 float   _EXFUN(strtof,(const char *__restrict __n, char **__restrict __end_PTR));
00132 #endif
00133 #ifndef __STRICT_ANSI__
00134 /* the following strtodf interface is deprecated...use strtof instead */
00135 # ifndef strtodf 
00136 #  define strtodf strtof
00137 # endif
00138 #endif
00139 long    _EXFUN(strtol,(const char *__restrict __n, char **__restrict __end_PTR, int __base));
00140 unsigned long _EXFUN(strtoul,(const char *__restrict __n, char **__restrict __end_PTR, int __base));
00141 
00142 int _EXFUN(system,(const char *__string));
00143 
00144 #ifndef __STRICT_ANSI__
00145 long    _EXFUN(a64l,(const char *__input));
00146 char *  _EXFUN(l64a,(long __input));
00147 int _EXFUN(on_exit,(_VOID (*__func)(int, _PTR),_PTR __arg));
00148 #endif /* ! __STRICT_ANSI__ */
00149 #if !defined(__STRICT_ANSI__) || \
00150   (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || \
00151   (defined(__cplusplus) && __cplusplus >= 201103L)
00152 _VOID   _EXFUN(_Exit,(int __status) _ATTRIBUTE ((__noreturn__)));
00153 #endif
00154 #ifndef __STRICT_ANSI__
00155 int _EXFUN(putenv,(char *__string));
00156 int _EXFUN(setenv,(const char *__string, const char *__value, int __overwrite));
00157 
00158 char *  _EXFUN(gcvt,(double,int,char *));
00159 char *  _EXFUN(gcvtf,(float,int,char *));
00160 char *  _EXFUN(fcvt,(double,int,int *,int *));
00161 char *  _EXFUN(fcvtf,(float,int,int *,int *));
00162 char *  _EXFUN(ecvt,(double,int,int *,int *));
00163 char *  _EXFUN(ecvtbuf,(double, int, int*, int*, char *));
00164 char *  _EXFUN(fcvtbuf,(double, int, int*, int*, char *));
00165 char *  _EXFUN(ecvtf,(float,int,int *,int *));
00166 char *  _EXFUN(dtoa,(double, int, int, int *, int*, char**));
00167 #endif
00168 char *  _EXFUN(__itoa,(int, char *, int));
00169 char *  _EXFUN(__utoa,(unsigned, char *, int));
00170 #ifndef __STRICT_ANSI__
00171 char *  _EXFUN(itoa,(int, char *, int));
00172 char *  _EXFUN(utoa,(unsigned, char *, int));
00173 int _EXFUN(rand_r,(unsigned *__seed));
00174 
00175 double _EXFUN(drand48,(_VOID));
00176 double _EXFUN(erand48,(unsigned short [3]));
00177 long   _EXFUN(jrand48,(unsigned short [3]));
00178 _VOID  _EXFUN(lcong48,(unsigned short [7]));
00179 long   _EXFUN(lrand48,(_VOID));
00180 long   _EXFUN(mrand48,(_VOID));
00181 long   _EXFUN(nrand48,(unsigned short [3]));
00182 unsigned short *
00183        _EXFUN(seed48,(unsigned short [3]));
00184 _VOID  _EXFUN(srand48,(long));
00185 #endif /* ! __STRICT_ANSI__ */
00186 #if !defined(__STRICT_ANSI__) || \
00187   (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || \
00188   (defined(__cplusplus) && __cplusplus >= 201103L)
00189 long long _EXFUN(atoll,(const char *__nptr));
00190 #endif
00191 #if !defined(__STRICT_ANSI__) || \
00192   (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || \
00193   (defined(__cplusplus) && __cplusplus >= 201103L)
00194 long long _EXFUN(llabs,(long long));
00195 lldiv_t _EXFUN(lldiv,(long long __numer, long long __denom));
00196 long long _EXFUN(strtoll,(const char *__restrict __n, char **__restrict __end_PTR, int __base));
00197 #endif
00198 #if !defined(__STRICT_ANSI__) || \
00199   (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || \
00200   (defined(__cplusplus) && __cplusplus >= 201103L)
00201 unsigned long long _EXFUN(strtoull,(const char *__restrict __n, char **__restrict __end_PTR, int __base));
00202 #endif
00203 #ifndef __STRICT_ANSI__
00204 
00205 #ifndef __CYGWIN__
00206 _VOID   _EXFUN(cfree,(_PTR));
00207 int _EXFUN(unsetenv,(const char *__string));
00208 #endif
00209 
00210 #ifdef __rtems__
00211 int _EXFUN(posix_memalign,(void **, size_t, size_t));
00212 #endif
00213 
00214 #endif /* ! __STRICT_ANSI__ */
00215 
00216 _VOID   _EXFUN(__eprintf,(const char *, const char *, unsigned int, const char *));
00217 
00218 /* There are two common qsort_r variants.  If you request
00219    _BSD_SOURCE, you get the BSD version; otherwise you get the GNU
00220    version.  We want that #undef qsort_r will still let you
00221    invoke the underlying function, but that requires gcc support. */
00222 #ifdef _BSD_SOURCE
00223 # ifdef __GNUC__
00224 _VOID   _EXFUN(qsort_r,(_PTR __base, size_t __nmemb, size_t __size, _PTR __thunk, int (*_compar)(_PTR, const _PTR, const _PTR)))
00225              __asm__ (__ASMNAME ("__bsd_qsort_r"));
00226 # else
00227 _VOID   _EXFUN(__bsd_qsort_r,(_PTR __base, size_t __nmemb, size_t __size, _PTR __thunk, int (*_compar)(_PTR, const _PTR, const _PTR)));
00228 #  define qsort_r __bsd_qsort_r
00229 # endif
00230 #elif __GNU_VISIBLE
00231 _VOID   _EXFUN(qsort_r,(_PTR __base, size_t __nmemb, size_t __size, int (*_compar)(const _PTR, const _PTR, _PTR), _PTR __thunk));
00232 #endif
00233 
00234 /* On platforms where long double equals double.  */
00235 #ifdef _HAVE_LONG_DOUBLE
00236 #if !defined(__STRICT_ANSI__) || \
00237   (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || \
00238   (defined(__cplusplus) && __cplusplus >= 201103L)
00239 extern long double strtold (const char *__restrict, char **__restrict);
00240 #endif
00241 #endif /* _HAVE_LONG_DOUBLE */
00242 
00243 _END_STD_C
00244 
00245 #endif /* _STDLIB_H_ */
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines