Subversion Repositories tendra.SVN

Rev

Rev 2 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 7u83 1
/*
2
    		 Crown Copyright (c) 1997
3
 
4
    This TenDRA(r) Computer Program is subject to Copyright
5
    owned by the United Kingdom Secretary of State for Defence
6
    acting through the Defence Evaluation and Research Agency
7
    (DERA).  It is made available to Recipients with a
8
    royalty-free licence for its use, reproduction, transfer
9
    to other parties and amendment for any purpose not excluding
10
    product development provided that any such use et cetera
11
    shall be deemed to be acceptance of the following conditions:-
12
 
13
        (1) Its Recipients shall ensure that this Notice is
14
        reproduced upon any copies or amended versions of it;
15
 
16
        (2) Any amended version of it shall be clearly marked to
17
        show both the nature of and the organisation responsible
18
        for the relevant amendment or amendments;
19
 
20
        (3) Its onward transfer from a recipient to another
21
        party shall be deemed to be that party's acceptance of
22
        these conditions;
23
 
24
        (4) DERA gives no warranty or assurance as to its
25
        quality or suitability for any purpose and DERA accepts
26
        no liability whatsoever in relation to any use to which
27
        it may be put.
28
*/
29
 
30
 
31
/**** os-interface.h --- Primitive definitions.
32
 *
33
 ** Author: Steve Folkes <smf@hermes.mod.uk>
34
 *
35
 **** Commentary:
36
 *
37
 ***=== INTRODUCTION =========================================================
38
 *
39
 * This file specifies an interface to the host system's C library, compiler
40
 * and operating system.  It provides definitions of basic types, constants
41
 * and macros, and declarations of functions, that can be used by other
42
 * components of the program.
43
 *
44
 * This file (and others in this directory) makes use of several macros to
45
 * turn on certain features.  These macros are listed below.  In each case
46
 * there is a macro that begins with ``FS_NO_'' instead of ``FS_'' that turns
47
 * the feature off; if both are defined, the ``FS_NO_'' macro takes
48
 * precedence, and the feature is turned off.  In addition, the ``FS_NO_STDC''
49
 * macro may be used to turn off the ``__STDC__'' macro (in the cases where
50
 * the system isn't really ANSI compliant), and the ``FS_NO_FILE_INFO'' macro
51
 * should be defined if the ``__FILE__'' or ``__LINE__'' macros are
52
 * unsupported.
53
 *
54
 *	FS_FAST
55
 *
56
 * This should be defined if you want the program to use macros in place of
57
 * some function calls.  This will generally speed up the program (although
58
 * this is not guaranteed).  It is incompatible with ``FS_SHORTNAMES''.  It
59
 * also turns off the assertion checking (unless ``FS_ASSERT'' is also
60
 * defined).
61
 *
62
 *	FS_SHORTNAMES
63
 *
64
 * This is a hack for systems that cannot cope with long external identifier
65
 * names.  It includes the file "shortnames.h" which should macro define all
66
 * external identifiers to be a suitable short name.  It is incompatible with
67
 * ``FS_FAST''.
68
 *
69
 *	FS_ASSERT
70
 *
71
 * This should be defined if you want assertion checking enabled.  This is on
72
 * by default, unless ``FS_FAST'' is defined, so it is only really useful to
73
 * define this if you have also defined ``FS_FAST'', but still want assertions
74
 * to be checked.  It is possible that less assertions will be checked, as
75
 * some of the "inlined" functions may have lost their assertions in the
76
 * macro version.
77
 *
78
 *	FS_STDC_HASH
79
 *
80
 * This should be defined if the system supports ANSI C style macro hash
81
 * syntax (``#'' and ``##'').  It is automatically defined if the ``__STDC__''
82
 * macro is defined.
83
 *
84
 *	FS_PROTOTYPES
85
 *
86
 * This should be defined if the system supports ANSI C style function
87
 * prototypes.  It is automatically defined if the ``__STDC__'' macro is
88
 * defined.
89
 *
90
 *	FS_VOID_PTR
91
 *
92
 * This should be defined if the system supports ``void *'' as a generic
93
 * pointer.  If this is not the case, then ``char *'' is used instead.  It is
94
 * automatically defined if the ``__STDC__'' macro is defined.
95
 *
96
 *	FS_VOLATILE
97
 *
98
 * This should be defined if this system supports the ANSI C ``volatile''
99
 * keyword.  It is automatically defined if the ``__STDC__'' macro is defined.
100
 *
101
 *	FS_CONST
102
 *
103
 * This should be defined if this system supports the ANSI C ``const''
104
 * keyword.  It is automatically defined if the ``__STDC__'' macro is defined.
105
 *
106
 *	FS_UNION_INIT
107
 *
108
 * This should be defined if this system supports the ANSI C union
109
 * initialisation.  It is automatically defined if the ``__STDC__'' macro is
110
 * defined.
111
 *
112
 *	FS_ENUM
113
 *
114
 * This should be defined if this system supports enumerated types.  It is
115
 * automatically defined if ``__STDC__'' is defined.  This macro needs to be
116
 * tested wherever an enumeration type is declared, and if enumeration types
117
 * are not supported, then an integer must be used instead.
118
 *
119
 *	FS_ANSI_ENVIRON
120
 *
121
 * This should be defined if the system has an ANSI C compliant standard
122
 * library.  If this is not the case, then an attempt is made to approximate
123
 * that library.  It is automatically defined if the ``__STDC__'' macro is
124
 * defined to be ``1''.
125
 *
126
 *	FS_BINARY_STDIO
127
 *
128
 * This should be defined if the system supports the "b" modifier to the
129
 * standard library ``fopen'' function.  It is automatically defined if
130
 * ``FS_ANSI_ENVIRON'' is defined.
131
 *
132
 *	FS_STRERROR
133
 *
134
 * This should be defined if this system supports the ANSI ``strerror''
135
 * function for getting a textual description of a system error message.  It
136
 * is automatically defined if ``FS_ANSI_ENVIRON'' is defined.
137
 *
138
 *	FS_SYS_ERRLIST
139
 *
140
 * This should be defined if this system supports ``sys_nerr'' and
141
 * ``sys_errlist'' for getting a textual description of the current system
142
 * error.  If the ``FS_STRERROR'' macro is defined, then the ANSI ``strerror''
143
 * function will be used instead (overiding this macro).  If neither macro is
144
 * defined, then the error number will be used as the message.
145
 *
146
 *	FS_MKDIR
147
 *
148
 * This should be defined if this system supports the POSIX ``mkdir''
149
 * function.
150
 *
151
 * As well as the feature switch macros, there are some portability option
152
 * macros as well.  These provide values for types and constants when the type
153
 * cannot be otherwise deduced.  These macros are ignored when the correct
154
 * value can be obtained automatically (this generally means on an ANSI
155
 * compliant system).
156
 *
157
 *	PO_SIZE_T_TYPE
158
 *
159
 * The ``sizeof'' operator returns a value of type ``size_t''.  In an ANSI C
160
 * compliant standard library, this type should be defined in <stddef.h>.  If
161
 * the machine doesn't have an ANSI C compliant standard library, then this
162
 * macro should specify the type of ``size_t''.  If no definition is provided,
163
 * and the environment is not ANSI C compliant, then ``unsigned'' will be
164
 * used.
165
 *
166
 *	PO_CHAR_BIT
167
 *
168
 * This should be defined to be the number of bits in a ``char'' object, used
169
 * to define ``CHAR_BIT''.  In an ANSI C compliant standard library, this
170
 * macro is defined in <limits.h>. If the standard library is not ANSI
171
 * compliant and no value is provided, then ``8'' will be used.
172
 *
173
 *	PO_EXIT_SUCCESS
174
 *	PO_EXIT_FAILURE
175
 *
176
 * These two macros should be defined to be the values for ``EXIT_SUCCESS''
177
 * and ``EXIT_FAILUE''.  In an ANSI C compliant standard library, they are
178
 * defined in <stdlib.h>.  If the standard library is not ANSI compliant and
179
 * no value is provided, then ``0'' and ``1'' will be used.
180
 *
181
 *	PO_UINT_MAX
182
 *
183
 * This should be defined to be the maximum unsinged integer, and is used to
184
 * define ``UINT_MAX''.  In an ANSI C compliant standard library, this macro
185
 * is defined in <limits.h>. If the standard library is not ANSI compliant and
186
 * no value is provided, then ``(~(unsigned) 0)'' will be used.
187
 *
188
 *	PO_SEEK_SET
189
 *	PO_SEEK_CUR
190
 *	PO_SEEK_END
191
 *
192
 * These should be defined to be the values for ``SEEK_SET'', ``SEEK_CUR'' and
193
 * ``SEEK_END''.  In an ANSI C compliant standard library, they are defined in
194
 * <stdio.h>.  If the standard library is not ANSI compliant and no value is
195
 * provided, then ``0'', ``1'' and ``2'' will be used.
196
 *
197
 * This file also requires that one external function be provided:
198
 *
199
 *	void				E_assertion_failed
200
 *			PROTO_S ((CStringP, CStringP, unsigned))
201
 *
202
 * This function will be called if an assertion fails.  It will be called with
203
 * the text of the assertion, the name of the file in which the assertion was
204
 * written, and line on which it occured.
205
 *
206
 ***=== FROM ANSI ============================================================
207
 *
208
 * The following ANSI C functions are declared:
209
 *
210
 *	NoReturnT			abort
211
 *			PROTO_S ((void))
212
 *	GenericP			calloc
213
 *			PROTO_S ((SizeT length, SizeT size))
214
 *	GenericP			malloc
215
 *			PROTO_S ((SizeT size))
216
 *	NoReturnT			exit
217
 *			PROTO_S ((int exit_code))
218
 *	void				free
219
 *			PROTO_S ((GenericP pointer))
220
 *	CStringP			getenv
221
 *			PROTO_S ((CStringP name))
222
 *	int				memcmp
223
 *			PROTO_S ((GenericP ptr1, GenericP ptr2, SizeT length))
224
 *	GenericP			memcpy
225
 *			PROTO_S ((GenericP to, GenericP from, SizeT length))
226
 *	GenericP			memset
227
 *			PROTO_S ((GenericP ptr, int val, SizeT length))
228
 *	GenericP			memchr
229
 *			PROTO_S ((GenericP ptr, int val, SizeT length))
230
 *	SizeT				strlen
231
 *			PROTO_S ((CStringP string))
232
 *	int				strcmp
233
 *			PROTO_S ((CStringP string1, CStringP string2))
234
 *	CStringP			strcpy
235
 *			PROTO_S ((CStringP to, CStringP from))
236
 *	CStringP			strchr
237
 *			PROTO_S ((CStringP string, int c))
238
 *	CStringP			strrchr
239
 *			PROTO_S ((CStringP string, int c))
240
 *
241
 * Also everything in <setjmp.h> and <stdio.h> is included (hopefully this is
242
 * sufficiently common to be used even on non-ANSI platforms).  Where features
243
 * are absent on non-ANSI systems, support for them will need to be added.
244
 *
245
 ***=== FUNCTIONS ============================================================
246
 *
247
 ** Function:	int			mkdir
248
 *			PROTO_S ((CStringP path, int mode))
249
 ** Exceptions:
250
 *
251
 * This function is only declared if the ``FS_MKDIR'' macro is defined.  This
252
 * macro should also be tested before the function is used anywhere.  It is
253
 * the POSIX directory creation function.
254
 *
255
 ** Function:	CStringP		strerror
256
 *			PROTO_S ((int error))
257
 ** Exceptions:
258
 *
259
 * This function is only declared if the ``FS_STRERROR'' macro is defined.
260
 * This macro should also be tested before the function is used anywhere.  It
261
 * is the ANSI function for obtaining a textual description of a system error
262
 * message.
263
 *
264
 ***=== VARIABLES ============================================================
265
 *
266
 ** Variable:	int			sys_nerr
267
 *
268
 * This variable is only declared if the ``FS_SYS_ERRLIST'' macro is defined.
269
 * It contains the number of error messages stored in the ``sys_errlist''
270
 * vector.
271
 *
272
 ** Variable:	CStringP		sys_errlist []
273
 *
274
 * This variable is only declared if the ``FS_SYS_ERRLIST'' macro is defined.
275
 * It contains the text of the system error messages.
276
 *
277
 ** Variable:	int			errno
278
 *
279
 * This variable contains the number of the current system error.
280
 *
281
 ***=== TYPES ================================================================
282
 *
283
 ** Type:	GenericP
284
 ** Repr:	void *
285
 *
286
 * This is the generic pointer type.  It can be used to store a pointer to any
287
 * non-function object.
288
 *
289
 ** Type:	NoReturnT
290
 ** Repr:	void
291
 *
292
 * This is the return type of a function that doesn't return (e.g.
293
 * ``longjmp'').  Normally this is just ``void'', however the GNU C compiler
294
 * can produce better code if this is declared as ``__volatile__ void''.  The
295
 * TenDRA compiler can be told that a function doesn't return as well.
296
 *
297
 ** Type:	SizeT
298
 ** Type:	SizeP
299
 ** Repr:	size_t
300
 *
301
 * This is the type of the return value of the "sizeof" operator.
302
 *
303
 ** Type:	CStringP
304
 ** Repr:	char *
305
 *
306
 * This is the C string type.  It is defined here to avoid a circularity in
307
 * the "os-interface" directory.  Other directories should access it via the
308
 * "cstring.h" file.
309
 *
310
 ** Type:	ByteT
311
 ** Type:	ByteP
312
 ** Repr:	unsigned char
313
 *
314
 * This is the byte type.  It is possible that this could be larger than a
315
 * byte in some implementations.
316
 *
317
 ** Type:	BoolT
318
 ** Type:	BoolP
319
 ** Repr:	int
320
 *
321
 * This is the boolean type.
322
 *
323
 ** Type:	CmpT
324
 ** Type:	CmpP
325
 ** Repr:	enum {CMP_LT, CMP_EQ, CMP_GT}
326
 *
327
 * This is the type returned by comparison functions.  The values represent
328
 * the fact that the first argument is less than, equal to, or greater than
329
 * the second argument respectively.
330
 *
331
 ***=== CONSTANTS ============================================================
332
 *
333
 ** Constant:	TRUE
334
 ** Constant:	FALSE
335
 *
336
 * These expand to values suitable for the boolean constants true and false.
337
 *
338
 ** Constant:	EXIT_SUCCESS
339
 ** Constant:	EXIT_FAILURE
340
 *
341
 * These values should be used as arguments to the ``exit'' function to
342
 * indicate success or failure of the program.
343
 *
344
 ** Constant:	UINT_MAX
345
 *
346
 * This is the maximum unsigned integer value.
347
 *
348
 ** Constant:	CHAR_BIT
349
 *
350
 * This is the number of bits in a ``char'' object.
351
 *
352
 ***=== MACROS ===============================================================
353
 *
354
 ** Macro:	FS_NO_FILE_INFO
355
 ** Exceptions:
356
 *
357
 * This macro is defined if ``__FILE__'' or ``__LINE__'' are unsupported.
358
 * They will be defined as macros with some default value in this case, but
359
 * the programmer may wish to do something different.
360
 *
361
 ** Macro:	FS_STDC_HASH
362
 ** Exceptions:
363
 *
364
 * This macro is defined if the ANSI C hash operators (``#'' and ``##'') are
365
 * available.
366
 *
367
 ** Macro:	FS_ENUM
368
 ** Macro:	FS_NO_ENUM
369
 ** Exceptions:
370
 *
371
 * The first of these macros is defined if the compiler supports enumeration
372
 * types.  The second is defined when the first is undefined (and vice-versa).
373
 * Either can (and should) be tested when enumeration types are being defined,
374
 * with integer types and macros being used if enumeration types are not
375
 * supported.
376
 *
377
 ** Macro:	FS_BINARY_STDIO
378
 ** Exceptions:
379
 *
380
 * This macro is defined if ANSI binary input and output is supported
381
 * (i.e. the "b" modifier is allowed in the second argument to ``fopen'').
382
 *
383
 ** Macro:	FS_STRERROR
384
 ** Exceptions:
385
 *
386
 * This macro is defined if the ANSI function ``strerror'' is defined.
387
 *
388
 ** Macro:	FS_SYS_ERRLIST
389
 ** Exceptions:
390
 *
391
 * This macro is defined if the BSD ``sys_nerr'' and ``sys_errlist'' variables
392
 * are defined.  If ``FS_STRERROR'' is defined, then the ``strerror'' function
393
 * should be used in preference to ``sys_nerr'' and ``sys_errlist''.
394
 *
395
 ** Macro:	FS_MKDIR
396
 ** Exceptions:
397
 *
398
 * This macro is defined if the POSIX function ``mkdir'' is defined.
399
 *
400
 ** Macro:	NIL(type)
401
 ** Exceptions:
402
 *
403
 * This is the null pointer macro.  The argument is the type for which a null
404
 * pointer is required.
405
 *
406
 ** Macro:	PROTO_S (prototype)
407
 ** Exceptions:
408
 *
409
 * If prototypes are supported, this expands to the prototyped function
410
 * argument declaration provided.  If they are not supported, it expands to an
411
 * empty argument list.  It is necessary to use two sets of parentheses, as
412
 * the prototype may contain commas.  This macro should be used to declare all
413
 * functions within the program (see the function declarations later on in the
414
 * file for some examples of its use).
415
 *
416
 ** Macro:	PROTO_N (names)
417
 ** Macro:	PROTO_T (types)
418
 ** Macro:	X
419
 ** Macro:	PROTO_Z ()
420
 ** Exceptions:
421
 *
422
 * The "PROTO_N" and "PROTO_T" macros should be used for argument
423
 * specifications when defining functions.  If prototypes are supported, these
424
 * macros expand to a prototyped argument specification; if they are not
425
 * supported, the macros expand to an unprototyped argument specification.
426
 * The "PROTO_N" macro takes a comma separated list of argument names (in a
427
 * similar manner to the "PROTO_S" macro).  The "PROTO_T" macro takes a list
428
 * of declarations for those names, separated by an "X" macro.  If the
429
 * function takes no parameters, then the "PROTO_Z" macro should be used
430
 * instead.  An example of the definition of the ``main'' function in a
431
 * program is:
432
 *
433
 *	int
434
 *	main PROTO_N ((argc, argv))
435
 *	     PROTO_T (int argc X char **argv)
436
 *	{
437
 *	}
438
 *
439
 * An example of the definition of a function with no parameters is:
440
 *
441
 *	void
442
 *	no_args_proc PROTO_Z ()
443
 *	{
444
 *	}
445
 * 
446
 * Other functions should be defined in a similar manner.
447
 *
448
 ** Macro:	UNION
449
 ** Exceptions:
450
 *
451
 * This macro should be used to define union types that need initialisation.
452
 * If union initialisation is supported, it expands to ``union'', otherwise it
453
 * expands to ``struct''.
454
 *
455
 ** Macro:	UB
456
 ** Macro:	UE
457
 ** Exceptions:
458
 *
459
 * These macros should be used to initialise instances of union types that
460
 * need initialisation.  The ``UB'' macro should go before the initialiser,
461
 * and the ``UE'' macro should go after it.
462
 *
463
 ** Macro:	INLINE
464
 ** Exceptions:
465
 *
466
 * This macro may be used before a function to indicate that the function
467
 * should be inlined.  Normally it expands to nothing, however under the GNU C
468
 * compiler it expands to ``__inline__'' which causes the compiler to inline
469
 * the function.
470
 *
471
 ** Macro:	ASSERT (assertion)
472
 ** Exceptions:
473
 *
474
 * This macro causes the program to abort if the assertion provided does not
475
 * hold.  Assertion checking is disabled if the ``FS_FAST'' macro is defined
476
 * or if the ``FS_NO_ASSERT'' macro is defined.  The assertion "ASSERT
477
 * (FALSE);" is used to indicate that the program should never reach the
478
 * current line.
479
 *
480
 ** Macro:	UNUSED (variable)
481
 ** Exceptions:
482
 *
483
 * This macro documents the fact that the specified variable will no longer be
484
 * used.  One use is to indicate function parameters that are not used.  On
485
 * most compilers it will do nothing, but on compilers that support it it will
486
 * tell the compiler that the variable is not expected to be used.
487
 *
488
 ** Macro:	EXHAUSTIVE
489
 ** Exceptions:
490
 *
491
 * This macro documents the fact that the switch statement in which it appears
492
 * is meant to be exhaustive.  It is used as follows:
493
 *
494
 *	switch (expression) EXHAUSTIVE { ... }
495
 *
496
 ** Macro:	UNREACHED
497
 ** Exceptions:
498
 *
499
 * This macro documents the fact that the location that it occurs in should be
500
 * unreachable.
501
 *
502
 ** Macro:	FALL_THROUGH
503
 ** Exceptions:
504
 *
505
 * This macro documents the fact that the current case of a switch statement
506
 * should follow through into the next (immediately following) case.  It is
507
 * used as follows:
508
 *
509
 *	case 1:
510
 *	  ...
511
 *	  FALL_THROUGH;
512
 *	case 2:
513
 *	  ...
514
 *
515
 **** Change Log:
516
 * $Log: os-interface.h,v $
517
 * Revision 1.2  1998/03/16  11:26:27  release
518
 * Modifications prior to version 4.1.2.
519
 *
520
 * Revision 1.1.1.1  1998/01/17  15:57:18  release
521
 * First version to be checked into rolling release.
522
 *
523
 * Revision 1.3  1995/09/08  16:11:39  smf
524
 * Put braces into union initialisation macros (as per ANSI spec).
525
 * Guarded "gcc" builtin functions.
526
 *
527
 * Revision 1.2  1994/12/12  11:45:45  smf
528
 * Performing changes for 'CR94_178.sid+tld-update' - bringing in line with
529
 * OSSG C Coding Standards.
530
 *
531
 * Revision 1.1.1.1  1994/07/25  16:06:11  smf
532
 * Initial import of os-interface shared files.
533
 *
534
**/
535
 
