2
* (c) Copyright 1992, 1993 by Panagiotis Tsirigotis
3
* All rights reserved. The file named COPYRIGHT specifies the terms
4
* and conditions for redistribution.
9
* $Id: sioconf.h,v 1.3 2003/03/09 19:27:07 steveg Exp $
13
* This file has 2 sections:
14
* 1. a OS-specific section
15
* 2. a CPU/compiler-specific section
17
* You can override/redefine any of the constants/macros in this file.
18
* by uncommenting the inclusion of customconf.h and placing your own
19
* definitions in that file.
22
/* #include "customconf.h" */
27
* OS-specific section.
29
* Features here use the flag HAVE_<feature>.
30
* List of flags (check the following for macros that can be overridden):
32
* HAVE_MMAP (overridable macros)
36
* HAVE_OTHER_FINALIZER (must define macros)
39
* HAVE_BCOPY (HAVE_MEMCPY will be preferred if both are defined)
41
* At least one of the following flags must be defined. The 2nd and 3rd
42
* flags are incompatible.
50
* The library requires 3 macros: SIO_MMAP, SIO_MUNMAP, SIO_MNEED.
51
* You can selectively override any of them.
52
* Notice that the SIO_MNEED macro is not required. If your system
53
* does not have madvise, you can define the macro as:
54
* #define SIO_MNEED( addr, len )
58
#if !defined( SIO_MMAP ) || !defined( SIO_MUNMAP ) || !defined( SIO_MNEED )
59
#include <sys/types.h>
64
#define SIO_MMAP( addr, len, fd, off ) \
65
mmap( addr, len, PROT_READ, \
66
( addr == 0 ) ? MAP_PRIVATE : MAP_PRIVATE + MAP_FIXED, \
71
#define SIO_MUNMAP( addr, len ) munmap( addr, len )
76
#define SIO_MNEED( addr, len )
78
#define SIO_MNEED( addr, len ) (void) madvise( addr, len, MADV_WILLNEED )
82
#endif /* HAVE_MMAP */
85
* N_SIO_DESCRIPTORS is the maximum number of file descriptors
88
#include <sys/param.h>
90
#define N_SIO_DESCRIPTORS OPEN_MAX
92
#define N_SIO_DESCRIPTORS NOFILE
98
* Finalization function.
100
* The purpose of this function is to do work after your program has
101
* called exit(3). In the case of SIO, this means flushing the SIO
104
* If your system does not support atexit or onexit but has some other
105
* way of installing a finalization function, you define the flag
106
* HAVE_FINALIZER. Then you must define the macros
107
* SIO_FINALIZE and SIO_DEFINE_FIN
109
* SIO_FINALIZE attempts to install a finalization function and returns TRUE
110
* if successful, FALSE if unsuccessful.
111
* SIO_DEFINE_FIN defines the finalization function (the reason for this macro
112
* s that different systems pass different number/type of arguments to the
113
* finalization function; the SIO finalization function does not use any
116
#if defined(HAVE_ONEXIT) || defined(HAVE_ATEXIT) || defined(HAVE_FINALIZER)
118
#define HAVE_FINALIZATION_FUNCTION
120
#if defined( HAVE_ONEXIT ) && defined( HAVE_ATEXIT )
125
#define SIO_FINALIZE( func ) ( on_exit( func, (caddr_t) 0 ) == 0 )
126
#define SIO_DEFINE_FIN( func ) static void func ( exit_status, arg ) \
129
#endif /* HAVE_ONEXIT */
132
#define SIO_FINALIZE( func ) ( atexit( func ) == 0 )
133
#define SIO_DEFINE_FIN( func ) static void func ()
134
#endif /* HAVE_ATEXIT */
136
#endif /* HAVE_ONEXIT || HAVE_ATEXIT || HAVE_FINALIZER */
140
* HAVE_MEMCPY should be defined if your OS supports the mem* functions
141
* (memcpy etc). If not, then you can define HAVE_BCOPY if your OS supports
144
#if defined( HAVE_MEMCPY ) && defined( HAVE_BCOPY )
150
* Support for the isatty(3) function. This function identifies if a
151
* descriptor refers to a terminal.
153
* Case 1: isatty(3) is in the C library
154
* --> define HAVE_ISATTY
155
* Case 2: no isatty(3), BSD 4.3 tty handling
156
* --> define HAVE_BSDTTY
157
* Case 3: no isatty(3), System V tty handling
158
* --> define HAVE_SYSVTTY
160
* The following code checks:
161
* 1) that at least one of the flags is defined
162
* 2) only one of the BSD, SYS V flags is defined
164
#if !defined(HAVE_ISATTY) && !defined(HAVE_BSDTTY) && !defined(HAVE_SYSVTTY)
165
#error function_isatty_not_available ;
173
#if defined(HAVE_BSDTTY) && defined(HAVE_SYSVTTY)
174
#error HAVE_BSDTTY_and_HAVE_SYSVTTY_both_defined ;
180
* CPU/compiler-specific section.
182
* The following constant affects the behavior of Sprint.
184
* Sprint performs integer->string conversions by first converting
185
* the integer to the widest int type supported by the CPU/compiler.
186
* By default, this is the "long int" type. If your machine has
187
* a wider type, you can specify it by defining the WIDE_INT constant.
189
* #define WIDE_INT long long