Subversion Repositories tendra.SVN

Rev

Rev 2 | 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
 *
7 7u83 199
 *	void E_assertion_failed(CStringP, CStringP, unsigned)
2 7u83 200
 *
201
 * This function will be called if an assertion fails.  It will be called with
202
 * the text of the assertion, the name of the file in which the assertion was
203
 * written, and line on which it occured.
204
 *
205
 ***=== FROM ANSI ============================================================
206
 *
207
 * The following ANSI C functions are declared:
208
 *
209
 *	NoReturnT			abort
7 7u83 210
 *			(void)
2 7u83 211
 *	GenericP			calloc
7 7u83 212
 *			(SizeT length, SizeT size)
2 7u83 213
 *	GenericP			malloc
7 7u83 214
 *			(SizeT size)
2 7u83 215
 *	NoReturnT			exit
7 7u83 216
 *			(int exit_code)
2 7u83 217
 *	void				free
7 7u83 218
 *			(GenericP pointer)
2 7u83 219
 *	CStringP			getenv
7 7u83 220
 *			(CStringP name)
2 7u83 221
 *	int				memcmp
7 7u83 222
 *			(GenericP ptr1, GenericP ptr2, SizeT length)
2 7u83 223
 *	GenericP			memcpy
7 7u83 224
 *			(GenericP to, GenericP from, SizeT length)
2 7u83 225
 *	GenericP			memset
7 7u83 226
 *			(GenericP ptr, int val, SizeT length)
2 7u83 227
 *	GenericP			memchr
7 7u83 228
 *			(GenericP ptr, int val, SizeT length)
2 7u83 229
 *	SizeT				strlen
7 7u83 230
 *			(CStringP string)
2 7u83 231
 *	int				strcmp
7 7u83 232
 *			(CStringP string1, CStringP string2)
2 7u83 233
 *	CStringP			strcpy
7 7u83 234
 *			(CStringP to, CStringP from)
2 7u83 235
 *	CStringP			strchr
7 7u83 236
 *			(CStringP string, int c)
2 7u83 237
 *	CStringP			strrchr
7 7u83 238
 *			(CStringP string, int c)
2 7u83 239
 *
240
 * Also everything in <setjmp.h> and <stdio.h> is included (hopefully this is
241
 * sufficiently common to be used even on non-ANSI platforms).  Where features
242
 * are absent on non-ANSI systems, support for them will need to be added.
243
 *
244
 ***=== FUNCTIONS ============================================================
245
 *
246
 ** Function:	int			mkdir
7 7u83 247
 *			(CStringP path, int mode)
2 7u83 248
 ** Exceptions:
249
 *
250
 * This function is only declared if the ``FS_MKDIR'' macro is defined.  This
251
 * macro should also be tested before the function is used anywhere.  It is
252
 * the POSIX directory creation function.
253
 *
254
 ** Function:	CStringP		strerror
7 7u83 255
 *			(int error)
2 7u83 256
 ** Exceptions:
257
 *
258
 * This function is only declared if the ``FS_STRERROR'' macro is defined.
259
 * This macro should also be tested before the function is used anywhere.  It
260
 * is the ANSI function for obtaining a textual description of a system error
261
 * message.
262
 *
263
 ***=== VARIABLES ============================================================
264
 *
265
 ** Variable:	int			sys_nerr
266
 *
267
 * This variable is only declared if the ``FS_SYS_ERRLIST'' macro is defined.
268
 * It contains the number of error messages stored in the ``sys_errlist''
269
 * vector.
270
 *
271
 ** Variable:	CStringP		sys_errlist []
272
 *
273
 * This variable is only declared if the ``FS_SYS_ERRLIST'' macro is defined.
274
 * It contains the text of the system error messages.
275
 *
276
 ** Variable:	int			errno
277
 *
278
 * This variable contains the number of the current system error.
279
 *
280
 ***=== TYPES ================================================================
281
 *
282
 ** Type:	GenericP
283
 ** Repr:	void *
284
 *
285
 * This is the generic pointer type.  It can be used to store a pointer to any
286
 * non-function object.
287
 *
288
 ** Type:	NoReturnT