536
/****************************************************************************/
537
 
538
#ifndef H_OS_INTERFACE
539
#define H_OS_INTERFACE
540
 
541
# ifdef FS_NO_SHORTNAMES
542
#  undef FS_SHORTNAMES
543
# endif /* defined (FS_NO_SHORTNAMES) */
544
# ifdef FS_NO_FAST
545
#  undef FS_FAST
546
# endif /* defined (FS_NO_FAST) */
547
# ifdef FS_SHORTNAMES
548
#  include "shortnames.h"
549
#  ifdef FS_FAST
550
#   include "fast-short.h"
551
#   undef FS_FAST
552
#  endif /* defined (FS_FAST) */
553
# endif /* defined (FS_SHORTNAMES) */
554
# ifndef FS_FAST
555
#  define FS_ASSERT
556
# endif /* !defined (FS_FAST) */
557
# ifdef FS_NO_ASSERT
558
#  undef FS_ASSERT
559
# endif /* defined (FS_NO_ASSERT) */
560
 
561
# ifndef FS_NO_STDC
562
#  ifdef __STDC__
563
#   define FS_STDC_HASH
564
#   define FS_PROTOTYPES
565
#   define FS_VOID_PTR
566
#   define FS_VOLATILE
567
#   define FS_CONST
568
#   define FS_UNION_INIT
569
#   define FS_ENUM
570
#   if __STDC__ == 1
571
#    define FS_ANSI_ENVIRON
572
#   endif /* __STDC__ == 1 */
573
#  endif /* defined (__STDC__) */
574
# endif /* !defined (FS_NO_STDC) */
575
 
