home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / cset21v1.zip / IBMCPP / INCLUDE / STDLIB.H < prev    next >
Text File  |  1993-09-17  |  12KB  |  305 lines

  1. #pragma info( none )
  2. #ifndef __CHKHDR__
  3.    #pragma info( none )
  4. #endif
  5. #pragma info( restore )
  6.  
  7. #ifndef __stdlib_h
  8.    #define __stdlib_h
  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/C++ Tools Version 2.01                                    */
  20.    /*  Copyright (C) International Business Machines Corp., 1991,1993  */
  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.    #ifdef __cplusplus
  101.       inline int abs ( int x ) { return __abs ( x ); }
  102.       inline int labs( int x ) { return __labs( x ); }
  103.    #else
  104.       #pragma info( none )
  105.       #define  abs( x )  __abs ( (x) )
  106.       #define  labs( x )  __labs( (x) )
  107.       #pragma info( restore )
  108.    #endif
  109.  
  110.    #ifndef __ANSI__
  111.  
  112.    #ifndef __SAA_L2__
  113.  
  114.       #define max(a,b) (((a) > (b)) ? (a) : (b))
  115.       #define min(a,b) (((a) < (b)) ? (a) : (b))
  116.  
  117.       #ifndef _alloca
  118.          void * _Builtin __alloca( size_t );
  119.          #pragma info( none )
  120.          #define _alloca( x ) __alloca( (x) )
  121.          #define alloca( x ) __alloca( (x) )
  122.          #pragma info( restore )
  123.       #endif
  124.  
  125.       unsigned char _Builtin __parmdwords( void );
  126.  
  127.       long double _Optlink _atold( const char * );
  128.       char * _Optlink  ecvt( double, int, int *, int * );
  129.       char * _Optlink _ecvt( double, int, int *, int * );
  130.       char * _Optlink  fcvt( double, int, int *, int * );
  131.       char * _Optlink _fcvt( double, int, int *, int * );
  132.       int    _Optlink _freemod( unsigned long );
  133.       char * _Optlink _fullpath(char *, char *, size_t);
  134.       char * _Optlink  gcvt( double, int, char * );
  135.       char * _Optlink _gcvt( double, int, char * );
  136.       int    (_Optlink _heapmin)( void );
  137.       char * _Optlink  itoa( int, char *, int );
  138.       char * _Optlink _itoa( int, char *, int );
  139.       int    _Optlink _loadmod( char *, unsigned long * );
  140.       char * _Optlink  ltoa( long, char *, int );
  141.       char * _Optlink _ltoa( long, char *, int );
  142.       size_t _Optlink _msize(void *);
  143.       int    _Optlink  putenv( const char * );
  144.       int    _Optlink _putenv( const char * );
  145.       long double _Optlink  strtold( const char *, char ** );
  146.       long double _Optlink _strtold( const char *, char ** );
  147.       char * _Optlink  ultoa( unsigned long, char *, int );
  148.       char * _Optlink _ultoa( unsigned long, char *, int );
  149.  
  150.       #pragma map( ecvt    , "_ecvt"    )
  151.       #pragma map( fcvt    , "_fcvt"    )
  152.       #pragma map( gcvt    , "_gcvt"    )
  153.       #pragma map( itoa    , "_itoa"    )
  154.       #pragma map( ltoa    , "_ltoa"    )
  155.       #pragma map( ultoa   , "_ultoa"   )
  156.       #pragma map( putenv  , "_putenv"  )
  157.       #pragma map( _strtold, "strtold"  )
  158.  
  159.       #ifndef __malloc_h
  160.          #if (defined(__DEBUG_ALLOC__) && !defined(__TILED__))
  161.             void * _Optlink _debug_calloc( size_t, size_t, const char *, size_t );
  162.             void   _Optlink _debug_free( void *, const char *, size_t );
  163.             void * _Optlink _debug_malloc( size_t, const char *, size_t );
  164.             void * _Optlink _debug_realloc( void *, size_t, const char *, size_t );
  165.             int    _Optlink _debug_heapmin( const char *, size_t );
  166.             void   _Optlink _heap_check( void );
  167.             void   _Optlink _dump_allocated( int );
  168.             #pragma info( none )
  169.             #define calloc( x, y )  _debug_calloc( (x), (y), __FILE__, __LINE__ )
  170.             #define free( x )       _debug_free( (x), __FILE__, __LINE__ )
  171.             #define malloc( x )     _debug_malloc( (x), __FILE__, __LINE__ )
  172.             #define realloc( x, y ) _debug_realloc( (x), (y), __FILE__, __LINE__ )
  173.             #define _heapmin( )     _debug_heapmin( __FILE__, __LINE__ )
  174.             #pragma info( restore )
  175.          #else
  176.             #define _heap_check( )
  177.             #define _dump_allocated( x )
  178.          #endif
  179.       #endif
  180.  
  181.       #ifdef __MULTI__
  182.          int  _Optlink _beginthread( void ( * _Optlink __thread )( void * ), void *, unsigned, void * );
  183.          void _Optlink _endthread( void );
  184.          void ** _Optlink _threadstore( void );
  185.       #endif
  186.  
  187.       #pragma map( atof  , "_atofieee"   )
  188.       #pragma map( strtod, "_strtodieee" )
  189.  
  190.       #if defined(__EXTENDED__)
  191.  
  192.          void  _Builtin __enable( void );
  193.          void  _Builtin __disable( void );
  194.  
  195.          #define _enable( )  __enable( )
  196.          #define _disable( ) __disable( )
  197.  
  198.          #ifndef errno
  199.             #ifdef __MULTI__
  200.                int * _Optlink _errno( void );
  201.                #pragma info( none )
  202.                #define errno (*_errno( ))
  203.                #pragma info( restore )
  204.             #else
  205.                extern int errno;
  206.                #pragma info( none )
  207.                #define errno errno
  208.                #pragma info( restore )
  209.             #endif
  210.          #endif
  211.  
  212.          #ifndef _doserrno
  213.             #ifdef __MULTI__
  214.                int * _Optlink __doserrno(void);
  215.                #pragma info( none )
  216.                #define _doserrno (*__doserrno( ))
  217.                #pragma info( restore )
  218.             #else
  219.                extern int _doserrno;
  220.                #pragma info( none )
  221.                #define _doserrno _doserrno
  222.                #pragma info( restore )
  223.             #endif
  224.          #endif
  225.  
  226.          extern char **_environ;
  227.          extern unsigned char _osmajor;
  228.          extern unsigned char _osminor;
  229.          extern unsigned char _osmode;
  230.  
  231.          #define environ _environ
  232.  
  233.          #define DOS_MODE        0       /* Real Address Mode */
  234.          #define OS2_MODE        1       /* Protected Address Mode */
  235.  
  236.          typedef int ( __onexit_t )( void );
  237.          typedef __onexit_t * onexit_t;
  238.  
  239.          /* Sizes for buffers used by the _makepath() and _splitpath() functions.*/
  240.          /* Note that the sizes include space for null terminating character.    */
  241.  
  242.          #define _MAX_PATH       260   /* max. length of full pathname           */
  243.          #define _MAX_DRIVE      3     /* max. length of drive component         */
  244.          #define _MAX_DIR        256   /* max. length of path component          */
  245.          #define _MAX_FNAME      256   /* max. length of file name component     */
  246.          #define _MAX_EXT        256   /* max. length of extension component     */
  247.  
  248.          void          _Optlink _exit( int );
  249.          onexit_t      _Optlink  onexit( onexit_t );
  250.          onexit_t      _Optlink _onexit( onexit_t );
  251.          unsigned int  _Optlink _rotl (unsigned int, int);
  252.          unsigned int  _Optlink _rotr (unsigned int, int);
  253.          unsigned long _Optlink _lrotl(unsigned long, int);
  254.          unsigned long _Optlink _lrotr(unsigned long, int);
  255.          void          _Optlink _makepath( char *, char *, char *, char *, char * );
  256.          void          _Optlink _splitpath( char *, char *, char *, char *, char * );
  257.          void          _Optlink _searchenv( char *, char *, char *);
  258.          void          _Optlink  swab( char *, char *, int );
  259.          void          _Optlink _swab( char *, char *, int );
  260.  
  261.          #pragma map( onexit , "_onexit"  )
  262.          #pragma map( swab   , "_swab"    )
  263.  
  264.          /* Define different memory model versions of memory management       */
  265.          /* routines to the standard names.                                   */
  266.  
  267.          #define _ncalloc( x, y )  calloc( (x), (y) )
  268.          #define _fcalloc( x, y )  calloc( (x), (y) )
  269.          #define _nfree( x )       free( (x) )
  270.          #define _ffree( x )       free( (x) )
  271.          #define _nmalloc( x )     malloc( (x) )
  272.          #define _fmalloc( x )     malloc( (x) )
  273.          #define _nrealloc( x, y ) realloc( (x), (y) )
  274.          #define _frealloc( x, y ) realloc( (x), (y) )
  275.          #define _fheapmin( )      _heapmin( )
  276.          #define _nheapmin( )      _heapmin( )
  277.  
  278.          #if (!defined(__malloc_h) && defined(__TILED__))
  279.             void * _Optlink _tcalloc( size_t, size_t );
  280.             void   _Optlink _tfree( void * );
  281.             void * _Optlink _tmalloc( size_t );
  282.             void * _Optlink _trealloc( void *, size_t );
  283.             #pragma map( calloc , "_tcalloc"  )
  284.             #pragma map( free   , "_tfree"    )
  285.             #pragma map( malloc , "_tmalloc"  )
  286.             #pragma map( realloc, "_trealloc" )
  287.          #endif
  288.  
  289.       #endif
  290.  
  291.    #endif
  292.    #endif
  293.  
  294.    #ifdef __cplusplus
  295.       }
  296.    #endif
  297.  
  298. #endif
  299.  
  300. #pragma info( none )
  301. #ifndef __CHKHDR__
  302.    #pragma info( restore )
  303. #endif
  304. #pragma info( restore )
  305.