289
 ** Repr:	void
290
 *
291
 * This is the return type of a function that doesn't return (e.g.
292
 * ``longjmp'').  Normally this is just ``void'', however the GNU C compiler
293
 * can produce better code if this is declared as ``__volatile__ void''.  The
294
 * TenDRA compiler can be told that a function doesn't return as well.
295
 *
296
 ** Type:	SizeT
297
 ** Type:	SizeP
298
 ** Repr:	size_t
299
 *
300
 * This is the type of the return value of the "sizeof" operator.
301
 *
302
 ** Type:	CStringP
303
 ** Repr:	char *
304
 *
305
 * This is the C string type.  It is defined here to avoid a circularity in
306
 * the "os-interface" directory.  Other directories should access it via the
307
 * "cstring.h" file.
308
 *
309
 ** Type:	ByteT
310
 ** Type:	ByteP
311
 ** Repr:	unsigned char
312
 *
313
 * This is the byte type.  It is possible that this could be larger than a
314
 * byte in some implementations.
315
 *
316
 ** Type:	BoolT
317
 ** Type:	BoolP
318
 ** Repr:	int
319
 *
320
 * This is the boolean type.
321
 *
322
 ** Type:	CmpT
323
 ** Type:	CmpP
324
 ** Repr:	enum {CMP_LT, CMP_EQ, CMP_GT}
325
 *
326
 * This is the type returned by comparison functions.  The values represent
327
 * the fact that the first argument is less than, equal to, or greater than
328
 * the second argument respectively.
329
 *
330
 ***=== CONSTANTS ============================================================
331
 *
332
 ** Constant:	TRUE
333
 ** Constant:	FALSE
334
 *
335
 * These expand to values suitable for the boolean constants true and false.
336
 *
337
 ** Constant:	EXIT_SUCCESS
338
 ** Constant:	EXIT_FAILURE
339
 *
340
 * These values should be used as arguments to the ``exit'' function to
341
 * indicate success or failure of the program.
342
 *
343
 ** Constant:	UINT_MAX
344
 *
345
 * This is the maximum unsigned integer value.
346
 *
347
 ** Constant:	CHAR_BIT
348
 *
349
 * This is the number of bits in a ``char'' object.
350
 *
351
 ***=== MACROS ===============================================================
352
 *
353
 ** Macro:	FS_NO_FILE_INFO
354
 ** Exceptions:
355
 *
356
 * This macro is defined if ``__FILE__'' or ``__LINE__'' are unsupported.
357
 * They will be defined as macros with some default value in this case, but
358
 * the programmer may wish to do something different.
359
 *
360
 ** Macro:	FS_STDC_HASH
361
 ** Exceptions:
362
 *