576
# ifdef FS_NO_FILE_INFO
577
#  define __FILE__ "unknown"
578
#  define __LINE__ 0
579
# endif /* defined (FS_NO_FILE_INFO) */
580
 
581
# ifdef FS_NO_STDC_HASH
582
#  undef FS_STDC_HASH
583
# endif /* defined (FS_NO_STDC_HASH) */
584
 
585
# ifdef FS_NO_PROTOTYPES
586
#  undef FS_PROTOTYPES
587
# endif /* defined (FS_NO_PROTOTYPES) */
588
# ifdef FS_PROTOTYPES
589
#  define PROTO_S(ansi) ansi
590
#  define PROTO_N(names)
591
#  define PROTO_T(types) (types)
592
#  define PROTO_X ,
593
#  define PROTO_Z() (void)
594
# else
595
#  ifdef __TenDRA__
596
#   pragma TenDRA weak prototype analysis on
597
#   pragma TenDRA keyword KW_WEAK for weak
598
#   define PROTO_S(ansi) KW_WEAK ansi
599
#   define PROTO_N(names) names
600
#   define PROTO_T(types) types;
601
#   define PROTO_X ;
602
#   define PROTO_Z() ()
603
#  else
604
#   define PROTO_S(ansi) ()
605
#   define PROTO_N(names) names
606
#   define PROTO_T(types) types;
607
#   define PROTO_X ;
608
#   define PROTO_Z() ()
609
#  endif /* defined (__TenDRA__) */
610
# endif /* defined (FS_PROTOTYPES) */
611
 
