/* /% C %/ */ /*********************************************************************** * cint (C/C++ interpreter) ************************************************************************ * Source file include/mkincld.c ************************************************************************ * Description: * Create standard include files at cint installation ************************************************************************ * Author Masaharu Goto * Copyright(c) 1995~1999 Masaharu Goto (MXJ02154@niftyserve.or.jp) * * Permission to use, copy, modify and distribute this software and its * documentation for non-commercial purpose is hereby granted without fee, * provided that the above copyright notice appear in all copies and * that both that copyright notice and this permission notice appear * in supporting documentation. The author makes no * representations about the suitability of this software for any * purpose. It is provided "as is" without express or implied warranty. ************************************************************************/ #include #include #include #ifndef G__NONANSI #ifndef G__SUNOS4 #include #endif #endif #include #include #include #include #include #include #include "../G__ci.h" #ifdef G__NEWSOS4 #include #ifndef _IOFBF #define _IOFBF (0) #endif #ifndef SIG_ERR #define SIG_ERR (-1) #endif typedef int clock_t; #endif /* G__NEWSOS4 */ /* char *dir="include/"; */ char *dir=""; /******************************************************************* * check_pointersize() *******************************************************************/ int check_pointersize() { fprintf(stdout,"sizeof(long)=%d , sizeof(void*)=%d\n" ,sizeof(long),sizeof(void*)); if(sizeof(long)\n"); fprintf(fp,"#endif\n"); fprintf(fp,"#pragma include_noerr \n"); fprintf(fp,"#endif\n"); fclose(fp); return(0); } /******************************************************************* *******************************************************************/ int gen_limits() { FILE *fp; char filename[200]; char *header="limits.h"; sprintf(filename,"%s%s",dir,header); fp=fopen(filename,"w"); testdup(fp,"G__LIMITS_H"); fprintf(fp,"#define \tCHAR_BIT (%d)\n",CHAR_BIT); fprintf(fp,"#define \tCHAR_MAX (%d)\n",CHAR_MAX); fprintf(fp,"#define \tCHAR_MIN (%d)\n",CHAR_MIN); fprintf(fp,"#define \tINT_MAX (%d)\n",INT_MAX); fprintf(fp,"#define \tINT_MIN (%d)\n",INT_MIN); fprintf(fp,"#define \tLONG_MAX (%ld)\n",LONG_MAX); fprintf(fp,"#define \tLONG_MIN (%ld)\n",LONG_MIN); fprintf(fp,"#define \tSCHAR_MAX (%d)\n",SCHAR_MAX); fprintf(fp,"#define \tSCHAR_MIN (%d)\n",SCHAR_MIN); fprintf(fp,"#define \tSHRT_MAX (%d)\n",SHRT_MAX); fprintf(fp,"#define \tSHRT_MIN (%d)\n",SHRT_MIN); fprintf(fp,"#define \tUCHAR_MAX (%d)\n",UCHAR_MAX); fprintf(fp,"const unsigned int \tUINT_MAX =(%u);\n",UINT_MAX); fprintf(fp,"const unsigned long \tULONG_MAX =(%lu);\n",ULONG_MAX); fprintf(fp,"#define \tUSHRT_MAX (%u)\n",USHRT_MAX); fprintf(fp,"#endif\n"); fclose(fp); return(0); } /******************************************************************* *******************************************************************/ int gen_time() { FILE *fp; char filename[200]; char *header="time.h"; sprintf(filename,"%s%s",dir,header); fp=fopen(filename,"w"); testdup(fp,"G__TIME_H"); UINT_TYPEDEF_PREFER_LONG(fp,clock_t,"clock_t"); INT_TYPEDEF_PREFER_LONG(fp,time_t,"time_t"); #ifndef G__OLDIMPLEMENTATION467 fprintf(fp,"#ifndef G__STDSTRUCT\n"); fprintf(fp,"#pragma setstdstruct\n"); fprintf(fp,"#endif\n"); #else fprintf(fp,"struct tm {\n"); fprintf(fp," int tm_sec;\n"); fprintf(fp," int tm_min;\n"); fprintf(fp," int tm_hour;\n"); fprintf(fp," int tm_mday;\n"); fprintf(fp," int tm_mon;\n"); fprintf(fp," int tm_year;\n"); fprintf(fp," int tm_wday;\n"); fprintf(fp," int tm_yday;\n"); fprintf(fp," int tm_isdst;\n"); fprintf(fp,"};\n"); #endif #ifdef CLK_TCK fprintf(fp,"#define \tCLK_TCK (%ld)\n",(long)CLK_TCK); #endif fprintf(fp,"#endif\n"); fclose(fp); return(0); } /******************************************************************* *******************************************************************/ #ifndef G__NONANSI #ifndef G__SUNOS4 int gen_float() { FILE *fp; char filename[200]; char *header="float.h"; sprintf(filename,"%s%s",dir,header); fp=fopen(filename,"w"); testdup(fp,"G__FLOAT_H"); fprintf(fp,"#define \tDBL_DIG (%d)\n",DBL_DIG); fprintf(fp,"#define \tDBL_EPSILON (%g)\n",DBL_EPSILON); fprintf(fp,"#define \tDBL_MANT_DIG (%d)\n",DBL_MANT_DIG); fprintf(fp,"#define \tDBL_MAX (%g)\n",DBL_MAX); fprintf(fp,"#define \tDBL_MAX_10_EXP (%d)\n",DBL_MAX_10_EXP); fprintf(fp,"#define \tDBL_MAX_EXP (%d)\n",DBL_MAX_EXP); fprintf(fp,"#define \tDBL_MIN (%g)\n",DBL_MIN); fprintf(fp,"#define \tDBL_MIN_10_EXP (%d)\n",DBL_MIN_10_EXP); fprintf(fp,"#define \tDBL_MIN_EXP (%d)\n",DBL_MIN_EXP); fprintf(fp,"#define \tFLT_DIG (%d)\n",FLT_DIG); fprintf(fp,"#define \tFLT_EPSILON (%g)\n",FLT_EPSILON); fprintf(fp,"#define \tFLT_MANT_DIG (%d)\n",FLT_MANT_DIG); fprintf(fp,"#define \tFLT_MAX (%g)\n",FLT_MAX); fprintf(fp,"#define \tFLT_MAX_10_EXP (%d)\n",FLT_MAX_10_EXP); fprintf(fp,"#define \tFLT_MAX_EXP (%d)\n",FLT_MAX_EXP); fprintf(fp,"#define \tFLT_MIN (%g)\n",FLT_MIN); fprintf(fp,"#define \tFLT_MIN_10_EXP (%d)\n",FLT_MIN_10_EXP); fprintf(fp,"#define \tFLT_MIN_EXP (%d)\n",FLT_MIN_EXP); fprintf(fp,"#define \tFLT_RADIX (%d)\n",FLT_RADIX); fprintf(fp,"#define \tFLT_ROUNDS (%d)\n",FLT_ROUNDS); fprintf(fp,"#define \tLDBL_DIG (%d)\n",DBL_DIG); fprintf(fp,"#define \tLDBL_EPSILON (%g)\n",DBL_EPSILON); fprintf(fp,"#define \tLDBL_MANT_DIG (%d)\n",DBL_MANT_DIG); fprintf(fp,"#define \tLDBL_MAX (%g)\n",DBL_MAX); fprintf(fp,"#define \tLDBL_MAX_10_EXP (%d)\n",DBL_MAX_10_EXP); fprintf(fp,"#define \tLDBL_MAX_EXP (%d)\n",DBL_MAX_EXP); fprintf(fp,"#define \tLDBL_MIN (%g)\n",DBL_MIN); fprintf(fp,"#define \tLDBL_MIN_10_EXP (%d)\n",DBL_MIN_10_EXP); fprintf(fp,"#define \tLDBL_MIN_EXP (%d)\n",DBL_MIN_EXP); fprintf(fp,"#endif\n"); fclose(fp); return(0); } #endif #endif /******************************************************************* *******************************************************************/ int gen_math() { FILE *fp; char filename[200]; char *header="math.h"; sprintf(filename,"%s%s",dir,header); fp=fopen(filename,"w"); testdup(fp,"G__MATH_H"); fprintf(fp,"#define \tEDOM (%d)\n",EDOM); fprintf(fp,"#define \tERANGE (%d)\n",ERANGE); #if defined(G__NONANSI) || defined(G__SUNOS4) fprintf(fp,"#define \tHUGE_VAL (%g)\n",1.79e+308); /* HUGE_VAL */ #else fprintf(fp,"#define \tHUGE_VAL (%g)\n",DBL_MAX); /* HUGE_VAL */ #endif fprintf(fp,"#pragma include_noerr \n"); fprintf(fp,"#endif\n"); fclose(fp); return(0); } /******************************************************************* *******************************************************************/ int gen_errno() { FILE *fp; char filename[200]; char *header="errno.h"; sprintf(filename,"%s%s",dir,header); fp=fopen(filename,"w"); testdup(fp,"G__ERRNO_H"); fprintf(fp,"/* extern int errno; */\n"); fprintf(fp,"#endif\n"); fclose(fp); return(0); } /******************************************************************* *******************************************************************/ int gen_stdlib() { FILE *fp; char filename[200]; char *header="stdlib.h"; sprintf(filename,"%s%s",dir,header); fp=fopen(filename,"w"); testdup(fp,"G__STDLIB_H"); #ifndef G__OLDIMPLEMENTATION467 fprintf(fp,"#ifndef G__STDSTRUCT\n"); fprintf(fp,"#pragma setstdstruct\n"); fprintf(fp,"#endif\n"); #else fprintf(fp,"typedef struct {\n"); fprintf(fp," int quot;\n"); fprintf(fp," int rem;\n"); fprintf(fp,"} div_t;\n"); fprintf(fp,"typedef struct {\n"); fprintf(fp," long int quot;\n"); fprintf(fp," long int rem;\n"); fprintf(fp,"} ldiv_t;\n"); #endif UINT_TYPEDEF_PREFER_INT(fp,size_t,"size_t"); fprintf(fp,"#define \tEXIT_FAILURE (%d)\n",EXIT_FAILURE); fprintf(fp,"#define \tEXIT_SUCCESS (%d)\n",EXIT_SUCCESS); fprintf(fp,"#define \tMB_CUR_MAX (%d)\n",MB_CUR_MAX); fprintf(fp,"#define \tMB_LEN_MAX (%d)\n",MB_LEN_MAX); #ifndef G__NONANSI #ifndef G__SUNOS4 fprintf(fp,"#define \tRAND_MAX (%d)\n",RAND_MAX); #endif #endif #ifndef G__NONANSI UINT_TYPEDEF_PREFER_INT(fp,wchar_t,"wchar_t"); #else fprintf(fp,"typedef unsigned short wchar_t;\n"); #endif fprintf(fp,"#pragma include_noerr \n"); fprintf(fp,"#endif\n"); fclose(fp); return(0); } /******************************************************************* *******************************************************************/ int gen_locale() { FILE *fp; char filename[200]; char *header="locale.h"; sprintf(filename,"%s%s",dir,header); fp=fopen(filename,"w"); testdup(fp,"G__LOCALE_H"); #ifndef G__OLDIMPLEMENTATION467 fprintf(fp,"#ifndef G__STDSTRUCT\n"); fprintf(fp,"#pragma setstdstruct\n"); fprintf(fp,"#endif\n"); #else fprintf(fp,"struct lconv {\n"); fprintf(fp," char *decimal_point;\n"); fprintf(fp," char *thousands_sep;\n"); fprintf(fp," char *grouping;\n"); fprintf(fp," char *int_curr_symbol;\n"); fprintf(fp," char *currency_symbol;\n"); fprintf(fp," char *mon_decimal_point;\n"); fprintf(fp," char *mon_thousands_sep;\n"); fprintf(fp," char *mon_grouping;\n"); fprintf(fp," char *positive_sign;\n"); fprintf(fp," char *negative_sign;\n"); fprintf(fp," char int_frac_digits;\n"); fprintf(fp," char frac_digits;\n"); fprintf(fp," char p_cs_precedes;\n"); fprintf(fp," char p_sep_by_space;\n"); fprintf(fp," char n_cs_precedes;\n"); fprintf(fp," char n_sep_by_space;\n"); fprintf(fp," char p_sign_posn;\n"); fprintf(fp," char n_sign_posn;\n"); fprintf(fp,"};\n"); #endif fprintf(fp,"#define \tLC_ALL (%d)\n",LC_ALL); fprintf(fp,"#define \tLC_COLLATE (%d)\n",LC_COLLATE); fprintf(fp,"#define \tLC_CTYPE (%d)\n",LC_CTYPE); fprintf(fp,"#define \tLC_MONETARY (%d)\n",LC_MONETARY); fprintf(fp,"#define \tLC_NUMERIC (%d)\n",LC_NUMERIC); fprintf(fp,"#define \tLC_TIME (%d)\n",LC_TIME); fprintf(fp,"#endif\n"); fclose(fp); return(0); } /******************************************************************* *******************************************************************/ int gen_stddef() { FILE *fp; char filename[200]; char *header="stddef.h"; sprintf(filename,"%s%s",dir,header); fp=fopen(filename,"w"); testdup(fp,"G__STDDEF_H"); /* NULL */ /* offsetof(); */ INT_TYPEDEF_PREFER_LONG(fp,ptrdiff_t,"ptrdiff_t"); UINT_TYPEDEF_PREFER_INT(fp,size_t,"size_t"); #ifndef G__NONANSI UINT_TYPEDEF_PREFER_INT(fp,wchar_t,"wchar_t"); #else fprintf(fp,"typedef unsigned short wchar_t;\n"); #endif fprintf(fp,"#endif\n"); fclose(fp); return(0); } /******************************************************************* *******************************************************************/ int gen_signal() { FILE *fp; char filename[200]; char *header="signal.h"; sprintf(filename,"%s%s",dir,header); fp=fopen(filename,"w"); testdup(fp,"G__SIGNAL_H"); fprintf(fp,"#define \tSIG_DFL (%ld)\n",(long)SIG_DFL); fprintf(fp,"#define \tSIG_ERR (%ld)\n",(long)SIG_ERR); fprintf(fp,"#define \tSIG_IGN (%ld)\n",(long)SIG_IGN); fprintf(fp,"#define \tSIGABRT (%d)\n",SIGABRT); fprintf(fp,"#define \tSIGFPE (%d)\n",SIGFPE); fprintf(fp,"#define \tSIGILL (%d)\n",SIGILL); fprintf(fp,"#define \tSIGINT (%d)\n",SIGINT); fprintf(fp,"#define \tSIGSEGV (%d)\n",SIGSEGV); fprintf(fp,"#define \tSIGTERM (%d)\n",SIGTERM); fprintf(fp,"/* non ANSI signals */\n"); #ifdef SIGHUP fprintf(fp,"#define \tSIGHUP (%d)\n",SIGHUP); #endif #ifdef SIGQUIT fprintf(fp,"#define \tSIGQUIT (%d)\n",SIGQUIT); #endif #ifdef SIGTSTP fprintf(fp,"#define \tSIGTSTP (%d)\n",SIGTSTP); #endif #ifdef SIGTTIN fprintf(fp,"#define \tSIGTTIN (%d)\n",SIGTTIN); #endif #ifdef SIGTTOU fprintf(fp,"#define \tSIGTTOU (%d)\n",SIGTTOU); #endif #ifdef SIGALRM fprintf(fp,"#define \tSIGALRM (%d)\n",SIGALRM); #endif #ifdef SIGUSR1 fprintf(fp,"#define \tSIGUSR1 (%d)\n",SIGUSR1); #endif #ifdef SIGUSR2 fprintf(fp,"#define \tSIGUSR2 (%d)\n",SIGUSR2); #endif #ifdef HELLO fprintf(fp,"#define \tHELLO (%d)\n",HELLO); #endif fprintf(fp,"#endif\n"); fclose(fp); return(0); } /******************************************************************* * main() *******************************************************************/ int main() { check_pointersize(); gen_stdio(); gen_limits(); gen_time(); #ifndef G__NONANSI #ifndef G__SUNOS4 gen_float(); #endif #endif gen_math(); gen_errno(); gen_stdlib(); gen_locale(); gen_stddef(); gen_signal(); exit(EXIT_SUCCESS); }