363
 * This macro is defined if the ANSI C hash operators (``#'' and ``##'') are
364
 * available.
365
 *
366
 ** Macro:	FS_ENUM
367
 ** Macro:	FS_NO_ENUM
368
 ** Exceptions:
369
 *
370
 * The first of these macros is defined if the compiler supports enumeration
371
 * types.  The second is defined when the first is undefined (and vice-versa).
372
 * Either can (and should) be tested when enumeration types are being defined,
373
 * with integer types and macros being used if enumeration types are not
374
 * supported.
375
 *
376
 ** Macro:	FS_BINARY_STDIO
377
 ** Exceptions:
378
 *
379
 * This macro is defined if ANSI binary input and output is supported
380
 * (i.e. the "b" modifier is allowed in the second argument to ``fopen'').
381
 *
382
 ** Macro:	FS_STRERROR
383
 ** Exceptions:
384
 *
385
 * This macro is defined if the ANSI function ``strerror'' is defined.
386
 *
387
 ** Macro:	FS_SYS_ERRLIST
388
 ** Exceptions:
389
 *
390
 * This macro is defined if the BSD ``sys_nerr'' and ``sys_errlist'' variables
391
 * are defined.  If ``FS_STRERROR'' is defined, then the ``strerror'' function
392
 * should be used in preference to ``sys_nerr'' and ``sys_errlist''.
393
 *
394
 ** Macro:	FS_MKDIR
395
 ** Exceptions:
396
 *
397
 * This macro is defined if the POSIX function ``mkdir'' is defined.
398
 *
399
 ** Macro:	NIL(type)
400
 ** Exceptions:
401
 *
402
 * This is the null pointer macro.  The argument is the type for which a null
403
 * pointer is required.
404
 *
405
 ** Macro:	UNION
406
 ** Exceptions:
407
 *
408
 * This macro should be used to define union types that need initialisation.
409
 * If union initialisation is supported, it expands to ``union'', otherwise it
410
 * expands to ``struct''.
411
 *
412
 ** Macro:	UB
413
 ** Macro:	UE
414
 ** Exceptions:
415
 *
416
 * These macros should be used to initialise instances of union types that
417
 * need initialisation.  The ``UB'' macro should go before the initialiser,
418
 * and the ``UE'' macro should go after it.
419
 *
420
 ** Macro:	INLINE
421
 ** Exceptions:
422
 *
423
 * This macro may be used before a function to indicate that the function
424
 * should be inlined.  Normally it expands to nothing, however under the GNU C
425
 * compiler it expands to ``__inline__'' which causes the compiler to inline
426
 * the function.
427
 *
428
 ** Macro:	ASSERT (assertion)
429
 ** Exceptions:
430
 *
431
 * This macro causes the program to abort if the assertion provided does not
432
 * hold.  Assertion checking is disabled if the ``FS_FAST'' macro is defined
433
 * or if the ``FS_NO_ASSERT'' macro is defined.  The assertion "ASSERT
434
 * (FALSE);" is used to indicate that the program should never reach the
435
 * current line.
436
 *
437
 ** Macro:	UNUSED (variable)
438
 ** Exceptions:
439
 *
440
 * This macro documents the fact that the specified variable will no longer be
441
 * used.  One use is to indicate function parameters that are not used.  On
442
 * most compilers it will do nothing, but on compilers that support it it will
443
 * tell the compiler that the variable is not expected to be used.
444
 *
445
 ** Macro:	EXHAUSTIVE
446
 ** Exceptions:
447
 *
448
 * This macro documents the fact that the switch statement in which it appears
449
 * is meant to be exhaustive.  It is used as follows:
450
 *
451
 *	switch (expression) EXHAUSTIVE { ... }
452
 *
453
 ** Macro:	UNREACHED
454
 ** Exceptions:
455
 *
456
 * This macro documents the fact that the location that it occurs in should be
457
 * unreachable.
458
 *
459
 ** Macro:	FALL_THROUGH
460
 ** Exceptions:
461
 *
462
 * This macro documents the fact that the current case of a switch statement
463
 * should follow through into the next (immediately following) case.  It is
464
 * used as follows:
465
 *
466
 *	case 1:
467
 *	  ...
468
 *	  FALL_THROUGH;
469
 *	case 2:
470
 *	  ...
471
 *
472
 **** Change Log:
473
 * $Log: os-interface.h,v $
474
 * Revision 1.2  1998/03/16  11:26:27  release
475
 * Modifications prior to version 4.1.2.
476
 *
477
 * Revision 1.1.1.1  1998/01/17  15:57:18  release
478
 * First version to be checked into rolling release.
479
 *
480
 * Revision 1.3  1995/09/08  16:11:39  smf
481
 * Put braces into union initialisation macros (as per ANSI spec).
482
 * Guarded "gcc" builtin functions.
483
 *
484
 * Revision 1.2  1994/12/12  11:45:45  smf
485
 * Performing changes for 'CR94_178.sid+tld-update' - bringing in line with
486
 * OSSG C Coding Standards.
487
 *
488
 * Revision 1.1.1.1  1994/07/25  16:06:11  smf
489
 * Initial import of os-interface shared files.
490
 *
491
**/
492
 
493
/****************************************************************************/
494
 
495
#ifndef H_OS_INTERFACE
496
#define H_OS_INTERFACE
497
 
498
# ifdef FS_NO_SHORTNAMES
499
#  undef FS_SHORTNAMES
500
# endif /* defined (FS_NO_SHORTNAMES) */
501
# ifdef FS_NO_FAST
502
#  undef FS_FAST
503
# endif /* defined (FS_NO_FAST) */
504
# ifdef FS_SHORTNAMES
505
#  include "shortnames.h"
506
#  ifdef FS_FAST
507
#   include "fast-short.h"
508
#   undef FS_FAST
509
#  endif /* defined (FS_FAST) */
510
# endif /* defined (FS_SHORTNAMES) */
511
# ifndef FS_FAST
512
#  define FS_ASSERT
513
# endif /* !defined (FS_FAST) */
514
# ifdef FS_NO_ASSERT
515
#  undef FS_ASSERT
516
# endif /* defined (FS_NO_ASSERT) */
517
 
518
# ifndef FS_NO_STDC
519
#  ifdef __STDC__
520
#   define FS_STDC_HASH
521
#   define FS_PROTOTYPES
522
#   define FS_VOID_PTR
523
#   define FS_VOLATILE
524
#   define FS_CONST
525
#   define FS_UNION_INIT
526
#   define FS_ENUM
527
#   if __STDC__ == 1
528
#    define FS_ANSI_ENVIRON
529
#   endif /* __STDC__ == 1 */
530
#  endif /* defined (__STDC__) */
531
# endif /* !defined (FS_NO_STDC) */
532
 
533
# ifdef FS_NO_FILE_INFO
534
#  define __FILE__ "unknown"
535
#  define __LINE__ 0
536
# endif /* defined (FS_NO_FILE_INFO) */
537
 
538
# ifdef FS_NO_STDC_HASH
539
#  undef FS_STDC_HASH
540
# endif /* defined (FS_NO_STDC_HASH) */
541
 
542
# ifdef FS_NO_VOID_PTR
543
#  undef FS_VOID_PTR
544
# endif /* defined (FS_NO_VOID_PTR) */
545
# ifdef FS_VOID_PTR
546
typedef void *GenericP;
547
# else
548
typedef char *GenericP;
549
# endif /* defined (FS_VOID_PTR) */
550
 
551
# ifdef FS_NO_VOLATILE
552
#  undef FS_VOLATILE
553
# endif /* defined (FS_NO_VOLATILE) */
554
# ifndef FS_VOLATILE
555
#  define volatile
556
# endif /* !defined (FS_VOLATILE) */
557
 
558
# ifdef FS_NO_CONST
559
#  undef FS_CONST
560
# endif /* defined (FS_NO_CONST) */
561
# ifndef FS_CONST
562
#  define const
563
# endif /* !defined (FS_CONST) */
564
 
565
# ifdef FS_NO_UNION_INIT
566
#  undef FS_UNION_INIT
567
# endif /* defined (FS_NO_UNION_INIT) */
568
# ifdef FS_UNION_INIT
569
#  define UNION union
570
#  define UB {
571
#  define UE }
572
# else
573
#  define UNION struct
574
#  define UB {
575
#  define UE }
576
# endif /* defined (FS_UNION_INIT) */
577
 
578
# ifdef FS_NO_ENUM
579
#  undef FS_ENUM
580
# endif /* defined (FS_NO_ENUM) */
581
# ifndef FS_ENUM
582
#  ifndef FS_NO_ENUM
583
#   define FS_NO_ENUM
584
#  endif /* !defined (FS_NO_ENUM) */
585
# endif /* !defined (FS_ENUM) */
586
 
587
# ifdef FS_NO_ANSI_ENVIRON
588
#  undef FS_ANSI_ENVIRON
589
# endif /* defined (FS_NO_ANSI_ENVIRON) */
590
 
591
# ifdef FS_ANSI_ENVIRON
592
#  define FS_BINARY_STDIO
593
#  define FS_STRERROR
594
# endif /* defined (FS_ANSI_ENVIRON) */
595
# ifdef FS_NO_BINARY_STDIO
596
#  undef FS_BINARY_STDIO
597
# endif /* defined (FS_NO_BINARY_STDIO) */
598
# ifdef FS_NO_STRERROR
599
#  undef FS_STRERROR
600
# endif /* defined (FS_NO_STRERROR) */
601
# ifdef FS_NO_SYS_ERRLIST
602
#  undef FS_SYS_ERRLIST
603
# endif /* defined (FS_NO_SYS_ERRLIST) */
604
# ifdef FS_NO_MKDIR
605
#  undef FS_MKDIR
606
# endif /* defined (FS_NO_MKDIR) */
607
 
608
# ifdef __GNUC__
7 7u83 609
typedef void NoReturnT;
2 7u83 610
# else
611
#  ifdef __TenDRA__
612
#   pragma TenDRA type NoReturnT for bottom
613
#  else
614
#   define NoReturnT void
615
#  endif /* defined (__TenDRA__) */
616
# endif /* defined (__GNUC__) */
617
 
618
# ifdef __TenDRA__
619
#  pragma TenDRA keyword UNUSED for discard variable
620
# else
621
#  define UNUSED(v)
622
# endif /* defined (__TenDRA__) */
623
 
624
typedef char *CStringP;
625
typedef unsigned char ByteT, *ByteP;
626
typedef int BoolT, *BoolP;
627
# ifdef FS_NO_ENUM
628
typedef int CmpT, *CmpP;
629
# define CMP_LT	(0)
630
# define CMP_EQ	(1)
631
# define CMP_GT	(2)
632
# else
633
typedef enum {
634
    CMP_LT,
635
    CMP_EQ,
636
    CMP_GT
637
} CmpT, *CmpP;
638
# endif /* defined (FS_NO_ENUM) */
639
 
640
# define NIL(type) ((type) (0))
641
 
642
# define FALSE (0)
643
# define TRUE (1)
644
 
645
# ifdef __GNUC__
646
#  define INLINE __inline__
647
# else
648
#  define INLINE
649
# endif /* defined (__GNUC__) */
650
 
651
# ifdef FS_MKDIR
652
extern int			mkdir
7 7u83 653
	(CStringP, int);
2 7u83 654
# endif /* defined (FS_MKDIR) */
655
 
656
# ifdef FS_ASSERT
657
extern void			E_assertion_failed
7 7u83 658
	(CStringP, CStringP, unsigned);
2 7u83 659
#  ifdef FS_STDC_HASH
660
#   define ASSERT(a) \
661
if (!(a)) { \
662
    E_assertion_failed (#a, __FILE__, (unsigned) __LINE__); \
663
    abort (); \
664
}
665
#  else
666
#   define ASSERT(a) \
667
if (!(a)) { \
668
    E_assertion_failed ("<unavailable>", __FILE__, (unsigned) __LINE__); \
669
    abort (); \
670
}
671
#  endif /* defined (FS_STDC_HASH) */
672
# else
673
#  define ASSERT(a)
674
# endif /* defined (FS_ASSERT) */
675
 
676
# ifdef __TenDRA__
677
#  pragma TenDRA keyword EXHAUSTIVE for exhaustive
678
#  pragma TenDRA keyword FALL_THROUGH for fall into case
679
#  pragma TenDRA keyword UNREACHED for set unreachable
680
# else
681
#  define EXHAUSTIVE
682
#  define FALL_THROUGH
683
#  define UNREACHED ASSERT (FALSE)
684
# endif /* defined (__TenDRA__) */
685
 
686
# ifdef FS_ANSI_ENVIRON
687
#  include <errno.h>
688
#  include <limits.h>
689
#  include <setjmp.h>
690
#  include <stddef.h>
691
#  include <stdio.h>
692
#  include <stdlib.h>
693
#  include <string.h>
694
typedef size_t SizeT, *SizeP;
695
# else
696
 
697
#  ifdef PO_SIZE_T_TYPE
698
typedef PO_SIZE_T_TYPE SizeT, *SizeP;
699
#  else
700
typedef unsigned SizeT, *SizeP;
701
#  endif /* defined (PO_SIZE_T_TYPE) */
702
 
7 7u83 703
extern NoReturnT abort(void);
704
extern GenericP calloc(SizeT, SizeT);
705
extern GenericP	malloc(SizeT);
706
extern NoReturnT exit(int);
707
extern void free(GenericP);
708
extern CStringP	getenv(CStringP);
2 7u83 709
#  ifndef __GNUC__
7 7u83 710
extern int memcmp(GenericP, GenericP, SizeT);
2 7u83 711
#  endif /* defined (__GNUC__) */
712
#  ifndef __GNUC__
7 7u83 713
extern GenericP	memcpy(GenericP, GenericP, SizeT);
2 7u83 714
#  endif /* defined (__GNUC__) */
7 7u83 715
extern GenericP	memset(GenericP, int, SizeT);
716
extern GenericP memchr(GenericP, int, SizeT);
2 7u83 717
#  ifndef __GNUC__
7 7u83 718
extern SizeT strlen(CStringP);
2 7u83 719
#  endif /* defined (__GNUC__) */
720
#  ifndef __GNUC__
7 7u83 721
extern int strcmp(CStringP, CStringP);
2 7u83 722
#  endif /* defined (__GNUC__) */
723
#  ifndef __GNUC__
7 7u83 724
extern CStringP strcpy(CStringP, CStringP);
2 7u83 725
#  endif /* defined (__GNUC__) */
7 7u83 726
extern CStringP strchr(CStringP, int);
727
extern CStringP	strrchr(CStringP, int);
728
extern int errno;
2 7u83 729
#  ifdef FS_STRERROR
7 7u83 730
extern CStringP strerror(int);
2 7u83 731
#  endif /* defined (FS_STRERROR) */
732
 
733
#  include <setjmp.h>
734
#  include <stdio.h>
735
 
736
# endif /* !defined (FS_ANSI_ENVIRON) */
737
 
738
#  ifndef CHAR_BIT
739
#   ifdef PO_CHAR_BIT
740
#    define CHAR_BIT PO_CHAR_BIT
741
#   else
742
#    define CHAR_BIT 8
743
#   endif /* defined (PO_CHAR_BIT) */
744
#  endif /* !defined (CHAR_BIT) */
745
 
746
#  ifndef EXIT_SUCCESS
747
#   ifdef PO_EXIT_SUCCESS
748
#    define EXIT_SUCCESS PO_EXIT_SUCCESS
749
#   else
750
#    define EXIT_SUCCESS (0)
751
#   endif /* defined (PO_EXIT_SUCCESS) */
752
#  endif /* !defined (EXIT_SUCCESS) */
753
 
754
#  ifndef EXIT_FAILURE
755
#   ifdef PO_EXIT_FAILURE
756
#    define EXIT_FAILURE PO_EXIT_FAILURE
757
#   else
758
#    define EXIT_FAILURE (1)
759
#   endif /* defined (PO_EXIT_FAILURE) */
760
#  endif /* !defined (EXIT_FAILURE) */
761
 
762
#  ifndef UINT_MAX
763
#   ifdef PO_UINT_MAX
764
#    define UINT_MAX PO_UINT_MAX
765
#   else
766
#    define UINT_MAX (~(unsigned) 0)
767
#   endif /* defined (PO_UINT_MAX) */
768
#  endif /* !defined (UINT_MAX) */
769
 
770
#  ifndef SEEK_SET
771
#   ifdef PO_SEEK_SET
772
#    define SEEK_SET PO_SEEK_SET
773
#   else
774
#    define SEEK_SET (0)
775
#   endif /* defined (PO_SEEK_SET) */
776
#  endif /* !defined (SEEK_SET) */
777
 
778
#  ifndef SEEK_CUR
779
#   ifdef PO_SEEK_CUR
780
#    define SEEK_CUR PO_SEEK_CUR
781
#   else
782
#    define SEEK_CUR (1)
783
#   endif /* defined (PO_SEEK_CUR) */
784
#  endif /* !defined (SEEK_CUR) */
785
 
786
#  ifndef SEEK_END
787
#   ifdef PO_SEEK_END
788
#    define SEEK_END PO_SEEK_END
789
#   else
790
#    define SEEK_END (2)
791
#   endif /* defined (PO_SEEK_END) */
792
#  endif /* !defined (SEEK_END) */
793
 
794
# ifdef FS_SYS_ERRLIST
795
extern int			sys_nerr;
796
extern CStringP			sys_errlist [];
797
# endif /* defined (FS_SYS_ERRLIST) */
798
 
799
#endif /* !defined (H_OS_INTERFACE) */