~noskcaj/ubuntu/saucy/xinetd/2.3.15

« back to all changes in this revision

Viewing changes to libs/src/sio/sioconf.h

  • Committer: Bazaar Package Importer
  • Author(s): Thomas Seyrat
  • Date: 2004-04-18 13:33:57 UTC
  • Revision ID: james.westby@ubuntu.com-20040418133357-czeqeju37433xvdd
Tags: upstream-2.3.13
ImportĀ upstreamĀ versionĀ 2.3.13

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * (c) Copyright 1992, 1993 by Panagiotis Tsirigotis
 
3
 * All rights reserved.  The file named COPYRIGHT specifies the terms 
 
4
 * and conditions for redistribution.
 
5
 */
 
6
 
 
7
 
 
8
/*
 
9
 * $Id: sioconf.h,v 1.3 2003/03/09 19:27:07 steveg Exp $
 
10
 */
 
11
 
 
12
/*
 
13
 * This file has 2 sections:
 
14
 *              1. a OS-specific section
 
15
 *              2. a CPU/compiler-specific section
 
16
 *
 
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.
 
20
 */
 
21
 
 
22
/* #include "customconf.h" */
 
23
 
 
24
 
 
25
 
 
26
/*
 
27
 * OS-specific section.
 
28
 *
 
29
 * Features here use the flag HAVE_<feature>.
 
30
 * List of flags (check the following for macros that can be overridden):
 
31
 *
 
32
 *                      HAVE_MMAP (overridable macros)
 
33
 *
 
34
 *                      HAVE_ATEXIT
 
35
 *                      HAVE_ONEXIT
 
36
 *                      HAVE_OTHER_FINALIZER    (must define macros)
 
37
 *
 
38
 *                      HAVE_MEMCPY
 
39
 *                      HAVE_BCOPY                      (HAVE_MEMCPY will be preferred if both are defined)
 
40
 *
 
41
 *      At least one of the following flags must be defined. The 2nd and 3rd
 
42
 * flags are incompatible.
 
43
 *                      HAVE_ISATTY
 
44
 *                      HAVE_SYSVTTY
 
45
 *                      HAVE_BSDTTY
 
46
 */
 
47
 
 
48
/*
 
49
 * Memory mapping.
 
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 )
 
55
 */
 
56
#ifdef HAVE_MMAP
 
57
 
 
58
#if !defined( SIO_MMAP ) || !defined( SIO_MUNMAP ) || !defined( SIO_MNEED )
 
59
#include <sys/types.h>
 
60
#include <sys/mman.h>
 
61
#endif
 
62
 
 
63
#ifndef SIO_MMAP
 
64
#define SIO_MMAP( addr, len, fd, off )                                  \
 
65
         mmap( addr, len, PROT_READ,                                    \
 
66
            ( addr == 0 ) ? MAP_PRIVATE : MAP_PRIVATE + MAP_FIXED,      \
 
67
               fd, off )
 
68
#endif
 
69
 
 
70
#ifndef SIO_MUNMAP
 
71
#define SIO_MUNMAP( addr, len )  munmap( addr, len )
 
72
#endif
 
73
 
 
74
#ifndef SIO_MNEED
 
75
#if defined(linux)
 
76
#define SIO_MNEED( addr, len )
 
77
#else
 
78
#define SIO_MNEED( addr, len )      (void) madvise( addr, len, MADV_WILLNEED )
 
79
#endif
 
80
#endif
 
81
 
 
82
#endif  /* HAVE_MMAP */
 
83
 
 
84
/*
 
85
 * N_SIO_DESCRIPTORS is the maximum number of file descriptors
 
86
 * supported by the OS
 
87
 */
 
88
#include <sys/param.h>
 
89
#ifdef OPEN_MAX
 
90
#define N_SIO_DESCRIPTORS               OPEN_MAX
 
91
#else
 
92
#define N_SIO_DESCRIPTORS               NOFILE
 
93
#endif
 
94
 
 
95
 
 
96
 
 
97
/*
 
98
 * Finalization function. 
 
99
 *
 
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
 
102
 * output buffers.
 
103
 *
 
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
 
108
 *
 
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
 
114
 * arguments).
 
115
 */
 
116
#if defined(HAVE_ONEXIT) || defined(HAVE_ATEXIT) || defined(HAVE_FINALIZER)
 
117
 
 
118
#define HAVE_FINALIZATION_FUNCTION
 
119
 
 
120
#if defined( HAVE_ONEXIT ) && defined( HAVE_ATEXIT )
 
121
#undef HAVE_ONEXIT
 
122
#endif
 
123
 
 
124
#ifdef HAVE_ONEXIT
 
125
#define SIO_FINALIZE( func )        ( on_exit( func, (caddr_t) 0 ) == 0 )
 
126
#define SIO_DEFINE_FIN( func )      static void func ( exit_status, arg )  \
 
127
                                          int exit_status ;                \
 
128
                                          caddr_t arg ;
 
129
#endif  /* HAVE_ONEXIT */
 
130
 
 
131
#ifdef HAVE_ATEXIT
 
132
#define SIO_FINALIZE( func )        ( atexit( func ) == 0 )
 
133
#define SIO_DEFINE_FIN( func )      static void func ()
 
134
#endif  /* HAVE_ATEXIT */
 
135
 
 
136
#endif  /* HAVE_ONEXIT || HAVE_ATEXIT || HAVE_FINALIZER */
 
137
 
 
138
 
 
139
/*
 
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 
 
142
 * bcopy.
 
143
 */
 
144
#if defined( HAVE_MEMCPY ) && defined( HAVE_BCOPY )
 
145
#undef HAVE_BCOPY
 
146
#endif
 
147
 
 
148
 
 
149
/*
 
150
 * Support for the isatty(3) function. This function identifies if a 
 
151
 * descriptor refers to a terminal.
 
152
 *
 
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
 
159
 *
 
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
 
163
 */
 
164
#if !defined(HAVE_ISATTY) && !defined(HAVE_BSDTTY) && !defined(HAVE_SYSVTTY)
 
165
 #error function_isatty_not_available ;
 
166
#endif
 
167
 
 
168
#ifdef HAVE_ISATTY
 
169
#undef HAVE_BSDTTY
 
170
#undef HAVE_SYSVTTY
 
171
#endif
 
172
 
 
173
#if defined(HAVE_BSDTTY) && defined(HAVE_SYSVTTY)
 
174
 #error HAVE_BSDTTY_and_HAVE_SYSVTTY_both_defined ;
 
175
#endif
 
176
 
 
177
 
 
178
 
 
179
/*
 
180
 * CPU/compiler-specific section.
 
181
 *
 
182
 * The following constant affects the behavior of Sprint.
 
183
 *
 
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.
 
188
 * For example:
 
189
 *              #define WIDE_INT                                        long long
 
190
 */
 
191