612
# ifdef FS_NO_VOID_PTR
613
#  undef FS_VOID_PTR
614
# endif /* defined (FS_NO_VOID_PTR) */
615
# ifdef FS_VOID_PTR
616
typedef void *GenericP;
617
# else
618
typedef char *GenericP;
619
# endif /* defined (FS_VOID_PTR) */
620
 
621
# ifdef FS_NO_VOLATILE
622
#  undef FS_VOLATILE
623
# endif /* defined (FS_NO_VOLATILE) */
624
# ifndef FS_VOLATILE
625
#  define volatile
626
# endif /* !defined (FS_VOLATILE) */
627
 
628
# ifdef FS_NO_CONST
629
#  undef FS_CONST
630
# endif /* defined (FS_NO_CONST) */
631
# ifndef FS_CONST
632
#  define const
633
# endif /* !defined (FS_CONST) */
634
 
635
# ifdef FS_NO_UNION_INIT
636
#  undef FS_UNION_INIT
637
# endif /* defined (FS_NO_UNION_INIT) */
638
# ifdef FS_UNION_INIT
639
#  define UNION union
640
#  define UB {
641
#  define UE }
642
# else
643
#  define UNION struct
644
#  define UB {
645
#  define UE }
646
# endif /* defined (FS_UNION_INIT) */
647
 
