home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 22 gnu / 22-gnu.zip / fweb153.zip / fweb-1.53 / web / os.h < prev    next >
C/C++ Source or Header  |  1995-09-23  |  10KB  |  519 lines

  1. #if(0)
  2.   FTANGLE v1.53, created with UNIX on "Thursday, September 21, 1995 at 15:06." 
  3.   COMMAND LINE: "web/ftangle web/os -A -# --F -= 1.53/web/os.h"
  4.   RUN TIME: "Saturday, September 23, 1995 at 16:17."
  5.   WEB FILE:    "web/os.web"
  6.   CHANGE FILE: (none)
  7. #endif
  8.  
  9.  
  10.  
  11. #ifndef OS_H_
  12. #define OS_H_
  13.  
  14. #ifdef HAVE_CONFIG_H
  15. #include "config.h" /* \.{config.h} is generated by \.{./configure}. */
  16. #endif /* |HAVE_CONFIG_H| */
  17.  
  18.  
  19.  
  20.  
  21. #include "custom.h" /* Macros defined by the user. */
  22.  
  23.  
  24.  
  25.  
  26. #if OLD_PROTOTYPES
  27. #define PROTO(args) () /* Old-style. */
  28. #else
  29. #define PROTO(args) args /* New-style. */
  30. #endif /* |PROTOTYPES| */
  31.  
  32.  
  33.  
  34. #if(0)
  35. /* Sun's system is hopeless. */
  36. #if(NUM_VA_ARGS == 1)
  37. #undef NUM_VA_ARGS
  38. #define NUM_VA_ARGS 2
  39. #endif
  40. #endif
  41.  
  42. #if VARIABLE_ARGUMENTS
  43. #define ELLIPSIS ,... /* ANSI standard; VAX allows for old-style \
  44. declarations. */
  45. #define VA_ARGS
  46. #define VA_start
  47. #if(NUM_VA_ARGS == 1)
  48. #define VA_ALIST(args) (va_alist) /* Sun's way. */
  49. #define VA_DCL(args) va_dcl
  50. #define VA_START(a,n) va_start(a)
  51. #else
  52. #define VA_ALIST(args) args /* ANSI way. */
  53. #define VA_DCL(args) args
  54. #define VA_START(a,n) va_start(a,n)
  55. #endif
  56. #define VA_LIST(a) va_list a;
  57. #else
  58. #define ELLIPSIS /* Not permitted by \.{gcc} for old-style \
  59. declarations. */
  60. #define VA_ARGS ,arg_ptr
  61. #define arg_ptr arg1,arg2,arg3,arg4,arg5,arg6,\
  62. arg7,arg8,arg9,arg10,arg11,arg12,arg13
  63. #define VA_start outer_char *arg1,*arg2,*arg3,*arg4,*arg5,*arg6,\
  64. *arg7,*arg8,*arg9,*arg10,*arg11,*arg12,*arg13;
  65. #define VA_ALIST(args) args
  66. #define VA_DCL(args) args
  67. #define VA_LIST(a)
  68. #define VA_START(a,n)
  69. #ifdef va_arg
  70. #undef va_arg
  71. #define va_arg(a,type) (type)"KLUDGE for va_arg"
  72. #endif
  73. #define va_end(a)
  74. #define vprintf printf
  75. #define vsprintf sprintf
  76. #endif /* ANSI variable arguments. */
  77.  
  78.  
  79.  
  80. #if !NO_VOID  /* \.{Machine-dependent}: For machines \
  81. that understand about |void *| or |void fcn()|. */
  82. #define VOID void
  83. #define SRTN void
  84. #else
  85. #define VOID /* For use in function declarations. */
  86. #define void char
  87. #define SRTN int
  88. #endif /* |void| stuff. */
  89.  
  90. #if KEEP_CONST
  91. #define CONST const
  92. #else
  93. #define CONST
  94. #endif
  95.  
  96.  
  97.  
  98. #if OLD_PROTOTYPES
  99. /* Old-style declarations. */
  100. #define FCN(args) args
  101. #define C0(cmnt) ;
  102. #define C1(cmnt) ;
  103. #define C2(cmnt) ;VA_start
  104. #else
  105. /* New-style declarations.  To use these macros, function declarations \
  106. should have form |main FCN((num_args,args))|.  See one of the \FWEB\ \
  107. sources for examples of the use of~|C0|, |C1|, and~|C2|. */
  108. #define FCN(args) (
  109.  
  110. #define C0(cmnt) , /* Intermediate comments. */
  111.  
  112. #define C1(cmnt) ) /* Comment on last argument. */
  113.  
  114. #define C2(cmnt) ,...) /* Variable args. */
  115. #endif /* |PROTOTYPES| */
  116.  
  117.  
  118.  
  119. /* SYSTEM LOGIC based on \.{custom.h}, and additional include files. */
  120.  
  121. #ifndef ANSI_CTYPE_H
  122. #define ANSI_CTYPE_H 0
  123. #endif
  124.  
  125. #ifndef ANSI_SPRINTF
  126. #define ANSI_SPRINTF 0
  127. #endif
  128.  
  129. #ifndef ANSI_SSCANF
  130. #define ANSI_SSCANF 0
  131. #endif
  132.  
  133. #ifndef ANSI_SYSTEM
  134. #define ANSI_SYSTEM 0
  135. #endif
  136.  
  137. #ifndef DEBUG_XCHR
  138. #define DEBUG_XCHR 0
  139. #endif
  140.  
  141. #ifndef FCN_CALLS
  142. #define FCN_CALLS 0
  143. #endif
  144.  
  145. #ifndef FANCY_SPLIT
  146. #define FANCY_SPLIT 0
  147. #endif
  148.  
  149. #ifndef HAVE_ERROR
  150. #define HAVE_ERROR 0
  151. #endif
  152.  
  153. #ifndef HAVE_GETENV
  154. #define HAVE_GETENV 0
  155. #endif
  156.  
  157. #ifndef HAVE_GETTIMEOFDAY
  158. #define HAVE_GETTIMEOFDAY 0
  159. #endif
  160.  
  161. #ifndef HAVE_LIMITS_H
  162. #define HAVE_LIMITS_H 0
  163. #endif
  164.  
  165. #ifndef HAVE_SYS_TIMEB_H
  166. #define HAVE_SYS_TIMEB_H 0
  167. #endif
  168.  
  169. #ifndef HAVE_STDARG_H
  170. #define HAVE_STDARG_H 0
  171. #endif
  172.  
  173. #ifndef HAVE_STDDEF_H
  174. #define HAVE_STDDEF_H 0
  175. #endif
  176.  
  177. #ifndef HAVE_STDLIB_H
  178. #define HAVE_STDLIB_H 0
  179. #endif
  180.  
  181. #ifndef HAVE_STD_PROTOTYPES
  182. #define HAVE_STD_PROTOTYPES 0
  183. #endif
  184.  
  185. #ifndef HAVE_STRERROR
  186. #define HAVE_STRERROR 0
  187. #endif
  188.  
  189. #ifndef HAVE_VALUES_H
  190. #define HAVE_VALUES_H 0
  191. #endif
  192.  
  193. #ifndef HUGE_POINTERS
  194. #define HUGE_POINTERS 0
  195. #endif
  196.  
  197. #ifndef KEEP_CONST
  198. #define KEEP_CONST 0
  199. #endif
  200.  
  201. #ifndef NEW_DIFFTIME
  202. #define NEW_DIFFTIME 0
  203. #endif
  204.  
  205. #ifndef NO_VOID
  206. #define NO_VOID 0
  207. #endif
  208.  
  209. #ifndef NON_ANSI_CALLOC
  210. #define NON_ANSI_CALLOC 0
  211. #endif
  212.  
  213. #ifndef OLD_PROTOTYPES
  214. #define OLD_PROTOTYPES 0
  215. #endif
  216.  
  217. #ifndef PRINT_AVAILABLE_MEMORY
  218. #define PRINT_AVAILABLE_MEMORY 0
  219. #endif
  220.  
  221. #ifndef SIZE_T_DEFINED
  222. #define SIZE_T_DEFINED 0
  223. #endif
  224.  
  225. #ifndef TIMING
  226. #define TIMING 0
  227. #endif
  228.  
  229. #ifndef TRANSLATE_ASCII
  230. #define TRANSLATE_ASCII 0
  231. #endif
  232.  
  233. #ifndef UNIX_PATH
  234. #define UNIX_PATH 0
  235. #endif
  236.  
  237.  
  238.  
  239. #if HAVE_STDARG_H
  240. #include <stdarg.h>
  241. #else
  242. #include <varargs.h>
  243. #endif
  244.  
  245. #if HAVE_STDLIB_H
  246. #include <stdlib.h>
  247. #endif
  248.  
  249. #if !HAVE_STD_PROTOTYPES
  250. #include "stdlib0.h"
  251. #endif
  252.  
  253. #if HAVE_STDDEF_H
  254. #include <stddef.h>
  255. #endif
  256.  
  257. #if HAVE_LIMITS_H
  258. #include <limits.h> /* ANSI: Numerical limits. */
  259. #else
  260. #if HAVE_VALUES_H
  261. #define INT_MAX MAXINT
  262. #define LONG_MAX MAXLONG
  263. #else
  264. #define INT_MAX 0x7FFF
  265. #define LONG_MAX INT_MAX
  266. #endif
  267.  
  268. #define INT_MIN (~(INT_MAX))
  269. #define LONG_MIN (~(LONG_MAX))
  270. #define ULONG_MAX (MAXLONG | (~(MAXLONG)))
  271. /* E.g., |0x7FFF OR0x8000|. */
  272. #endif
  273.  
  274. #if HAVE_FLOAT_H
  275. #include <float.h>
  276. #else
  277. #ifndef DBL_DIG
  278. #define DBL_DIG 10
  279. #endif
  280. #endif
  281.  
  282. #if !NON_ANSI_CALLOC
  283. #define CALLOC calloc
  284. #define REALLOC(old_ptr, new_size, old_size) realloc(old_ptr, new_size)
  285. #define FREE free
  286. #endif /* |ANSI_CALLOC| */
  287.  
  288.  
  289. /* Some compilers can't handle |unsigned long| constants of the form \
  290. |123UL|.  Thus, these constants are declared via the following macro. */
  291.  
  292. #define UL(num) ((unsigned long)(num))
  293.  
  294. #include <stdio.h> /* ANSI: STDIO routines. */
  295. #include <errno.h>
  296.  
  297. /* We use only ANSI write routines. */
  298. #define FWRITE(buf,len,fp) fwrite((CONST void *)(buf),(size_t)(len),\
  299.     (size_t)(1),fp)
  300.  
  301. #define WRITE1(buf,len) \
  302.  {\
  303.  int _k;\
  304.  outer_char *_p;\
  305.  for(_p= buf,_k= (int)(len); _k>0; _k--)\
  306.    {\
  307.    PUTC(*_p);\
  308.    _p++;\
  309.    }\
  310.  }
  311.  
  312. /* The following is courtesy of the autoconf Info file. */
  313. #if STDC_HEADERS || HAVE_STRING_H
  314. #include <string.h> /* ANSI: String manipulation routines. */
  315.  
  316. #if !STDC_HEADERS && HAVE_MEMORY_H
  317. #include <memory.h>
  318. #endif
  319. #else
  320. #include <strings.h>
  321. #endif
  322.  
  323. #include <ctype.h> /* ANSI: Character classification macros. */
  324.  
  325. /* The following works only for |ASCII| machines.  Furthermore, it's slower \
  326. than the usual procedure involving ANDing a |_ctype| array with various bit \
  327. flags.  However, that procedure isn't portable across machines.  Caution: \
  328. This solution evaluates |c| more than once, so watch out for side effects! */
  329. #if !ANSI_CTYPE_H
  330. #undef isalpha
  331. #undef isupper
  332. #undef islower
  333.  
  334. #define isupper(c) ('A' <= (unsigned)(c) && (unsigned)(c) <= 'Z')
  335. #define islower(c) ('a' <= (unsigned)(c) && (unsigned)(c) <= 'z')
  336. #define isalpha(c) (isupper(c) || islower(c))
  337. #endif
  338.  
  339. #include <setjmp.h> /* ANSI: |longjmp| and |setjmp|. */
  340.  
  341.  
  342.  
  343.  
  344. /* --- TIMING --- */
  345.  
  346. /* The compiler-line macro |timing_width| overrides the default format for \
  347. the time output; it's the number of \.x's in \.{n.xx} seconds. (See \
  348. \.{custom.web}.) */
  349. #ifndef TIMING_WIDTH
  350. #define TIMING_WIDTH 1 /* We ensure that it's defined to something. */
  351. #endif /* |TIMING_WIDTH| */
  352.  
  353. #include <time.h> /* ANSI: Time-conversion routines. (For non-ANSI \
  354.             machines, defines |struct tm|.) */
  355.  
  356. #if TIMING
  357.  
  358. /* We like wall-clock timing more precise than seconds. */
  359.  
  360. /* \.{Machine-dependent}: Non-ANSI timing: */
  361. #if HAVE_GETTIMEOFDAY
  362. /* uSec timing */
  363. #include <sys/time.h>
  364. #undef NEW_DIFFTIME
  365. #define NEW_DIFFTIME 1
  366. #define TIME_T struct timeval
  367. #ifdef _COMMON_h
  368. struct timezone tz_dummy;
  369. #endif
  370. int gettimeofday PROTO((struct timeval*tp,struct timezone*tzp));
  371. #define TIME(p) gettimeofday(p, &tz_dummy)
  372. #else
  373. #if HAVE_SYS_TIMEB_H
  374. /* mSec timing */
  375. #include <sys/timeb.h>
  376. #undef NEW_DIFFTIME
  377. #define NEW_DIFFTIME 1
  378. #define TIME_T struct timeb
  379. #define TIME(p) ftime(p)
  380. #else /* ANSI timing */
  381. #define TIME_T time_t
  382. #define TIME(p) time(p)
  383. #endif /* |HAVE_SYS_TIMEB_H| */
  384. #endif /* |HAVE_GETTIMEOFDAY| */
  385.  
  386. #if NEW_DIFFTIME
  387. #define DIFFTIME diff_time /* We supply our own version of \
  388. |difftime| when we don't like the ANSI version. See \.{common.web}. (We \
  389. can't just call our new version |difftime| because if that's already been \
  390. prototyped the compiler will complain about a prototype mismatch.) */
  391. #else
  392. #define DIFFTIME difftime /* Use the ANSI routine. */
  393. #endif /* |NEW_DIFFTIME| */
  394.  
  395. clock_t clock PROTO((VOID));/* Not defined on some machines. */
  396.  
  397. #ifndef CLOCKS_PER_SEC
  398. #ifdef CLK_TCK
  399. #define CLOCKS_PER_SEC CLK_TCK /* Some use older name. */
  400. #else
  401. #define CLOCKS_PER_SEC 1000000 /* Guess at default: \
  402. $\mu$sec timing. */
  403. #endif /* |CLK_TCK| */
  404. #endif /* |CLOCKS_PER_SEC| */
  405.  
  406. #endif /* |TIMING| */
  407.  
  408.  
  409.  
  410. #ifndef THE_SYSTEM
  411. #define THE_SYSTEM "UNKNOWN"
  412. #endif
  413.  
  414. #ifndef LOCAL_BANNER
  415. #define LOCAL_BANNER ""
  416. #endif
  417.  
  418. #ifndef NULL_FILE_NAME
  419. #define NULL_FILE_NAME "null"
  420. #endif
  421.  
  422. #ifndef C_EXT
  423. #define C_EXT "c"
  424. #endif
  425.  
  426. #ifndef M_EXT
  427. #define M_EXT "mk"
  428. #endif
  429.  
  430. #ifndef X_EXT
  431. #define X_EXT "sty"
  432. #endif
  433.  
  434. #ifndef Cpp_EXT
  435. #define Cpp_EXT "c++"
  436. #endif
  437.  
  438. #ifndef R_EXT
  439. #define R_EXT "r"
  440. #endif
  441.  
  442. #ifndef R90_EXT
  443. #define R90_EXT "r90"
  444. #endif
  445.  
  446. #ifndef N_EXT
  447. #define N_EXT "f"
  448. #endif
  449.  
  450. #ifndef N90_EXT
  451. #define N90_EXT "f90"
  452. #endif
  453.  
  454. #ifndef VARIABLE_ARGUMENTS
  455. #define VARIABLE_ARGUMENTS 0
  456. #endif
  457.  
  458. #if VARIABLE_ARGUMENTS
  459. #ifndef NUM_VA_ARGS
  460. #define NUM_VA_ARGS 2
  461. #endif
  462. #endif
  463.  
  464. #ifndef PREFIX_END_CHAR
  465. #define PREFIX_END_CHAR '/'
  466. #endif
  467.  
  468.  
  469.  
  470.  
  471. #ifndef _strmac_
  472. #include "strmac.h" /* Macros for casting calls to string routines. */
  473. #endif /* |_strmac_| */
  474.  
  475.  
  476.  
  477. #define UNUSED(var) var
  478.  
  479.  
  480.  
  481. #define HUGE_FCN_PTR
  482.  
  483. #ifndef _POSIX_SOURCE
  484. #define _POSIX_SOURCE /* Otherwise, the Sun gets hopelessly confused. */
  485. #endif
  486.  
  487. #include <math.h> /* ANSI: Declarations of mathematics functions such as |pow|. */
  488. #ifdef HUGE
  489. #undef HUGE /* The Sun's annoying. */
  490. #endif
  491.  
  492. #if HUGE_POINTERS /* \.{Machine-dependent}: Force full pointer arithmetic. */
  493. #define HUGE huge /* \It{Normalized} far pointer. */
  494. #else
  495. #define HUGE /* Null def'n for everything except personal computers. */
  496. #endif /* |HUGE_POINTERS| */
  497.  
  498.  
  499.  
  500. #define PLUS
  501.  
  502.  
  503.  
  504. #define CAST(type,var) var
  505. #define _Xx(fmt) fmt
  506.  
  507.  
  508.  
  509.  
  510.  
  511.  
  512.  
  513. #endif /* |OS_H_| */
  514.  
  515.  
  516.  
  517.  
  518.  
  519.