This commit was generated by cvs2svn to compensate for changes in r2,
[ircu2.10.12-pk.git] / include / sys.h
1 /*
2  * IRC - Internet Relay Chat, include/sys.h
3  * Copyright (C) 1990 University of Oulu, Computing Center
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 1, or (at your option)
8  * any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18  */
19
20 #ifndef __sys_include__
21 #define __sys_include__
22
23 #include "../config/config.h"
24 #include "../config/setup.h"
25
26 #ifdef __osf__
27 #define _OSF_SOURCE
28 #endif
29
30 #ifdef __sun__
31 #ifdef __svr4__
32 #define SOL2
33 #else
34 #define SUNOS4
35 #endif
36 #endif
37
38 #if WORDS_BIGENDIAN
39 # define BIT_ZERO_ON_LEFT
40 #else
41 # define BIT_ZERO_ON_RIGHT
42 #endif
43
44 #ifdef _SEQUENT_                /* Dynix 1.4 or 2.0 Generic Define.. */
45 #undef BSD
46 #define SYSV                    /* Also #define SYSV */
47 #endif
48
49 #ifdef __hpux
50 #define HPUX
51 #endif
52
53 #ifdef sgi
54 #define SGI
55 #endif
56
57 #if defined(mips)
58 #undef SYSV
59 #undef BSD
60 #define BSD 1                   /* mips only works in bsd43 environment */
61 #endif
62
63 #ifdef  BSD_RELIABLE_SIGNALS
64 #if defined(SYSV_UNRELIABLE_SIGNALS) || defined(POSIX_SIGNALS)
65 #error You stuffed up config.h signals #defines use only one.
66 #endif
67 #define HAVE_RELIABLE_SIGNALS
68 #endif
69
70 #ifdef  SYSV_UNRELIABLE_SIGNALS
71 #ifdef  POSIX_SIGNALS
72 #error You stuffed up config.h signals #defines use only one.
73 #endif
74 #undef  HAVE_RELIABLE_SIGNALS
75 #endif
76
77 #ifdef  POSIX_SIGNALS
78 #define HAVE_RELIABLE_SIGNALS
79 #endif
80
81 /*
82  * safety margin so we can always have one spare fd, for motd/authd or
83  * whatever else.  -24 allows "safety" margin of 10 listen ports, 8 servers
84  * and space reserved for logfiles, DNS sockets and identd sockets etc.
85  */
86 #define MAXCLIENTS      (MAXCONNECTIONS-24)
87
88 #ifdef HAVECURSES
89 #define DOCURSES
90 #else
91 #undef DOCURSES
92 #endif
93
94 #ifdef HAVETERMCAP
95 #define DOTERMCAP
96 #else
97 #undef DOTERMCAP
98 #endif
99
100 #ifndef UNIXPORT
101 #undef  UNIXPORTPATH
102 #endif
103
104 #if defined(CLIENT_FLOOD)
105 #if (CLIENT_FLOOD > 8000) || (CLIENT_FLOOD < 512)
106 #error CLIENT_FLOOD needs redefining.
107 #endif
108 #else
109 #error CLIENT_FLOOD undefined
110 #endif
111
112 #ifndef CONFIG_SETUGID
113 #undef IRC_UID
114 #undef IRC_GID
115 #endif
116
117 #define Reg1 register
118 #define Reg2 register
119 #define Reg3 register
120 #define Reg4 register
121 #define Reg5 register
122 #define Reg6 register
123 #define Reg7 register
124 #define Reg8 register
125 #define Reg9 register
126 #define Reg10 register
127
128 /* Define FD_SETSIZE to what we want before including sys/types.h on BSD */
129 #if  defined(__FreeBSD__) || defined(__NetBSD__) || defined(__bsdi__)
130 #if ((!defined(USE_POLL)) && (!defined(FD_SETSIZE)))
131 #define FD_SETSIZE ((MAXCONNECTIONS)+4)
132 #endif
133 #endif
134
135 #include <stdio.h>
136 #include <sys/types.h>
137 #include <sys/param.h>
138
139 #ifdef __osf__
140 #undef _OSF_SOURCE
141 /* Buggy header */
142 #include <netdb.h>
143 #define _OSF_SOURCE
144 #endif
145
146 #if HAVE_ERRNO_H
147 # include <errno.h>
148 #else
149 # if HAVE_NET_ERRNO_H
150 #  include <net/errno.h>
151 # endif
152 #endif
153
154 #if !defined(__FreeBSD__) && !defined(__NetBSD__) && \
155     !defined(__bsdi__) && !defined(__alpha) && !defined(__GLIBC__)
156 extern char *sys_errlist[];
157 #endif
158
159 /* See AC_HEADER_STDC in 'info autoconf' */
160 #if STDC_HEADERS
161 # include <string.h>
162 #else
163 # if HAVE_STRING_H
164 #  include <string.h>
165 # endif
166 # ifndef HAVE_STRCHR
167 #  define strchr index
168 #  define strrchr rindex
169 # endif
170 char *strchr(), *strrchr(), *strtok();
171 # if HAVE_MEMORY_H              /* See AC_MEMORY_H in 'info autoconf' */
172 #  include <memory.h>
173 # endif
174 # ifndef HAVE_MEMCPY
175 #  define memcpy(d, s, n) bcopy ((s), (d), (n))
176 #  define memset(a, b, c) bzero(a, c)   /* We ONLY use memset(x, 0, y) */
177 # else
178 #  if NEED_BZERO                /* This is not used yet - needs to be added to `configure' */
179 #   define bzero(a, c) memset((a), 0, (c))      /* Some use it in FD_ZERO */
180 #  endif
181 # endif
182 # ifndef HAVE_MEMMOVE
183 #  define memmove(d, s, n) bcopy ((s), (d), (n))
184 # endif
185 #endif
186
187 #if defined(_AIX) || (defined(__STRICT_ANSI__) && __GLIBC__ >= 2)
188 #include <sys/select.h>
189 #endif
190
191 /* See AC_HEADER_TIME in 'info autoconf' */
192 #if TIME_WITH_SYS_TIME
193 # include <sys/time.h>
194 # include <time.h>
195 #else
196 # if HAVE_SYS_TIME_H
197 #  include <sys/time.h>
198 # else
199 #  include <time.h>
200 # endif
201 #endif
202
203 #ifdef SOL2
204 #define OPT_TYPE char           /* opt type for get/setsockopt */
205 #else
206 #define OPT_TYPE void
207 #endif
208
209 #ifdef SUNOS4
210 #define LIMIT_FMT "%d"
211 #else
212 #if (defined(__bsdi__) || defined(__NetBSD__))
213 #define LIMIT_FMT "%qd"
214 #else
215 #define LIMIT_FMT "%ld"
216 #endif
217 #endif
218
219 /* Different name on NetBSD and FreeBSD --Skip */
220 #if defined(__NetBSD__) || defined(__FreeBSD__) || defined(__bsdi__)
221 #define dn_skipname  __dn_skipname
222 #endif
223
224 #if defined(DEBUGMODE) && !defined(DEBUGMALLOC)
225 #define DEBUGMALLOC
226 #endif
227
228 #ifdef STDC_HEADERS
229 #include <stdlib.h>
230 #include <stddef.h>
231 #else /* !STDC_HEADERS */
232 #ifdef HAVE_MALLOC_H
233 #include <malloc.h>
234 #else
235 #ifdef HAVE_SYS_MALLOC_H
236 #include <sys/malloc.h>
237 #endif /* HAVE_SYS_MALLOC_H */
238 #endif /* HAVE_MALLOC_H */
239 #endif /* !STDC_HEADERS */
240
241 #ifndef MAX
242 #define MAX(a, b)       ((a) > (b) ? (a) : (b))
243 #endif
244 #ifndef MIN
245 #define MIN(a, b)       ((a) < (b) ? (a) : (b))
246 #endif
247
248 #ifndef FALSE
249 #define FALSE (0)
250 #endif
251 #ifndef TRUE
252 #define TRUE  (!FALSE)
253 #endif
254
255 #ifndef offsetof
256 #define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
257 #endif
258
259 #include "runmalloc.h"
260
261 #define MyCoreDump *((int *)NULL)=0
262
263 /* This isn't really POSIX :(, but we really need it -- can this be replaced ? */
264 #if defined(__STRICT_ANSI__) && !defined(_AIX)
265 extern int gettimeofday(struct timeval *tv, struct timezone *tz);
266 #endif
267
268 /*
269  * The following part is donated by Carlo Wood from his package 'libr':
270  * (C) Copyright 1996 by Carlo Wood. All rights reserved.
271  */
272
273 /* GNU CC improvements: We can only use this if we have a gcc/g++ compiler */
274 #ifdef __GNUC__
275
276 #if (__GNUC__ < 2) || (__GNUC__ == 2 && __GNUC_MINOR__ < 7)
277 #define NO_ATTRIBUTE
278 #endif
279
280 #else /* !__GNUC__ */
281
282 /* No attributes if we don't have gcc-2.7 or higher */
283 #define NO_ATTRIBUTE
284
285 #endif /* !__GNUC__ */
286
287 #ifdef __cplusplus
288 #define HANDLER_ARG(x) x
289 #define UNUSED(x)
290 #else
291 #define HANDLER_ARG(x)
292 #ifdef NO_ATTRIBUTE
293 #define __attribute__(x)
294 #define UNUSED(x) unused_##x
295 #else
296 #define UNUSED(x) x __attribute__ ((unused))
297 #endif
298 #endif
299
300 #ifdef NO_ATTRIBUTE
301 #define RCSTAG_CC(string) static char unused_rcs_ident[] = string
302 #else
303 #define RCSTAG_CC(string) static char rcs_ident[] __attribute__ ((unused)) = string
304 #endif
305
306 #ifdef HAVE_SYS_CDEFS_H
307 #include <sys/cdefs.h>
308 #else /* !HAVE_SYS_MALLOC_H */
309 #undef __BEGIN_DECLS
310 #undef __END_DECLS
311 #ifdef  __cplusplus
312 #define __BEGIN_DECLS   extern "C" {
313 #define __END_DECLS     }
314 #else
315 #define __BEGIN_DECLS
316 #define __END_DECLS
317 #endif
318 #endif /* !HAVE_SYS_CDEFS_H */
319
320 #endif /* __sys_include__ */