Warning: Attempt to read property "date" on null in /usr/local/www/websvn.planix.org/blame.php on line 247

Warning: Attempt to read property "msg" on null in /usr/local/www/websvn.planix.org/blame.php on line 247
WebSVN – tendra.SVN – Blame – /branches/tendra5-amd64/src/utilities/sid/os-interface.h – Rev 5

Subversion Repositories tendra.SVN

Rev

Go to most recent revision | Details | 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.3  1998/03/16  11:26:35  release
518
 * Modifications prior to version 4.1.2.
519
 *
520
 * Revision 1.2  1998/02/04  10:46:57  release
521
 * Changes during testing.
522
 *
523
 * Revision 1.1.1.1  1998/01/17  15:57:45  release
524
 * First version to be checked into rolling release.
525
 *
526
 * Revision 1.3  1995/09/08  16:11:39  smf
527
 * Put braces into union initialisation macros (as per ANSI spec).
528
 * Guarded "gcc" builtin functions.
529
 *
530
 * Revision 1.2  1994/12/12  11:45:45  smf
531
 * Performing changes for 'CR94_178.sid+tld-update' - bringing in line with
532
 * OSSG C Coding Standards.
533
 *
534
 * Revision 1.1.1.1  1994/07/25  16:06:11  smf
535
 * Initial import of os-interface shared files.
536
 *
537
**/
538
 
539
/****************************************************************************/
540
 
541
#ifndef H_OS_INTERFACE
542
#define H_OS_INTERFACE
543
 
544
# ifdef FS_NO_SHORTNAMES
545
#  undef FS_SHORTNAMES
546
# endif /* defined (FS_NO_SHORTNAMES) */
547
# ifdef FS_NO_FAST
548
#  undef FS_FAST
549
# endif /* defined (FS_NO_FAST) */
550
# ifdef FS_SHORTNAMES
551
#  include "shortnames.h"
552
#  ifdef FS_FAST
553
#   include "fast-short.h"
554
#   undef FS_FAST
555
#  endif /* defined (FS_FAST) */
556
# endif /* defined (FS_SHORTNAMES) */
557
# ifndef FS_FAST
558
#  define FS_ASSERT
559
# endif /* !defined (FS_FAST) */
560
# ifdef FS_NO_ASSERT
561
#  undef FS_ASSERT
562
# endif /* defined (FS_NO_ASSERT) */
563
 
564
# ifndef FS_NO_STDC
565
#  ifdef __STDC__
566
#   define FS_STDC_HASH
567
#   define FS_PROTOTYPES
568
#   define FS_VOID_PTR
569
#   define FS_VOLATILE
570
#   define FS_CONST
571
#   define FS_UNION_INIT
572
#   define FS_ENUM
573
#   if __STDC__ == 1
574
#    define FS_ANSI_ENVIRON
575
#   endif /* __STDC__ == 1 */
576
#  endif /* defined (__STDC__) */
577
# endif /* !defined (FS_NO_STDC) */
578
 
579
# ifdef FS_NO_FILE_INFO
580
#  define __FILE__ "unknown"
581
#  define __LINE__ 0
582
# endif /* defined (FS_NO_FILE_INFO) */
583
 
584
# ifdef FS_NO_STDC_HASH
585
#  undef FS_STDC_HASH
586
# endif /* defined (FS_NO_STDC_HASH) */
587
 
588
# ifdef FS_NO_PROTOTYPES
589
#  undef FS_PROTOTYPES
590
# endif /* defined (FS_NO_PROTOTYPES) */
591
# ifdef FS_PROTOTYPES
592
#  define PROTO_S(ansi) ansi
593
#  define PROTO_N(names)
594
#  define PROTO_T(types) (types)
595
#  define PROTO_X ,
596
#  define PROTO_Z() (void)
597
# else
598
#  ifdef __TenDRA__
599
#   pragma TenDRA weak prototype analysis on
600
#   pragma TenDRA keyword KW_WEAK for weak
601
#   define PROTO_S(ansi) KW_WEAK ansi
602
#   define PROTO_N(names) names
603
#   define PROTO_T(types) types;
604
#   define PROTO_X ;
605
#   define PROTO_Z() ()
606
#  else
607
#   define PROTO_S(ansi) ()
608
#   define PROTO_N(names) names
609
#   define PROTO_T(types) types;
610
#   define PROTO_X ;
611
#   define PROTO_Z() ()
612
#  endif /* defined (__TenDRA__) */
613
# endif /* defined (FS_PROTOTYPES) */
614
 
