source: trunk/include/incl_vac/STDLIB.H@ 10367

Last change on this file since 10367 was 9707, checked in by sandervl, 23 years ago

Added changed VAC headers to rename memory and file functions; add include\incl_vac to include path (/I)

File size: 20.1 KB
Line 
1#if (defined(__IBMC__) || defined(__IBMCPP__))
2#pragma info( none )
3#ifndef __CHKHDR__
4 #pragma info( none )
5#endif
6#pragma info( restore )
7#endif
8
9#ifndef __stdlib_h
10 #define __stdlib_h
11
12 #ifdef __cplusplus
13 extern "C" {
14 #endif
15
16 #ifndef _LNK_CONV
17 #ifdef _M_I386
18 #define _LNK_CONV _Optlink
19 #else
20 #define _LNK_CONV
21 #endif
22 #endif
23
24 #ifndef _IMPORT
25 #ifdef __IMPORTLIB__
26 #define _IMPORT _Import
27 #else
28 #define _IMPORT
29 #endif
30 #endif
31
32 /********************************************************************/
33 /* <stdlib.h> header file */
34 /* */
35 /* IBM VisualAge C++ for OS/2, Version 3.00 */
36 /* (C) Copyright IBM Corp. 1991, 1995. */
37 /* - Licensed Material - Program-Property of IBM */
38 /* - All rights reserved */
39 /* */
40 /********************************************************************/
41
42 #ifndef __size_t
43 #define __size_t
44 typedef unsigned int size_t;
45 #endif
46
47 #ifndef __wchar_t
48 #define __wchar_t
49 typedef unsigned short wchar_t;
50 #endif
51
52 typedef struct _div_t
53 {
54 int quot; /* quotient of integer division */
55 int rem; /* remainder of integer division */
56 } div_t;
57
58 typedef struct _ldiv_t
59 {
60 long int quot; /* quotient of long integer division */
61 long int rem; /* remainder of long integer division */
62 } ldiv_t;
63
64 #ifndef NULL
65 #if (defined(__EXTENDED__) || defined( __cplusplus ))
66 #define NULL 0
67 #else
68 #define NULL ((void *)0)
69 #endif
70 #endif
71
72 #define EXIT_SUCCESS 0
73 #define EXIT_FAILURE 8
74 #define RAND_MAX 32767
75
76 #ifdef __BSEXCPT__
77 typedef unsigned long _System
78 _EH_RTN(PEXCEPTIONREPORTRECORD, struct _EXCEPTIONREGISTRATIONRECORD *,
79 PCONTEXTRECORD, PVOID);
80 #elif defined(_INC_EXCPT)
81 typedef unsigned long __stdcall
82 _EH_RTN(struct _EXCEPTION_RECORD*, PVOID, struct _CONTEXT*, PVOID);
83 #else
84 #ifdef __OS2__
85 typedef unsigned long _System _EH_RTN(void *,void *,void *,void *);
86 #else
87 typedef unsigned long __stdcall _EH_RTN(void *,void *,void *,void *);
88 #endif
89 #endif
90
91 extern int _IMPORT _LNK_CONV _eh_del(_EH_RTN *);
92 extern int _IMPORT _LNK_CONV _eh_add(_EH_RTN *);
93 extern int _IMPORT _mb_cur_max;
94 #define MB_CUR_MAX _mb_cur_max
95
96 /* function prototypes */
97
98 #ifdef _M_I386
99 int _Builtin __abs( int );
100 long int _Builtin __labs( long int );
101 #endif
102
103 #ifndef CRTWRAP
104 #define CRTWRAP(a) odin_##a
105 #endif
106#ifndef ORIGINAL_VAC_FUNCTIONS
107 #undef calloc
108 #undef free
109 #undef malloc
110 #undef realloc
111 #undef _heapmin
112 #undef _msize
113 #define calloc CRTWRAP(calloc)
114 #define free CRTWRAP(free)
115 #define malloc CRTWRAP(malloc)
116 #define realloc CRTWRAP(realloc)
117 #define _heapmin CRTWRAP(_heapmin)
118 #define _msize CRTWRAP(_msize)
119#endif
120
121 double _IMPORT _LNK_CONV atof( const char * );
122 int _IMPORT _LNK_CONV atoi( const char * );
123 long int _IMPORT _LNK_CONV atol( const char * );
124 double _IMPORT _LNK_CONV strtod( const char *, char ** );
125 long int _IMPORT _LNK_CONV strtol( const char *, char **, int );
126 unsigned long int _IMPORT _LNK_CONV strtoul( const char *, char **, int );
127 int _IMPORT _LNK_CONV rand( void );
128 void _IMPORT _LNK_CONV srand( unsigned int );
129 void * (_IMPORT _LNK_CONV calloc)( size_t, size_t );
130 void (_IMPORT _LNK_CONV free)( void * );
131 void * (_IMPORT _LNK_CONV malloc)( size_t );
132 void * (_IMPORT _LNK_CONV realloc)( void *, size_t );
133 void _IMPORT _LNK_CONV abort( void );
134 int _IMPORT _LNK_CONV atexit( void ( * )( void ) );
135 void _IMPORT _LNK_CONV exit( int );
136 char * _IMPORT _LNK_CONV getenv( const char * );
137 int _IMPORT _LNK_CONV system( const char * );
138 void * _IMPORT _LNK_CONV bsearch( const void *, const void *, size_t, size_t,
139 int ( * _LNK_CONV __compare )( const void *, const void * ) );
140 void _IMPORT _LNK_CONV qsort( void *, size_t, size_t,
141 int ( * _LNK_CONV __compare )( const void *, const void * ) );
142 div_t _IMPORT _LNK_CONV div( int, int );
143 ldiv_t _IMPORT _LNK_CONV ldiv( long int, long int );
144 int _IMPORT _LNK_CONV mblen( const char *, size_t );
145 int _IMPORT _LNK_CONV mbtowc( wchar_t *, const char *, size_t );
146 int _IMPORT _LNK_CONV wctomb( char *, wchar_t );
147 size_t _IMPORT _LNK_CONV mbstowcs( wchar_t *, const char *, size_t );
148 size_t _IMPORT _LNK_CONV wcstombs( char *, const wchar_t *, size_t );
149
150 #ifdef _M_I386
151 #ifdef __cplusplus
152 inline int _LNK_CONV abs ( int x ) { return __abs ( x ); }
153 inline long int _LNK_CONV labs( long int l ) { return __labs( l ); }
154 #else
155 int _IMPORT _LNK_CONV abs ( int );
156 long int _IMPORT _LNK_CONV labs( long int );
157
158 #pragma info( none )
159 #define abs( x ) __abs ( (x) )
160 #define labs( x ) __labs( (x) )
161 #pragma info( restore )
162 #endif
163 #endif
164
165 #ifndef __ANSI__
166
167 #ifndef __SAA_L2__
168
169 #ifndef max
170 #define max(a,b) (((a) > (b)) ? (a) : (b))
171 #endif
172 #ifndef min
173 #define min(a,b) (((a) < (b)) ? (a) : (b))
174 #endif
175
176 #ifdef _M_I386
177 #ifndef _alloca
178 void * _Builtin __alloca( size_t );
179 #pragma info( none )
180 #define _alloca( x ) __alloca( (x) )
181 #define alloca( x ) __alloca( (x) )
182 #pragma info( restore )
183 #endif
184
185 unsigned char _Builtin __parmdwords( void );
186 #endif
187
188 long double _IMPORT _LNK_CONV _atold( const char * );
189 char * _IMPORT _LNK_CONV ecvt( double, int, int *, int * );
190 char * _IMPORT _LNK_CONV _ecvt( double, int, int *, int * );
191 char * _IMPORT _LNK_CONV fcvt( double, int, int *, int * );
192 char * _IMPORT _LNK_CONV _fcvt( double, int, int *, int * );
193 int _IMPORT _LNK_CONV _freemod( unsigned long );
194 char * _IMPORT _LNK_CONV _fullpath(char *, char *, size_t);
195 char * _IMPORT _LNK_CONV gcvt( double, int, char * );
196 char * _IMPORT _LNK_CONV _gcvt( double, int, char * );
197 int (_IMPORT _LNK_CONV _heapmin)( void );
198 char * _IMPORT _LNK_CONV itoa( int, char *, int );
199 char * _IMPORT _LNK_CONV _itoa( int, char *, int );
200 int _IMPORT _LNK_CONV _loadmod( char *, unsigned long * );
201 char * _IMPORT _LNK_CONV ltoa( long, char *, int );
202 char * _IMPORT _LNK_CONV _ltoa( long, char *, int );
203 size_t _IMPORT _LNK_CONV _msize(void *);
204 int _IMPORT _LNK_CONV putenv( const char * );
205 int _IMPORT _LNK_CONV _putenv( const char * );
206 long double _IMPORT _LNK_CONV strtold( const char *, char ** );
207 long double _IMPORT _LNK_CONV _strtold( const char *, char ** );
208 char * _IMPORT _LNK_CONV ultoa( unsigned long, char *, int );
209 char * _IMPORT _LNK_CONV _ultoa( unsigned long, char *, int );
210
211 #if (defined(__IBMC__) || defined(__IBMCPP__))
212 #pragma map( ecvt , "_ecvt" )
213 #pragma map( fcvt , "_fcvt" )
214 #pragma map( gcvt , "_gcvt" )
215 #pragma map( itoa , "_itoa" )
216 #pragma map( ltoa , "_ltoa" )
217 #pragma map( ultoa , "_ultoa" )
218 #pragma map( putenv , "_putenv" )
219 #pragma map( _strtold, "strtold" )
220 #else
221 #pragma Alias( ecvt , "_ecvt" )
222 #pragma Alias( fcvt , "_fcvt" )
223 #pragma Alias( gcvt , "_gcvt" )
224 #pragma Alias( itoa , "_itoa" )
225 #pragma Alias( ltoa , "_ltoa" )
226 #pragma Alias( ultoa , "_ultoa" )
227 #pragma Alias( putenv , "_putenv" )
228 #pragma Alias( _strtold, "strtold" )
229 #endif
230
231 #ifndef __malloc_h
232
233 #ifdef __TILED__
234 void * _IMPORT _LNK_CONV _tcalloc( size_t, size_t );
235 void _IMPORT _LNK_CONV _tfree( void * );
236 void * _IMPORT _LNK_CONV _tmalloc( size_t );
237 void * _IMPORT _LNK_CONV _trealloc( void *, size_t );
238 void * _IMPORT _LNK_CONV _theapmin(void);
239 #ifndef __DEBUG_ALLOC__
240 #pragma map( calloc , "_tcalloc" )
241 #pragma map( free , "_tfree" )
242 #pragma map( malloc , "_tmalloc" )
243 #pragma map( realloc, "_trealloc" )
244 #pragma map( heapmin, "_theapmin" )
245 #endif
246 #endif
247
248 #ifdef __DEBUG_ALLOC__
249 #ifdef __TILED__
250 void * _IMPORT _LNK_CONV _debug_tcalloc( size_t, size_t, const char *, size_t );
251 void _IMPORT _LNK_CONV _debug_tfree( void *, const char *, size_t );
252 void * _IMPORT _LNK_CONV _debug_tmalloc( size_t, const char *, size_t );
253 void * _IMPORT _LNK_CONV _debug_trealloc( void *, size_t, const char *, size_t );
254 int _IMPORT _LNK_CONV _debug_theapmin( const char *, size_t );
255 void _IMPORT _LNK_CONV _theap_check( void );
256 void _IMPORT _LNK_CONV _tdump_allocated( int );
257 void _IMPORT _LNK_CONV _tdump_allocated_delta( int );
258
259 void _IMPORT _LNK_CONV __theap_check( const char *,size_t );
260 void _IMPORT _LNK_CONV __tdump_allocated( int ,const char *, size_t);
261 void _IMPORT _LNK_CONV __tdump_allocated_delta( int, const char *, size_t);
262
263 #pragma info( none )
264 #define _tcalloc(x,y) _debug_tcalloc( (x), (y), __FILE__, __LINE__ )
265 #define _tfree( x ) _debug_tfree( (x), __FILE__, __LINE__ )
266 #define _tmalloc( x ) _debug_tmalloc( (x), __FILE__, __LINE__ )
267 #define _trealloc(x,y) _debug_trealloc( (x), (y), __FILE__, __LINE__ )
268 #define _theapmin( ) _debug_theapmin( __FILE__, __LINE__ )
269
270 #define calloc(x,y) _debug_tcalloc( (x), (y), __FILE__, __LINE__ )
271 #define free( x ) _debug_tfree( (x), __FILE__, __LINE__ )
272 #define malloc( x ) _debug_tmalloc( (x), __FILE__, __LINE__ )
273 #define realloc(x,y) _debug_trealloc( (x), (y), __FILE__, __LINE__ )
274 #define _heapmin( ) _debug_theapmin( __FILE__, __LINE__ )
275
276 #define _heap_check() __theap_check(__FILE__,__LINE__)
277 #define _dump_allocated(x) __tdump_allocated((x),__FILE__,__LINE__)
278 #define _dump_allocated_delta(x) __tdump_allocated_delta((x),__FILE__,__LINE__)
279
280 #pragma info( restore )
281 #else
282
283#ifndef ORIGINAL_VAC_FUNCTIONS
284 #define _debug_calloc CRTWRAP(_debug_calloc)
285 #define _debug_free CRTWRAP(_debug_free)
286 #define _debug_malloc CRTWRAP(_debug_malloc)
287 #define _debug_realloc CRTWRAP(_debug_realloc)
288 #define _heap_check CRTWRAP(_heap_check)
289 #define _dump_allocated CRTWRAP(_dump_allocated)
290 #define _dump_allocated_delta CRTWRAP(_dump_allocated_delta)
291 #define _debug_heapmin CRTWRAP(_debug_heapmin)
292 #define __heap_check CRTWRAP(__heap_check)
293 #define __dump_allocated CRTWRAP(__dump_allocated)
294 #define __dump_allocated_delta CRTWRAP(__dump_allocated_delta)
295#endif
296 void * _IMPORT _LNK_CONV _debug_calloc( size_t, size_t, const char *, size_t );
297 void _IMPORT _LNK_CONV _debug_free( void *, const char *, size_t );
298 void * _IMPORT _LNK_CONV _debug_malloc( size_t, const char *, size_t );
299 void * _IMPORT _LNK_CONV _debug_realloc( void *, size_t, const char *, size_t );
300 int _IMPORT _LNK_CONV _debug_heapmin( const char *, size_t );
301 void _IMPORT _LNK_CONV _heap_check( void );
302 void _IMPORT _LNK_CONV _dump_allocated( int );
303 void _IMPORT _LNK_CONV _dump_allocated_delta( int );
304 void _IMPORT _LNK_CONV __heap_check( const char *,size_t );
305 void _IMPORT _LNK_CONV __dump_allocated( int ,const char *, size_t);
306 void _IMPORT _LNK_CONV __dump_allocated_delta( int, const char *, size_t );
307
308 #if (defined(__IBMC__) || defined(__IBMCPP__))
309 #pragma info( none )
310 #endif
311#ifndef ORIGINAL_VAC_FUNCTIONS
312 #undef calloc
313 #undef free
314 #undef malloc
315 #undef realloc
316 #undef _heapmin
317 #undef _heap_check
318 #undef _dump_allocated
319 #undef _dump_allocated_delta
320#endif
321 #define calloc( x, y ) _debug_calloc( (x), (y), __FILE__, __LINE__ )
322 #define free( x ) _debug_free( (x), __FILE__, __LINE__ )
323 #define malloc( x ) _debug_malloc( (x), __FILE__, __LINE__ )
324 #define realloc( x, y ) _debug_realloc( (x), (y), __FILE__, __LINE__ )
325 #define _heapmin( ) _debug_heapmin( __FILE__, __LINE__ )
326
327 #define _heap_check() __heap_check(__FILE__,__LINE__)
328 #define _dump_allocated(x) __dump_allocated((x),__FILE__,__LINE__)
329 #define _dump_allocated_delta(x) __dump_allocated_delta((x),__FILE__,__LINE__)
330
331 #if (defined(__IBMC__) || defined(__IBMCPP__))
332 #pragma info( restore )
333 #endif
334 #endif
335 #else
336 #define _heap_check( )
337 #define _dump_allocated( x )
338 #define _theap_check( )
339 #define _tdump_allocated( x )
340 #define _dump_allocated_delta( x )
341 #define _tdump_allocated_delta( x )
342 #endif
343
344 #endif
345
346 #ifdef __MULTI__
347 int _IMPORT _LNK_CONV _beginthread( void ( * _LNK_CONV thread )( void * ), void *, unsigned, void * );
348 void _IMPORT _LNK_CONV _endthread( void );
349 void ** _IMPORT _LNK_CONV _threadstore( void );
350 #endif
351
352 #if (defined(__IBMC__) || defined(__IBMCPP__))
353 #pragma map( atof , "_atofieee" )
354 #pragma map( strtod, "_strtodieee" )
355 #else
356 #pragma Alias( atof , "_atofieee" )
357 #pragma Alias( strtod, "_strtodieee" )
358 #endif
359
360 #if defined(__EXTENDED__)
361
362 #ifdef _M_I386
363 void _Builtin __enable( void );
364 void _Builtin __disable( void );
365
366 #define _enable( ) __enable( )
367 #define _disable( ) __disable( )
368 #endif
369
370 #ifndef errno
371 #ifdef __MULTI__
372 int * _IMPORT _LNK_CONV _errno( void );
373 #if (defined(__IBMC__) || defined(__IBMCPP__))
374 #pragma info( none )
375 #endif
376 #define errno (*_errno( ))
377 #if (defined(__IBMC__) || defined(__IBMCPP__))
378 #pragma info( restore )
379 #endif
380 #else
381 extern int _IMPORT errno;
382 #if (defined(__IBMC__) || defined(__IBMCPP__))
383 #pragma info( none )
384 #endif
385 #define errno errno
386 #if (defined(__IBMC__) || defined(__IBMCPP__))
387 #pragma info( restore )
388 #endif
389 #endif
390 #endif
391
392 #ifndef _doserrno
393 #ifdef __MULTI__
394 int * _IMPORT _LNK_CONV __doserrno(void);
395 #if (defined(__IBMC__) || defined(__IBMCPP__))
396 #pragma info( none )
397 #endif
398 #define _doserrno (*__doserrno( ))
399 #if (defined(__IBMC__) || defined(__IBMCPP__))
400 #pragma info( restore )
401 #endif
402 #else
403 extern int _IMPORT _doserrno;
404 #if (defined(__IBMC__) || defined(__IBMCPP__))
405 #pragma info( none )
406 #endif
407 #define _doserrno _doserrno
408 #if (defined(__IBMC__) || defined(__IBMCPP__))
409 #pragma info( restore )
410 #endif
411 #endif
412 #endif
413
414 extern char ** _IMPORT _environ;
415 extern unsigned char _IMPORT _osmajor;
416 extern unsigned char _IMPORT _osminor;
417 extern unsigned char _IMPORT _osmode;
418
419 #define environ _environ
420
421 #define DOS_MODE 0 /* Real Address Mode */
422 #define OS2_MODE 1 /* Protected Address Mode */
423
424 typedef int ( __onexit_t )( void );
425 typedef __onexit_t * onexit_t;
426
427 /* Sizes for buffers used by the _makepath() and _splitpath() functions.*/
428 /* Note that the sizes include space for null terminating character. */
429
430 #define _MAX_PATH 260 /* max. length of full pathname */
431 #define _MAX_DRIVE 3 /* max. length of drive component */
432 #define _MAX_DIR 256 /* max. length of path component */
433 #define _MAX_FNAME 256 /* max. length of file name component */
434 #define _MAX_EXT 256 /* max. length of extension component */
435
436 void _IMPORT _LNK_CONV _exit( int );
437 onexit_t _IMPORT _LNK_CONV onexit( onexit_t );
438 onexit_t _IMPORT _LNK_CONV _onexit( onexit_t );
439
440 #ifdef _M_I386
441 unsigned long _Builtin __lrotl(unsigned long, int);
442 unsigned long _Builtin __lrotr(unsigned long, int);
443 unsigned short _Builtin __srotl(unsigned short, int);
444 unsigned short _Builtin __srotr(unsigned short, int);
445 unsigned char _Builtin __crotl(unsigned char, int);
446 unsigned char _Builtin __crotr(unsigned char, int);
447 #define _rotl( x, y ) __lrotl( (x), (y) )
448 #define _rotr( x, y ) __lrotr( (x), (y) )
449 #define _lrotl( x, y ) __lrotl( (x), (y) )
450 #define _lrotr( x, y ) __lrotr( (x), (y) )
451 #define _srotl( x, y ) __srotl( (x), (y) )
452 #define _srotr( x, y ) __srotr( (x), (y) )
453 #define _crotl( x, y ) __crotl( (x), (y) )
454 #define _crotr( x, y ) __crotr( (x), (y) )
455 #else
456 unsigned int _rotl (unsigned int, int);
457 unsigned int _rotr (unsigned int, int);
458 unsigned long _lrotl(unsigned long, int);
459 unsigned long _lrotr(unsigned long, int);
460 unsigned short _srotl(unsigned short, int);
461 unsigned short _srotr(unsigned short, int);
462 unsigned char _crotl(unsigned char, int);
463 unsigned char _crotr(unsigned char, int);
464 #endif
465
466 void _IMPORT _LNK_CONV _makepath( char *, char *, char *, char *, char * );
467 void _IMPORT _LNK_CONV _splitpath( char *, char *, char *, char *, char * );
468 void _IMPORT _LNK_CONV _searchenv( char *, char *, char *);
469 void _IMPORT _LNK_CONV swab( char *, char *, int );
470 void _IMPORT _LNK_CONV _swab( char *, char *, int );
471
472 #if (defined(__IBMC__) || defined(__IBMCPP__))
473 #pragma map( onexit , "_onexit" )
474 #pragma map( swab , "_swab" )
475 #else
476 #pragma Alias( onexit , "_onexit" )
477 #pragma Alias( swab , "_swab" )
478 #endif
479
480 int _IMPORT _LNK_CONV rpmatch(const char *);
481 int _IMPORT _LNK_CONV csid(const char *);
482 int _IMPORT _LNK_CONV wcsid(const wchar_t);
483
484 #if (defined(__IBMC__) || defined(__IBMCPP__))
485 #pragma map( rpmatch, "_rpmatch" )
486 #pragma map( csid , "_csid" )
487 #pragma map( wcsid , "_wcsid" )
488 #else
489 #pragma Alias( rpmatch, "_rpmatch" )
490 #pragma Alias( csid , "_csid" )
491 #pragma Alias( wcsid , "_wcsid" )
492 #endif
493
494 /* Define different memory model versions of memory management */
495 /* routines to the standard names. */
496
497 #define _ncalloc( x, y ) calloc( (x), (y) )
498 #define _fcalloc( x, y ) calloc( (x), (y) )
499 #define _nfree( x ) free( (x) )
500 #define _ffree( x ) free( (x) )
501 #define _nmalloc( x ) malloc( (x) )
502 #define _fmalloc( x ) malloc( (x) )
503 #define _nrealloc( x, y ) realloc( (x), (y) )
504 #define _frealloc( x, y ) realloc( (x), (y) )
505 #define _fheapmin( ) _heapmin( )
506 #define _nheapmin( ) _heapmin( )
507
508 #endif
509
510 #endif
511 #endif
512
513 #ifdef __cplusplus
514 }
515 #endif
516
517#endif
518
519#if (defined(__IBMC__) || defined(__IBMCPP__))
520#pragma info( none )
521#ifndef __CHKHDR__
522 #pragma info( restore )
523#endif
524#pragma info( restore )
525#endif
526
Note: See TracBrowser for help on using the repository browser.