home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Professional Developers Kit 1992 November / Disc01 / Disc01.mdf / cppbeta / incla / stdlib.h__ / STDLIB.H
Encoding:
C/C++ Source or Header  |  1992-09-30  |  11.1 KB  |  292 lines

  1. #ifndef __stdlib_h
  2.    #define __stdlib_h
  3.  
  4.    #pragma info( none )
  5.    #ifndef __CHKHDR__
  6.       #pragma info( none )
  7.    #endif
  8.    #pragma info( restore )
  9.  
  10.    #ifdef __cplusplus
  11.       extern "C" {
  12.    #endif
  13.  
  14.    /********************************************************************/
  15.    /*  <stdlib.h> header file                                          */
  16.    /*                                                                  */
  17.    /*  Licensed Materials - Property of IBM                            */
  18.    /*                                                                  */
  19.    /*  IBM C Set/2 Beta Version                                        */
  20.    /*  Copyright (C) International Business Machines Corp., 1991,1992  */
  21.    /*  All rights reserved                                             */
  22.    /*                                                                  */
  23.    /*  US Government Users Restricted Rights -                         */
  24.    /*  Use, duplication, or disclosure restricted                      */
  25.    /*  by GSA ADP Schedule Contract with IBM Corp.                     */
  26.    /*                                                                  */
  27.    /********************************************************************/
  28.  
  29.    #ifndef __size_t
  30.      #define __size_t
  31.      typedef unsigned int size_t;
  32.    #endif
  33.  
  34.    #ifndef __wchar_t
  35.      #define __wchar_t
  36.      typedef unsigned short wchar_t;
  37.    #endif
  38.  
  39.    typedef struct _div_t
  40.        {
  41.        int quot;        /* quotient of integer division       */
  42.        int rem;         /* remainder of integer division      */
  43.        } div_t;
  44.  
  45.    typedef struct _ldiv_t
  46.        {
  47.        long int quot;   /* quotient of long integer division  */
  48.        long int rem;    /* remainder of long integer division */
  49.        } ldiv_t;
  50.  
  51.    #ifndef NULL
  52.       #if (defined(__EXTENDED__)  || defined( __cplusplus ))
  53.          #define NULL 0
  54.       #else
  55.          #define NULL ((void *)0)
  56.       #endif
  57.    #endif
  58.  
  59.    #define EXIT_SUCCESS      0
  60.    #define EXIT_FAILURE      8
  61.    #define RAND_MAX      32767
  62.    #define MB_CUR_MAX        2
  63.  
  64.    /* function prototypes */
  65.  
  66.    int      _Builtin __abs( int );
  67.    long int _Builtin __labs( long int );
  68.  
  69.    double   _Optlink atof( const char * );
  70.    int      _Optlink atoi( const char * );
  71.    long int _Optlink atol( const char * );
  72.    double   _Optlink strtod( const char *, char ** );
  73.    long int _Optlink strtol( const char *, char **, int );
  74.    unsigned long int _Optlink strtoul( const char *, char **, int );
  75.    int      _Optlink rand( void );
  76.    void     _Optlink srand( unsigned int );
  77.    void *   (_Optlink calloc)( size_t, size_t );
  78.    void     (_Optlink free)( void * );
  79.    void *   (_Optlink malloc)( size_t );
  80.    void *   (_Optlink realloc)( void *, size_t );
  81.    void     _Optlink abort( void );
  82.    int      _Optlink atexit( void ( * )( void ) );
  83.    void     _Optlink exit( int );
  84.    char *   _Optlink getenv( const char * );
  85.    int      _Optlink system( const char * );
  86.    void *   _Optlink bsearch( const void *, const void *, size_t, size_t,
  87.                               int ( * _Optlink __compare )( const void *, const void * ) );
  88.    void     _Optlink qsort( void *, size_t, size_t,
  89.                             int ( * _Optlink __compare )( const void *, const void * ) );
  90.    int      _Optlink abs( int );
  91.    div_t    _Optlink div( int, int );
  92.    long int _Optlink labs( long int );
  93.    ldiv_t   _Optlink ldiv( long int, long int );
  94.    int      _Optlink mblen( const char *, size_t );
  95.    int      _Optlink mbtowc( wchar_t *, const char *, size_t );
  96.    int      _Optlink wctomb( char *, wchar_t );
  97.    size_t   _Optlink mbstowcs( wchar_t *, const char *, size_t );
  98.    size_t   _Optlink wcstombs( char *, const wchar_t *, size_t );
  99.  
  100.    #ifndef __cplusplus
  101.       #pragma info( none )
  102.       #define  abs( x )  __abs( (x) )
  103.       #define  labs( x ) __labs( (x) )
  104.       #pragma info( restore )
  105.    #endif
  106.  
  107.    #ifndef __ANSI__
  108.  
  109.    #ifndef __SAA_L2__
  110.  
  111.       #define max(a,b) (((a) > (b)) ? (a) : (b))
  112.       #define min(a,b) (((a) < (b)) ? (a) : (b))
  113.  
  114.       #ifndef _alloca
  115.          void * _Builtin __alloca( size_t );
  116.          #pragma info( none )
  117.          #define _alloca( x ) __alloca( (x) )
  118.          #define alloca( x ) __alloca( (x) )
  119.          #pragma info( restore )
  120.       #endif
  121.  
  122.       unsigned char _Builtin __parmdwords( void );
  123.  
  124.       double _Optlink _atofieee( const char * );
  125.       long double _Optlink _atold( const char * );
  126.       char * _Optlink _ecvt( double, int, int *, int * );
  127.       char * _Optlink _fcvt( double, int, int *, int * );
  128.       int    _Optlink _freemod( unsigned long );
  129.       char * _Optlink _fullpath(char *, char *, size_t);
  130.       char * _Optlink _gcvt( double, int, char * );
  131.       int    (_Optlink _heapmin)( void );
  132.       char * _Optlink _itoa( int, char *, int );
  133.       int    _Optlink _loadmod( char *, unsigned long * );
  134.       char * _Optlink _ltoa( long, char *, int );
  135.       int    _Optlink _putenv( const char * );
  136.       double _Optlink _strtodieee( const char *, char ** );
  137.       long double _Optlink strtold( const char *, char ** );
  138.       char * _Optlink _ultoa( unsigned long, char *, int );
  139.    #if ( defined(__DEBUG_ALLOC__) && !defined(__malloc_h) )
  140.       void * _Optlink _debug_calloc( size_t, size_t, const char *, size_t );
  141.       void   _Optlink _debug_free( void *, const char *, size_t );
  142.       void * _Optlink _debug_malloc( size_t, const char *, size_t );
  143.       void * _Optlink _debug_realloc( void *, size_t, const char *, size_t );
  144.       int    _Optlink _debug_heapmin( const char *, size_t );
  145.       void   _Optlink _heap_check( void );
  146.       void   _Optlink _dump_allocated( int );
  147.       #pragma info( none )
  148.       #define calloc( x, y )  _debug_calloc( (x), (y), __FILE__, __LINE__ )
  149.       #define free( x )       _debug_free( (x), __FILE__, __LINE__ )
  150.       #define malloc( x )     _debug_malloc( (x), __FILE__, __LINE__ )
  151.       #define realloc( x, y ) _debug_realloc( (x), (y), __FILE__, __LINE__ )
  152.       #define _heapmin( )     _debug_heapmin( __FILE__, __LINE__ )
  153.       #pragma info( restore )
  154.    #endif
  155.  
  156.       #ifdef __MULTI__
  157.          int  _Optlink _beginthread( void ( * _Optlink __thread )( void * ), void *, unsigned, void * );
  158.          void _Optlink _endthread( void );
  159.       #endif
  160.  
  161.       #pragma info( none )
  162.       #define atof( p )         _atofieee( (p) )
  163.       #define strtod( p1, p2 )  _strtodieee( (p1), (p2) )
  164.       #pragma info( restore )
  165.  
  166.  
  167.       #if defined(__EXTENDED__)
  168.  
  169.          void  _Builtin __enable( void );
  170.          void  _Builtin __disable( void );
  171.  
  172.          #define _enable( )  __enable( )
  173.          #define _disable( ) __disable( )
  174.  
  175.          #ifndef errno
  176.             #ifdef __MULTI__
  177.                int * _Optlink _errno( void );
  178.                #pragma info( none )
  179.                #define errno (*_errno( ))
  180.                #pragma info( restore )
  181.             #else
  182.                extern int errno;
  183.                #pragma info( none )
  184.                #define errno errno
  185.                #pragma info( restore )
  186.             #endif
  187.          #endif
  188.  
  189.          #ifndef _doserrno
  190.             #ifdef __MULTI__
  191.                int * _Optlink __doserrno(void);
  192.                #pragma info( none )
  193.                #define _doserrno (*__doserrno( ))
  194.                #pragma info( restore )
  195.             #else
  196.                extern int _doserrno;
  197.                #pragma info( none )
  198.                #define _doserrno _doserrno
  199.                #pragma info( restore )
  200.             #endif
  201.          #endif
  202.  
  203.          extern char **_environ;
  204.          extern unsigned char _osmajor;
  205.          extern unsigned char _osminor;
  206.          extern unsigned char _osmode;
  207.  
  208.          #define DOS_MODE        0       /* Real Address Mode */
  209.          #define OS2_MODE        1       /* Protected Address Mode */
  210.  
  211.          typedef int ( __onexit_t )( void );
  212.          typedef __onexit_t * onexit_t;
  213.  
  214.          /* Sizes for buffers used by the _makepath() and _splitpath() functions.*/
  215.          /* Note that the sizes include space for null terminating character.    */
  216.  
  217.          #define _MAX_PATH       260   /* max. length of full pathname           */
  218.          #define _MAX_DRIVE      3     /* max. length of drive component         */
  219.          #define _MAX_DIR        256   /* max. length of path component          */
  220.          #define _MAX_FNAME      256   /* max. length of file name component     */
  221.          #define _MAX_EXT        256   /* max. length of extension component     */
  222.  
  223.          void          _Optlink _exit( int );
  224.          onexit_t      _Optlink _onexit( onexit_t );
  225.          unsigned int  _Optlink _rotl (unsigned int, int);
  226.          unsigned int  _Optlink _rotr (unsigned int, int);
  227.          unsigned long _Optlink _lrotl(unsigned long, int);
  228.          unsigned long _Optlink _lrotr(unsigned long, int);
  229.          void          _Optlink _makepath( char *, char *, char *, char *, char * );
  230.          void          _Optlink _splitpath( char *, char *, char *, char *, char * );
  231.          void          _Optlink _searchenv( char *, char *, char *);
  232.          void          _Optlink _swab( char *, char *, int );
  233.  
  234.  
  235.          #define  swab(a,b,c)  _swab( (a) , (b) , (c) )
  236.          #define  onexit(a)    _onexit(a)
  237.  
  238.          #define _strtold( p1, p2 )   strtold( (p1), (p2) )
  239.  
  240.          /* Define different memory model versions of memory management       */
  241.          /* routines to the standard names.                                   */
  242.  
  243.          #define _ncalloc( x, y )  calloc( (x), (y) )
  244.          #define _fcalloc( x, y )  calloc( (x), (y) )
  245.          #define _nfree( x )       free( (x) )
  246.          #define _ffree( x )       free( (x) )
  247.          #define _nmalloc( x )     malloc( (x) )
  248.          #define _fmalloc( x )     malloc( (x) )
  249.          #define _nrealloc( x, y ) realloc( (x), (y) )
  250.          #define _frealloc( x, y ) realloc( (x), (y) )
  251.          #define _fheapmin( )      _heapmin( )
  252.          #define _nheapmin( )      _heapmin( )
  253.  
  254.          #ifdef __TILED__
  255.             void * _Optlink _tcalloc( size_t, size_t );
  256.             void   _Optlink _tfree( void * );
  257.             void * _Optlink _tmalloc( size_t );
  258.             void * _Optlink _trealloc( void *, size_t );
  259.             #pragma info( none )
  260.             #define calloc( x, y )  _tcalloc( (x), (y) )
  261.             #define free( x )       _tfree( (x) )
  262.             #define malloc( x )     _tmalloc( (x) )
  263.             #define realloc( x, y ) _trealloc( (x), (y) )
  264.             #pragma info( restore )
  265.          #endif
  266.  
  267.          #define ecvt( x, y, z, w ) _ecvt( (x), (y), (z), (w))
  268.          #define fcvt( x, y, z, w ) _fcvt( (x), (y), (z), (w))
  269.          #define gcvt( x, y, z )    _gcvt( (x), (y), (z))
  270.          #define itoa( x, y, z )    _itoa( (x), (y), (z))
  271.          #define ltoa( x, y, z )    _ltoa( (x), (y), (z))
  272.          #define ultoa( x, y, z )   _ultoa( (x), (y), (z))
  273.          #define putenv( s )        _putenv( (s))
  274.          #define environ            _environ
  275.  
  276.       #endif
  277.  
  278.    #endif
  279.    #endif
  280.  
  281.    #ifdef __cplusplus
  282.       }
  283.    #endif
  284.  
  285.    #pragma info( none )
  286.    #ifndef __CHKHDR__
  287.       #pragma info( restore )
  288.    #endif
  289.    #pragma info( restore )
  290.  
  291. #endif
  292.