648
# ifdef FS_NO_ENUM
649
#  undef FS_ENUM
650
# endif /* defined (FS_NO_ENUM) */
651
# ifndef FS_ENUM
652
#  ifndef FS_NO_ENUM
653
#   define FS_NO_ENUM
654
#  endif /* !defined (FS_NO_ENUM) */
655
# endif /* !defined (FS_ENUM) */
656
 
657
# ifdef FS_NO_ANSI_ENVIRON
658
#  undef FS_ANSI_ENVIRON
659
# endif /* defined (FS_NO_ANSI_ENVIRON) */
660
 
661
# ifdef FS_ANSI_ENVIRON
662
#  define FS_BINARY_STDIO
663
#  define FS_STRERROR
664
# endif /* defined (FS_ANSI_ENVIRON) */
665
# ifdef FS_NO_BINARY_STDIO
666
#  undef FS_BINARY_STDIO
667
# endif /* defined (FS_NO_BINARY_STDIO) */
668
# ifdef FS_NO_STRERROR
669
#  undef FS_STRERROR
670
# endif /* defined (FS_NO_STRERROR) */
671
# ifdef FS_NO_SYS_ERRLIST
672
#  undef FS_SYS_ERRLIST
673
# endif /* defined (FS_NO_SYS_ERRLIST) */
674
# ifdef FS_NO_MKDIR
675
#  undef FS_MKDIR
676
# endif /* defined (FS_NO_MKDIR) */
677
 