615
# ifdef FS_NO_VOID_PTR
616
#  undef FS_VOID_PTR
617
# endif /* defined (FS_NO_VOID_PTR) */
618
# ifdef FS_VOID_PTR
619
typedef void *GenericP;
620
# else
621
typedef char *GenericP;
622
# endif /* defined (FS_VOID_PTR) */
623
 
624
# ifdef FS_NO_VOLATILE
625
#  undef FS_VOLATILE
626
# endif /* defined (FS_NO_VOLATILE) */
627
# ifndef FS_VOLATILE
628
#  define volatile
629
# endif /* !defined (FS_VOLATILE) */
630
 
631
# ifdef FS_NO_CONST
632
#  undef FS_CONST
633
# endif /* defined (FS_NO_CONST) */
634
# ifndef FS_CONST
635
#  define const
636
# endif /* !defined (FS_CONST) */
637
 
638
# ifdef FS_NO_UNION_INIT
639
#  undef FS_UNION_INIT
640
# endif /* defined (FS_NO_UNION_INIT) */
641
# ifdef FS_UNION_INIT
642
#  define UNION union
643
#  define UB {
644
#  define UE }
645
# else
646
#  define UNION struct
647
#  define UB {
648
#  define UE }
649
# endif /* defined (FS_UNION_INIT) */
650
 
651
# ifdef FS_NO_ENUM
652
#  undef FS_ENUM
653
# endif /* defined (FS_NO_ENUM) */
654
# ifndef FS_ENUM
655
#  ifndef FS_NO_ENUM
656
#   define FS_NO_ENUM
657
#  endif /* !defined (FS_NO_ENUM) */
658
# endif /* !defined (FS_ENUM) */
659
 
660
# ifdef FS_NO_ANSI_ENVIRON
661
#  undef FS_ANSI_ENVIRON
662
# endif /* defined (FS_NO_ANSI_ENVIRON) */
663
 
664
# ifdef FS_ANSI_ENVIRON
665
#  define FS_BINARY_STDIO
666
#  define FS_STRERROR
667
# endif /* defined (FS_ANSI_ENVIRON) */
668
# ifdef FS_NO_BINARY_STDIO
669
#  undef FS_BINARY_STDIO
670
# endif /* defined (FS_NO_BINARY_STDIO) */
671
# ifdef FS_NO_STRERROR
672
#  undef FS_STRERROR
673
# endif /* defined (FS_NO_STRERROR) */
674
# ifdef FS_NO_SYS_ERRLIST
675
#  undef FS_SYS_ERRLIST
676
# endif /* defined (FS_NO_SYS_ERRLIST) */
677
# ifdef FS_NO_MKDIR
678
#  undef FS_MKDIR
679
# endif /* defined (FS_NO_MKDIR) */
680
 
681
# ifdef __GNUC__
682
typedef __volatile__ void NoReturnT;
683
# else
684
#  ifdef __TenDRA__
685
#   pragma TenDRA type NoReturnT for bottom
686
#  else
687
#   define NoReturnT void
688
#  endif /* defined (__TenDRA__) */
689
# endif /* defined (__GNUC__) */
690
 
691
# ifdef __TenDRA__
692
#  pragma TenDRA keyword UNUSED for discard variable
693
# else
694
#  define UNUSED(v)
695
# endif /* defined (__TenDRA__) */
696
 
