home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c221 / 5.ddi / MWHC.005 / Q4 < prev    next >
Encoding:
Text File  |  1992-12-09  |  4.0 KB  |  146 lines

  1. /*
  2.  *   (c) Copyright 1991, MetaWare, Inc.
  3.  *
  4.  *   static.h:  support for reentrant libraries.
  5.  *              All static variables in the runtime
  6.  *              library should be defined here.
  7.  */
  8.  
  9. #ifndef _STATIC_H
  10.     #define _STATIC_H
  11. #pragma push_align_members(64);
  12.  
  13.     #ifdef _REENTRANT
  14.  
  15.     /************************************
  16.      *                                  *
  17.      *  definitions of static variables *
  18.      *         reentrant version        *
  19.      *                                  *
  20.      ************************************/
  21.  
  22.     #ifndef _STDIO_H
  23.         #include <stdio.h>
  24.     #endif
  25.  
  26.     #ifndef _LOCALE_H
  27.         #include <locale.h>
  28.     #endif
  29.  
  30.     #ifndef _FLOAT_H
  31.         #include <float.h>
  32.     #endif
  33.  
  34.     #ifndef _TIME_H
  35.         #include <time.h>
  36.     #endif
  37.  
  38.     #ifndef _MATH_H
  39.         #include <math.h>
  40.     #endif
  41.  
  42.     #if _HOBBIT
  43.         #define _BASESIZE 9
  44.     #else
  45.         #error __FILE__:  _BASESIZE not defined
  46.         /*
  47.         #define _BASESIZE 9
  48.         */
  49.     #endif
  50.  
  51.     /* task data */
  52.     typedef struct {
  53.         int errno;
  54.         char _tmpnam_s0[L_tmpnam + 1];
  55.         int _tmpnam_n;
  56.         #if (_IOB_FORMAT == _IOB_LIST)
  57.         FILE _IOB[_MIN_USER_STREAM];
  58.         FILE *_iob_head;
  59.         #else
  60.         FILE _IOB[FOPEN_MAX];
  61.         _iob_fioflag_t _iob_fioflag[FOPEN_MAX];
  62.         _iob_unget_t _iob_unget[FOPEN_MAX];    
  63.         char *_iob_tmpnam[FOPEN_MAX];
  64.         #endif
  65.         int _iob_fopen_max;  /* keep if _IOB_LIST? */
  66.         int _iob_fmode;
  67.         int _iob_pmode;
  68.         char _doecvt_buf[LDBL_DIG + sizeof(long) * 2 + 1];
  69.         char _asctime_buf[32];
  70.         char _ctime_buf[32];
  71.         int _atexit_count;
  72.         unsigned long _malloc_base[_BASESIZE];
  73.         unsigned long *_malloc_allocp;
  74.         unsigned long _rand_random;
  75.         char *_strtok_sp;
  76.         char *_get_tz_cp;
  77.         char _get_tz_DST_enabled;
  78.         int _get_tz_GMT_less_local;
  79.         struct tm _localtime_tm;
  80.         struct tm _gmtime_tm;
  81.         #ifndef __CPLUSPLUS__ /* struct exception isn't defined under C++ */
  82.         int (*_matherr_handler)(struct exception *err_info);
  83.         #endif
  84.         } _static_t;
  85.  
  86.  
  87. /* Definition of system-dependent entry point for retrieving the pointer 
  88.    to the static data.
  89. */
  90.     #if _HOBBIT
  91.         #define _TASK_DATA_PTR OSTaskRWData
  92.     #else
  93.         #error _TASK_DATA_PTR not defined in static.h
  94.     #endif
  95.     /* retrieve task data pointer */
  96.     extern void *_TASK_DATA_PTR();
  97.  
  98. /* Initializes the static area.  Must be called before "main" at runtime. 
  99.    This routine will call _TASK_DATA_PTR to get access to the data area
  100.    needing initialization */
  101.     extern void _static_initialize();
  102.  
  103.  
  104.  
  105.     #define _STATIC(x)(((_static_t *)_TASK_DATA_PTR())->x)
  106.  
  107.     /* macros used to access fields in task data */
  108.  
  109.     /* external variables */
  110.     #define errno             _STATIC(errno)
  111.     #define _IOB            _STATIC(_IOB)
  112.     #if (_IOB_FORMAT == _IOB_LIST)
  113.         #define _iob_head        _STATIC(_iob_head)
  114.     #else
  115.         #define _iob_fioflag    _STATIC(_iob_fioflag)
  116.         #define _iob_unget        _STATIC(_iob_unget)
  117.         #define _iob_tmpnam        _STATIC(_iob_tmpnam)
  118.     #endif
  119.     #define _fopen_max        _STATIC(_iob_fopen_max)
  120.     #define _fmode            _STATIC(_iob_fmode)
  121.     #define _pmode            _STATIC(_iob_pmode)
  122.         #define _random            _STATIC(_rand_random)
  123.     #ifndef __CPLUSPLUS__
  124.         #define _matherr_handler    _STATIC(_matherr_handler)
  125.     #endif
  126.  
  127.     /* static variables */
  128.     #define _tmpnam_s0        _STATIC(_tmpnam_s0)
  129.     #define _tmpnam_n        _STATIC(_tmpnam_n)
  130.         #define _doecvt_buf        _STATIC(_doecvt_buf)
  131.         #define _asctime_buf        _STATIC(_asctime_buf)
  132.         #define _ctime_buf        _STATIC(_ctime_buf)
  133.         #define _atexit_count        _STATIC(_atexit_count)
  134.         #define _malloc_base         _STATIC(_malloc_base)
  135.         #define _malloc_allocp        _STATIC(_malloc_allocp)
  136.         #define    _strtok_sp        _STATIC(_strtok_sp)
  137.         #define _get_tz_cp        _STATIC(_get_tz_cp)
  138.         #define _get_tz_DST_enabled    _STATIC(_get_tz_DST_enabled)
  139.         #define _get_tz_GMT_less_local    _STATIC(_get_tz_GMT_less_local)
  140.         #define _localtime_tm        _STATIC(_localtime_tm)
  141.         #define _gmtime_tm        _STATIC(_gmtime_tm)
  142.  
  143.     #endif
  144. #pragma pop_align_members();
  145. #endif
  146.