678
# ifdef __GNUC__
679
typedef __volatile__ void NoReturnT;
680
# else
681
#  ifdef __TenDRA__
682
#   pragma TenDRA type NoReturnT for bottom
683
#  else
684
#   define NoReturnT void
685
#  endif /* defined (__TenDRA__) */
686
# endif /* defined (__GNUC__) */
687
 
688
# ifdef __TenDRA__
689
#  pragma TenDRA keyword UNUSED for discard variable
690
# else
691
#  define UNUSED(v)
692
# endif /* defined (__TenDRA__) */
693
 
694
typedef char *CStringP;
695
typedef unsigned char ByteT, *ByteP;
696
typedef int BoolT, *BoolP;
697
# ifdef FS_NO_ENUM
698
typedef int CmpT, *CmpP;
699
# define CMP_LT	(0)
700
# define CMP_EQ	(1)
701
# define CMP_GT	(2)
702
# else
703
typedef enum {
704
    CMP_LT,
705
    CMP_EQ,
706
    CMP_GT
707
} CmpT, *CmpP;
708
# endif /* defined (FS_NO_ENUM) */
709
 
710
# define NIL(type) ((type) (0))
711
 
712
# define FALSE (0)
713
# define TRUE (1)
714
 
715
# ifdef __GNUC__
716
#  define INLINE __inline__
717
# else
718
#  define INLINE
719
# endif /* defined (__GNUC__) */
720
 