697
typedef char *CStringP;
698
typedef unsigned char ByteT, *ByteP;
699
typedef int BoolT, *BoolP;
700
# ifdef FS_NO_ENUM
701
typedef int CmpT, *CmpP;
702
# define CMP_LT	(0)
703
# define CMP_EQ	(1)
704
# define CMP_GT	(2)
705
# else
706
typedef enum {
707
    CMP_LT,
708
    CMP_EQ,
709
    CMP_GT
710
} CmpT, *CmpP;
711
# endif /* defined (FS_NO_ENUM) */
712
 
713
# define NIL(type) ((type) (0))
714
 
715
# define FALSE (0)
716
# define TRUE (1)
717
 
718
# ifdef __GNUC__
719
#  define INLINE __inline__
720
# else
721
#  define INLINE
722
# endif /* defined (__GNUC__) */
723
 
724
# ifdef FS_MKDIR
725
extern int			mkdir
726
	PROTO_S ((CStringP, int));
727
# endif /* defined (FS_MKDIR) */
728
 
729
# ifdef FS_ASSERT
730
extern void			E_assertion_failed
731
	PROTO_S ((CStringP, CStringP, unsigned));
732
#  ifdef FS_STDC_HASH
733
#   define ASSERT(a) \
734
if (!(a)) { \
735
    E_assertion_failed (#a, __FILE__, (unsigned) __LINE__); \
736
    abort (); \
737
}
738
#  else
739
#   define ASSERT(a) \
740
if (!(a)) { \
741
    E_assertion_failed ("<unavailable>", __FILE__, (unsigned) __LINE__); \
742
    abort (); \
743
}
744
#  endif /* defined (FS_STDC_HASH) */
745
# else
746
#  define ASSERT(a)
747
# endif /* defined (FS_ASSERT) */
748
 
749
# ifdef __TenDRA__
750
#  pragma TenDRA keyword EXHAUSTIVE for exhaustive
751
#  pragma TenDRA keyword FALL_THROUGH for fall into case
752
#  pragma TenDRA keyword UNREACHED for set unreachable
753
# else
754
#  define EXHAUSTIVE
755
#  define FALL_THROUGH
756
#  define UNREACHED ASSERT (FALSE)
757
# endif /* defined (__TenDRA__) */
758
 
759
# ifdef FS_ANSI_ENVIRON
760
#  include <errno.h>
761
#  include <limits.h>
762
#  include <setjmp.h>
763
#  include <stddef.h>
764
#  include <stdio.h>
765
#  include <stdlib.h>
766
#  include <string.h>
767
typedef size_t SizeT, *SizeP;
768
# else
769
 
770
#  ifdef PO_SIZE_T_TYPE
771
typedef PO_SIZE_T_TYPE SizeT, *SizeP;
772
#  else
773
typedef unsigned SizeT, *SizeP;
774
#  endif /* defined (PO_SIZE_T_TYPE) */
775
 
776
extern NoReturnT		abort
777
	PROTO_S ((void));
778
extern GenericP			calloc
779
	PROTO_S ((SizeT, SizeT));
780
extern GenericP			malloc
781
	PROTO_S ((SizeT));
782
extern NoReturnT		exit
783
	PROTO_S ((int));
784
extern void			free
785
	PROTO_S ((GenericP));
786
extern CStringP			getenv
787
	PROTO_S ((CStringP));
788
#  ifndef __GNUC__
789
extern int			memcmp
790
	PROTO_S ((GenericP, GenericP, SizeT));
791
#  endif /* defined (__GNUC__) */
792
#  ifndef __GNUC__
793
extern GenericP			memcpy
794
	PROTO_S ((GenericP, GenericP, SizeT));
795
#  endif /* defined (__GNUC__) */
796
extern GenericP			memset
797
	PROTO_S ((GenericP, int, SizeT));
798
extern GenericP			memchr
799
	PROTO_S ((GenericP, int, SizeT));
800
#  ifndef __GNUC__
801
extern SizeT			strlen
802
	PROTO_S ((CStringP));
803
#  endif /* defined (__GNUC__) */
804
#  ifndef __GNUC__
805
extern int			strcmp
806
	PROTO_S ((CStringP, CStringP));
807
#  endif /* defined (__GNUC__) */
808
#  ifndef __GNUC__
809
extern int			strncmp
810
	PROTO_S ((CStringP, CStringP, SizeT));
811
#  endif /* defined (__GNUC__) */
812
#  ifndef __GNUC__
813
extern CStringP			strcpy
814
	PROTO_S ((CStringP, CStringP));
815
#  endif /* defined (__GNUC__) */
816
extern CStringP			strchr
817
	PROTO_S ((CStringP, int));
818
extern CStringP			strrchr
819
	PROTO_S ((CStringP, int));
820
extern int			errno;
821
#  ifdef FS_STRERROR
822
extern CStringP			strerror
823
	PROTO_S ((int));
824
#  endif /* defined (FS_STRERROR) */
825
 
826
#  include <setjmp.h>
827
#  include <stdio.h>
828
 
829
# endif /* !defined (FS_ANSI_ENVIRON) */
830
 
831
# ifndef CHAR_BIT
832
#  ifdef PO_CHAR_BIT
833
#   define CHAR_BIT PO_CHAR_BIT
834
#  else
835
#   define CHAR_BIT 8
836
#  endif /* defined (PO_CHAR_BIT) */
837
# endif /* !defined (CHAR_BIT) */
838
 
839
# ifndef EXIT_SUCCESS
840
#  ifdef PO_EXIT_SUCCESS
841
#   define EXIT_SUCCESS PO_EXIT_SUCCESS
842
#  else
843
#   define EXIT_SUCCESS (0)
844
#  endif /* defined (PO_EXIT_SUCCESS) */
845
# endif /* !defined (EXIT_SUCCESS) */
846
 
847
# ifndef EXIT_FAILURE
848
#  ifdef PO_EXIT_FAILURE
849
#   define EXIT_FAILURE PO_EXIT_FAILURE
850
#  else
851
#   define EXIT_FAILURE (1)
852
#  endif /* defined (PO_EXIT_FAILURE) */
853
# endif /* !defined (EXIT_FAILURE) */
854
 
855
# ifndef UINT_MAX
856
#  ifdef PO_UINT_MAX
857
#   define UINT_MAX PO_UINT_MAX
858
#  else
859
#   define UINT_MAX (~(unsigned) 0)
860
#  endif /* defined (PO_UINT_MAX) */
861
# endif /* !defined (UINT_MAX) */
862
 
863
# ifndef SEEK_SET
864
#  ifdef PO_SEEK_SET
865
#   define SEEK_SET PO_SEEK_SET
866
#  else
867
#   define SEEK_SET (0)
868
#  endif /* defined (PO_SEEK_SET) */
869
# endif /* !defined (SEEK_SET) */
870
 
871
# ifndef SEEK_CUR
872
#  ifdef PO_SEEK_CUR
873
#   define SEEK_CUR PO_SEEK_CUR
874
#  else
875
#   define SEEK_CUR (1)
876
#  endif /* defined (PO_SEEK_CUR) */
877
# endif /* !defined (SEEK_CUR) */
878
 
879
# ifndef SEEK_END
880
#  ifdef PO_SEEK_END
881
#   define SEEK_END PO_SEEK_END
882
#  else
883
#   define SEEK_END (2)
884
#  endif /* defined (PO_SEEK_END) */
885
# endif /* !defined (SEEK_END) */
886
 
887
# ifdef FS_SYS_ERRLIST
888
extern int			sys_nerr;
889
extern CStringP			sys_errlist [];
890
# endif /* defined (FS_SYS_ERRLIST) */
891
 
892
# ifdef X
893
# undef X
894
# endif
895
# define X PROTO_X
896
 
897
#endif /* !defined (H_OS_INTERFACE) */