pspsdk-1.0+beta2
stdlib.h
Go to the documentation of this file.
1 /*
2  * PSP Software Development Kit - http://www.pspdev.org
3  * -----------------------------------------------------------------------
4  * Licensed under the BSD license, see LICENSE in PSPSDK root for details.
5  *
6  * stdlib.h
7  *
8  * Copyright (c) 2002-2004 PS2DEV
9  * Copyright (c) 2005 Marcus R. Brown <mrbrown@ocgnet.org>
10  * Copyright (c) 2005 James Forshaw <tyranid@gmail.com>
11  * Copyright (c) 2005 John Kelley <ps2dev@kelley.ca>
12  *
13  * $Id: stdlib.h 1095 2005-09-27 21:02:16Z jim $
14  */
15 
16 #ifndef __STDLIB_H__
17 #define __STDLIB_H__
18 
19 #include <pspkernel.h>
20 #include <stddef.h>
21 
22 #ifdef __cplusplus
23 extern "C" {
24 #endif
25 
26 
27 /* ensure NULL is defined. */
28 #ifndef NULL
29 #define NULL (void *)0
30 #endif
31 
32 
33 /* exit status constants. */
34 #define EXIT_SUCCESS 0
35 #define EXIT_FAILURE 1
36 
37 
38 /* multibyte maximum character constant. */
39 #define MB_CUR_MAX 1
40 
41 /* ensure div_t is defined. */
42 #ifndef __DIV_T_DEFINED
43 #define __DIV_T_DEFINED
44 typedef struct {
45  int quot;
46  int rem;
47 } div_t;
48 #endif // __DIV_T_DEFINED
49 
50 
51 /* ensure ldiv_t is defined. */
52 #ifndef __LDIV_T_DEFINED
53 #define __LDIV_T_DEFINED
54 typedef struct {
55  long quot;
56  long rem;
57 } ldiv_t;
58 #endif // __LDIV_T_DEFINED
59 
60 
61 #ifndef __STRICT_ANSI__
62 #ifndef __LLDIV_T_DEFINED
63 #define __LLDIV_T_DEFINED
64 typedef struct {
65  long long quot;
66  long long rem;
67 } lldiv_t;
68 #endif // __LLDIV_T_DEFINED
69 #endif // __STRICT_ANSI__
70 
71 /* we don't check for any previously defined value. This HAS to be that. */
72 #define RAND_MAX 2147483647
73 
74 
75 /* function declarations. */
76 void abort(void) __attribute__ ((noreturn));
77 int abs(int);
78 int atexit(void (*)(void));
79 double atof(const char *);
80 void exit(int);
81 //int atoi(const char *);
82 //long atol(const char *);
83 //#define atoi(x) strtol(x, NULL, 10)
84 //#define atol atoi
85 void *bsearch(const void *, const void *, size_t, size_t, int (*)(const void *, const void *));
86 div_t div(int, int);
87 char *getenv(const char *);
88 long labs(long);
89 ldiv_t ldiv(long, long);
90 #ifndef __STRICT_ANSI__
91 long long llabs(long long);
92 lldiv_t lldiv(long long, long long);
93 #endif
94 int rand(void);
95 int setenv(const char *, const char *, int);
96 void srand(unsigned int);
97 double strtod(const char *, char **);
98 long strtol(const char *, char **, int);
99 unsigned long strtoul(const char *, char **, int);
100 static __inline__ int atoi(const char * x) { return strtol(x, NULL, 10); }
101 static __inline__ long atol(const char * x) { return strtol(x, NULL, 10); }
102 
103 
104 void qsort(void *base, size_t nmemb, size_t size, int (*compar)(const void *, const void *));
105 
106 
107 /* Multibyte disabled, but prototyped for C++... */
108 int mblen(const char *, size_t);
109 size_t mbstowcs(wchar_t *, const char *, size_t);
110 int mbtowc(wchar_t *, const char *, size_t);
111 size_t wcstombs(char *, const wchar_t *, size_t);
112 int wctomb(char *, wchar_t);
113 
114 //char *_gcvt(double, size_t, char *);
115 char *_itoa(int, char *, int);
116 char *_ltoa(long, char *, int);
117 #ifndef __STRICT_ANSI__
118 char *_lltoa(long long, char *, int);
119 #endif
120 
121 // blah! C++ is evil.
122 int system (const char * string);
123 
124 #ifdef __cplusplus
125 }
126 
127 /* C++ is evil, let's defeat it... */
128 #define _CPP_CSTDLIB 1
129 
130 #endif
131 
132 
133 #endif // __STDLIB_H__