721
# ifdef FS_MKDIR
722
extern int			mkdir
723
	PROTO_S ((CStringP, int));
724
# endif /* defined (FS_MKDIR) */
725
 
726
# ifdef FS_ASSERT
727
extern void			E_assertion_failed
728
	PROTO_S ((CStringP, CStringP, unsigned));
729
#  ifdef FS_STDC_HASH
730
#   define ASSERT(a) \
731
if (!(a)) { \
732
    E_assertion_failed (#a, __FILE__, (unsigned) __LINE__); \
733
    abort (); \
734
}
735
#  else
736
#   define ASSERT(a) \
737
if (!(a)) { \
738
    E_assertion_failed ("<unavailable>", __FILE__, (unsigned) __LINE__); \
739
    abort (); \
740
}
741
#  endif /* defined (FS_STDC_HASH) */
742
# else
743
#  define ASSERT(a)
744
# endif /* defined (FS_ASSERT) */
745
 
746
# ifdef __TenDRA__
747
#  pragma TenDRA keyword EXHAUSTIVE for exhaustive
748
#  pragma TenDRA keyword FALL_THROUGH for fall into case
749
#  pragma TenDRA keyword UNREACHED for set unreachable
750
# else
751
#  define EXHAUSTIVE
752
#  define FALL_THROUGH
753
#  define UNREACHED ASSERT (FALSE)
754
# endif /* defined (__TenDRA__) */
755
 
756
# ifdef FS_ANSI_ENVIRON
757
#  include <errno.h>
758
#  include <limits.h>
759
#  include <setjmp.h>
760
#  include <stddef.h>
761
#  include <stdio.h>
762
#  include <stdlib.h>
763
#  include <string.h>
764
typedef size_t SizeT, *SizeP;
765
# else
766
 
767
#  ifdef PO_SIZE_T_TYPE
768
typedef PO_SIZE_T_TYPE SizeT, *SizeP;
769
#  else
770
typedef unsigned SizeT, *SizeP;
771
#  endif /* defined (PO_SIZE_T_TYPE) */
772
 
773
extern NoReturnT		abort
774
	PROTO_S ((void));
775
extern GenericP			calloc
776
	PROTO_S ((SizeT, SizeT));
777
extern GenericP			malloc
778
	PROTO_S ((SizeT));
779
extern NoReturnT		exit
780
	PROTO_S ((int));
781
extern void			free
782
	PROTO_S ((GenericP));
783
extern CStringP			getenv
784
	PROTO_S ((CStringP));
785
#  ifndef __GNUC__
786
extern int			memcmp
787
	PROTO_S ((GenericP, GenericP, SizeT));
788
#  endif /* defined (__GNUC__) */
789
#  ifndef __GNUC__
790
extern GenericP			memcpy
791
	PROTO_S ((GenericP, GenericP, SizeT));
792
#  endif /* defined (__GNUC__) */
793
extern GenericP			memset
794
	PROTO_S ((GenericP, int, SizeT));
795
extern GenericP			memchr
796
	PROTO_S ((GenericP, int, SizeT));
797
#  ifndef __GNUC__
798
extern SizeT			strlen
799
	PROTO_S ((CStringP));
800
#  endif /* defined (__GNUC__) */
801
#  ifndef __GNUC__
802
extern int			strcmp
803
	PROTO_S ((CStringP, CStringP));
804
#  endif /* defined (__GNUC__) */
805
#  ifndef __GNUC__
806
extern CStringP			strcpy
807
	PROTO_S ((CStringP, CStringP));
808
#  endif /* defined (__GNUC__) */
809
extern CStringP			strchr
810
	PROTO_S ((CStringP, int));
811
extern CStringP			strrchr
812
	PROTO_S ((CStringP, int));
813
extern int			errno;
814
#  ifdef FS_STRERROR
815
extern CStringP			strerror
816
	PROTO_S ((int));
817
#  endif /* defined (FS_STRERROR) */
818
 
819
#  include <setjmp.h>
820
#  include <stdio.h>
821
 
822
# endif /* !defined (FS_ANSI_ENVIRON) */
823
 
824
#  ifndef CHAR_BIT
825
#   ifdef PO_CHAR_BIT
826
#    define CHAR_BIT PO_CHAR_BIT
827
#   else
828
#    define CHAR_BIT 8
829
#   endif /* defined (PO_CHAR_BIT) */
830
#  endif /* !defined (CHAR_BIT) */
831
 
832
#  ifndef EXIT_SUCCESS
833
#   ifdef PO_EXIT_SUCCESS
834
#    define EXIT_SUCCESS PO_EXIT_SUCCESS
835
#   else
836
#    define EXIT_SUCCESS (0)
837
#   endif /* defined (PO_EXIT_SUCCESS) */
838
#  endif /* !defined (EXIT_SUCCESS) */
839
 
840
#  ifndef EXIT_FAILURE
841
#   ifdef PO_EXIT_FAILURE
842
#    define EXIT_FAILURE PO_EXIT_FAILURE
843
#   else
844
#    define EXIT_FAILURE (1)
845
#   endif /* defined (PO_EXIT_FAILURE) */
846
#  endif /* !defined (EXIT_FAILURE) */
847
 
848
#  ifndef UINT_MAX
849
#   ifdef PO_UINT_MAX
850
#    define UINT_MAX PO_UINT_MAX
851
#   else
852
#    define UINT_MAX (~(unsigned) 0)
853
#   endif /* defined (PO_UINT_MAX) */
854
#  endif /* !defined (UINT_MAX) */
855
 
856
#  ifndef SEEK_SET
857
#   ifdef PO_SEEK_SET
858
#    define SEEK_SET PO_SEEK_SET
859
#   else
860
#    define SEEK_SET (0)
861
#   endif /* defined (PO_SEEK_SET) */
862
#  endif /* !defined (SEEK_SET) */
863
 
864
#  ifndef SEEK_CUR
865
#   ifdef PO_SEEK_CUR
866
#    define SEEK_CUR PO_SEEK_CUR
867
#   else
868
#    define SEEK_CUR (1)
869
#   endif /* defined (PO_SEEK_CUR) */
870
#  endif /* !defined (SEEK_CUR) */
871
 
872
#  ifndef SEEK_END
873
#   ifdef PO_SEEK_END
874
#    define SEEK_END PO_SEEK_END
875
#   else
876
#    define SEEK_END (2)
877
#   endif /* defined (PO_SEEK_END) */
878
#  endif /* !defined (SEEK_END) */
879
 
880
# ifdef FS_SYS_ERRLIST
881
extern int			sys_nerr;
882
extern CStringP			sys_errlist [];
883
# endif /* defined (FS_SYS_ERRLIST) */
884
 
885
# ifdef X
886
# undef X
887
# endif
888
# define X PROTO_X
889
 
890
#endif /* !defined (H_OS_INTERFACE) */