summaryrefslogtreecommitdiff
path: root/PACE/pace/stdlib.h
blob: c968d8aba0398e535b12ac11f3aa0aaab518191d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
/* $Id$

 * ============================================================================
 *
 * = LIBRARY
 *    pace
 *
 * = FILENAME
 *    pace/stdlib.h
 *
 * = AUTHOR
 *    Luther Baker
 *
 * ============================================================================ */

#ifndef PACE_STDLIB_H
#define PACE_STDLIB_H

#include "pace/config/defines.h"
#include "pace/unistd.h"

#if (PACE_HAS_POSIX)
# include "pace/posix/stdlib.h"
#elif (PACE_VXWORKS)
# include "pace/vxworks/stdlib.h"
#elif (PACE_WIN32)
# include "pace/win32/stdlib.h"
#endif

#if defined (PACE_HAS_CPLUSPLUS)
extern "C" {
#endif /* PACE_HAS_CPLUSPLUS */

  /**
    C std 7.20.4.1
    */
#if (PACE_HAS_POSIX_SIG_UOF)
  PACE_INLINE void pace_abort (void);
#endif /* PACE_HAS_POSIX_SIG_UOF */

  /**
     PACE's implementation of the POSIX function abs.
     See POSIX standard (Internation Standard ISO/IEC 9945-1:1996;
     IEEE Std 1003.1, 1996 Edition), Section 8.1.
     */
#if (PACE_HAS_POSIX_CLS_UOF)
  PACE_INLINE int pace_abs (int val);
#endif /* PACE_HAS_POSIX_CLS_UOF */

  /**
    C std ref. 7.20.4.2
    */
#if (PACE_HAS_POSIX_NONUOF_FUNCS)
  PACE_INLINE int pace_atexit (void (*func)(void));
#endif /* PACE_HAS_POSIX_NONUOF_FUNCS */

  /**
     PACE's implementation of the POSIX function atof.
     See POSIX standard (Internation Standard ISO/IEC 9945-1:1996;
     IEEE Std 1003.1, 1996 Edition), Section 8.1.
     */
#if (PACE_HAS_POSIX_CLS_UOF)
  PACE_INLINE double pace_atof (const char * str);
#endif /* PACE_HAS_POSIX_CLS_UOF */

  /**
     PACE's implementation of the POSIX function atoi.
     See POSIX standard (Internation Standard ISO/IEC 9945-1:1996;
     IEEE Std 1003.1, 1996 Edition), Section 8.1.
     */
#if (PACE_HAS_POSIX_CLS_UOF)
  PACE_INLINE int pace_atoi (const char * str);
#endif /* PACE_HAS_POSIX_CLS_UOF */

  /**
     PACE's implementation of the POSIX function atol.
     See POSIX standard (Internation Standard ISO/IEC 9945-1:1996;
     IEEE Std 1003.1, 1996 Edition), Section 8.1.
     */
#if (PACE_HAS_POSIX_CLS_UOF)
  PACE_INLINE long pace_atol (const char * str);
#endif /* PACE_HAS_POSIX_CLS_UOF */

  /**
     PACE's implementation of the POSIX function bsearch.
     See POSIX standard (Internation Standard ISO/IEC 9945-1:1996;
     IEEE Std 1003.1, 1996 Edition), Section 8.1.
     */
#if (PACE_HAS_POSIX_CLS_UOF)
  PACE_INLINE void * pace_bsearch (const void *key, const void *base,
                                   size_t nel, size_t size,
                                   int (*compar)(const void *,const void *));
#endif /* PACE_HAS_POSIX_CLS_UOF */

  /**
    C std ref. 7.20.6.2
    */
#if (PACE_HAS_POSIX_NONUOF_FUNCS)
  PACE_INLINE pace_div_t pace_div (int numer, int denom);
#endif /* PACE_HAS_POSIX_NONUOF_FUNCS */

  /**
     PACE's implementation of the POSIX function exit.
     See POSIX standard (Internation Standard ISO/IEC 9945-1:1996;
     IEEE Std 1003.1, 1996 Edition), Section 8.1.
     */
#if (PACE_HAS_POSIX_MP_UOF)
  PACE_INLINE void pace_exit (int status);
#endif /* PACE_HAS_POSIX_MP_UOF */

  /**
     PACE's implementation of the POSIX function getenv.
     See POSIX standard (Internation Standard ISO/IEC 9945-1:1996;
     IEEE Std 1003.1, 1996 Edition), Section 4.6.1.
     */
#if (PACE_HAS_POSIX_MP_UOF)
  PACE_INLINE char * pace_getenv (const char * name);
#endif /* PACE_HAS_POSIX_MP_UOF */

  /**
    C std ref. 7.20.6.1
    */
#if (PACE_HAS_POSIX_NONUOF_FUNCS)
  PACE_INLINE long int pace_labs (long int j);
#endif /* PACE_HAS_POSIX_NONUOF_FUNCS */

  /**
    C std ref. 7.20.6.2
    */
#if (PACE_HAS_POSIX_NONUOF_FUNCS)
  PACE_INLINE pace_ldiv_t pace_ldiv (long int numer, long int denom);
#endif /* PACE_HAS_POSIX_NONUOF_FUNCS */

  /**
    C std ref. 7.20.7.1
    */
#if (PACE_HAS_POSIX_NONUOF_FUNCS)
  PACE_INLINE int pace_mblen (const char* s, pace_size_t n);
#endif /* PACE_HAS_POSIX_NONUOF_FUNCS */

  /**
    C std ref. 7.20.8.1
    */
#if (PACE_HAS_POSIX_NONUOF_FUNCS)
  PACE_INLINE pace_size_t pace_mbstowcs (pace_wchar_t* pwcs,
                                         const char* s,
                                         pace_size_t n);
#endif /* PACE_HAS_POSIX_NONUOF_FUNCS */

  /**
    C std ref. 7.20.7.2
    */
#if (PACE_HAS_POSIX_NONUOF_FUNCS)
  PACE_INLINE int pace_mbtowc (pace_wchar_t* pwc,
                               const char* s,
                               pace_size_t n);
#endif /* PACE_HAS_POSIX_NONUOF_FUNCS */

  /**
     PACE's implementation of the POSIX function qsort.
     See POSIX standard (Internation Standard ISO/IEC 9945-1:1996;
     IEEE Std 1003.1, 1996 Edition), Section 8.1.
     */
#if (PACE_HAS_POSIX_CLS_UOF)
  PACE_INLINE void pace_qsort (void * base, size_t nel, size_t width,
                               int (*compar)(const void *, const void *));
#endif /* PACE_HAS_POSIX_CLS_UOF */

  /**
     PACE's implementation of the POSIX function rand.
     See POSIX standard (Internation Standard ISO/IEC 9945-1:1996;
     IEEE Std 1003.1, 1996 Edition), Section 8.1.
     */
#if (PACE_HAS_POSIX_CLS_UOF)
  PACE_INLINE int pace_rand ();
#endif /* PACE_HAS_POSIX_CLS_UOF */

  /**
     PACE's implementation of the POSIX function srand.
     See POSIX standard (Internation Standard ISO/IEC 9945-1:1996;
     IEEE Std 1003.1, 1996 Edition), Section 8.1.
     */
#if (PACE_HAS_POSIX_CLS_UOF)
  PACE_INLINE void pace_srand (unsigned int seed);
#endif /* PACE_HAS_POSIX_CLS_UOF */

  /**
     PACE's implementation of the POSIX function rand_r.
     See POSIX standard (Internation Standard ISO/IEC 9945-1:1996;
     IEEE Std 1003.1, 1996 Edition), Section 8.3.8.
     */
#if (PACE_HAS_POSIX_CLSR_UOF)
  PACE_INLINE int pace_rand_r (unsigned int * seed);
#endif /* PACE_HAS_POSIX_CLSR_UOF */
  /* Requires PACE_HAS_REENTRANT. */

  /**
    C std ref. 7.20.1.3
    */
#if (PACE_HAS_POSIX_NONUOF_FUNCS)
  PACE_INLINE double pace_strtod (const char* nptr,
                                  char** endptr);
#endif /* PACE_HAS_POSIX_NONUOF_FUNCS */

  /**
    C std ref. 7.20.1.4
    */
#if (PACE_HAS_POSIX_NONUOF_FUNCS)
  PACE_INLINE int pace_strtol (const char* nptr,
                               char** endptr,
                               int base);
#endif /* PACE_HAS_POSIX_NONUOF_FUNCS */

  /**
    C std ref. 7.20.7.2
    */
#if (PACE_HAS_POSIX_NONUOF_FUNCS)
  PACE_INLINE unsigned long int pace_strtoul (const char* nptr,
                                              char** endptr,
                                              int base);
#endif /* PACE_HAS_POSIX_NONUOF_FUNCS */

  /**
    C std ref. 7.20.4.5
    */
#if (PACE_HAS_POSIX_NONUOF_FUNCS)
  PACE_INLINE int pace_system (const char* string);
#endif /* PACE_HAS_POSIX_NONUOF_FUNCS */

  /**
    C std ref. 7.20.8.2
    */
#if (PACE_HAS_POSIX_NONUOF_FUNCS)
  PACE_INLINE pace_size_t pace_wcstombs (char* s,
                                         const pace_wchar_t* pwcs,
                                         pace_size_t n);
#endif /* PACE_HAS_POSIX_NONUOF_FUNCS */

  /**
    C std ref. 7.20.7.3
    */
#if (PACE_HAS_POSIX_NONUOF_FUNCS)
  PACE_INLINE int pace_wctomb (char* s, pace_wchar_t wchar);
#endif /* PACE_HAS_POSIX_NONUOF_FUNCS */


                        /* Memory Management */

  /**
     PACE's implementation of the POSIX function malloc.
     See POSIX standard (Internation Standard ISO/IEC 9945-1:1996;
     IEEE Std 1003.1, 1996 Edition), Section 8.1.
     */
#if (PACE_HAS_POSIX_CLS_UOF)
  PACE_INLINE void * pace_malloc (size_t size);
#endif /* PACE_HAS_POSIX_CLS_UOF */

  /**
     PACE's implementation of the POSIX function calloc.
     See POSIX standard (Internation Standard ISO/IEC 9945-1:1996;
     IEEE Std 1003.1, 1996 Edition), Section 8.1.
     */
#if (PACE_HAS_POSIX_CLS_UOF)
  PACE_INLINE void * pace_calloc (size_t nelem, size_t elsize);
#endif /* PACE_HAS_POSIX_CLS_UOF */

  /**
     PACE's implementation of the POSIX function free.
     See POSIX standard (Internation Standard ISO/IEC 9945-1:1996;
     IEEE Std 1003.1, 1996 Edition), Section 8.1.
     */
#if (PACE_HAS_POSIX_CLS_UOF)
  PACE_INLINE void pace_free (void * ptr);
#endif /* PACE_HAS_POSIX_CLS_UOF */

  /**
     PACE's implementation of the POSIX function realloc.
     See POSIX standard (Internation Standard ISO/IEC 9945-1:1996;
     IEEE Std 1003.1, 1996 Edition), Section 8.1.
     */
#if (PACE_HAS_POSIX_CLS_UOF)
  PACE_INLINE void * pace_realloc (void * ptr, size_t size);
#endif /* PACE_HAS_POSIX_CLS_UOF */

#if defined (PACE_HAS_INLINE)
#  if (PACE_HAS_POSIX)
#    include "pace/posix/stdlib.inl"
#  elif (PACE_VXWORKS)
#    include "pace/vxworks/stdlib.inl"
#  elif (PACE_WIN32)
#    include "pace/win32/stdlib.inl"
#  endif
#endif /* PACE_HAS_INLINE */

#if defined (PACE_HAS_CPLUSPLUS)
}
#endif /* PACE_HAS_CPLUSPLUS */

#endif /* PACE_STDLIB_H */