UNIXworkcode

1 /* 2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 3 * 4 * Copyright 2008 Sun Microsystems, Inc. All rights reserved. 5 * 6 * THE BSD LICENSE 7 * 8 * Redistribution and use in source and binary forms, with or without 9 * modification, are permitted provided that the following conditions are met: 10 * 11 * Redistributions of source code must retain the above copyright notice, this 12 * list of conditions and the following disclaimer. 13 * Redistributions in binary form must reproduce the above copyright notice, 14 * this list of conditions and the following disclaimer in the documentation 15 * and/or other materials provided with the distribution. 16 * 17 * Neither the name of the nor the names of its contributors may be 18 * used to endorse or promote products derived from this software without 19 * specific prior written permission. 20 * 21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 24 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER 25 * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 26 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 27 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 28 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 29 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 30 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 31 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 */ 33 34 #ifndef BASE_SYSTEMS_H 35 #define BASE_SYSTEMS_H 36 37 //include <nspr.h> 38 #include <inttypes.h> 39 40 #ifndef NOINTNSAPI 41 #define INTNSAPI 42 #endif /* !NOINTNSAPI */ 43 44 /* 45 * systems.h: Lists of defines for systems 46 * 47 * This sets what general flavor the system is (UNIX, etc.), 48 * and defines what extra functions your particular system needs. 49 */ 50 51 52 /* --- Begin common definitions for all supported platforms --- */ 53 54 #define DAEMON_ANY 55 #define DAEMON_STATS 56 57 /* new types */ 58 typedef int PRBool; 59 #define PR_TRUE 1 60 #define PR_FALSE 0 61 62 typedef int WSBool; 63 #define WS_TRUE 1 64 #define WS_FALSE 0 65 /* end new types */ 66 67 /* --- End common definitions for all supported platforms --- */ 68 69 /* --- Begin platform-specific definitions --- */ 70 71 #if defined(AIX) 72 73 #define HAS_IPV6 74 #define AUTH_DBM 75 #define BSD_RLIMIT 76 #undef BSD_SIGNALS 77 //define DAEMON_NEEDS_SEMAPHORE 78 //define DAEMON_UNIX_MOBRULE 79 //define DLL_CAPABLE 80 #define DLL_DLOPEN 81 #define DLL_DLOPEN_FLAGS RTLD_NOW|RTLD_GLOBAL 82 #define DNS_CACHE 83 #define FILE_INHERIT_FCNTL 84 #define FILE_MMAP_FLAGS MAP_SHARED 85 #define HAS_STATFS 86 #define HAVE_ATEXIT 87 #define HAVE_STRERROR_R 88 #define HAVE_STRTOK_R 89 #define HAVE_TIME_R 2 /* arg count */ 90 #define HAVE_STRFTIME /* no cftime */ 91 #define JAVA_STATIC_LINK 92 #undef NEED_CRYPT_H 93 #define NEED_STRINGS_H /* for strcasecmp */ 94 #define NET_SOCKETS 95 #define SA_HANDLER_T(x) (void (*)(int))x 96 #ifdef NS_OLDES3X 97 #define SA_NOCLDWAIT 0 /* AIX don't got this */ 98 #endif 99 #define SEM_FLOCK 100 #define SHMEM_MMAP_FLAGS MAP_SHARED 101 #ifdef HW_THREADS 102 #define THREAD_ANY 103 #endif 104 #elif defined(BSDI) 105 106 #define AUTH_DBM 107 #define BSD_MAIL 108 #define BSD_RLIMIT 109 #define BSD_SIGNALS 110 #define BSD_TIME 111 #define DAEMON_UNIX_MOBRULE 112 #define DNS_CACHE 113 #define FILE_INHERIT_FCNTL 114 #define FILE_MMAP_FLAGS (MAP_FILE | MAP_SHARED) 115 #define HAS_STATFS 116 #define HAVE_ATEXIT 117 #undef NEED_CRYPT_PROTO 118 #define NET_SOCKETS 119 #define NO_DOMAINNAME 120 #define SEM_FLOCK 121 #define SHMEM_MMAP_FLAGS MAP_SHARED 122 #define JAVA_STATIC_LINK 123 124 #elif defined(HPUX) 125 126 #define HAVE_TIME_R 2 /* arg count */ 127 #define AUTH_DBM 128 #undef BSD_RLIMIT 129 #undef BSD_SIGNALS 130 #ifdef MCC_PROXY 131 #define DAEMON_NEEDS_SEMAPHORE 132 #else 133 #define DAEMON_NEEDS_SEMAPHORE 134 #endif 135 #define DAEMON_UNIX_MOBRULE 136 #define DLL_CAPABLE 137 #define DLL_HPSHL 138 #define DNS_CACHE 139 #define FILE_INHERIT_FCNTL 140 #define FILE_MMAP_FLAGS MAP_PRIVATE 141 #define HAS_STATFS 142 #define HAVE_ATEXIT 143 #define HAVE_STRFTIME 144 #define JAVA_STATIC_LINK 145 #undef NEED_CRYPT_H 146 #define NET_SOCKETS 147 #define SA_HANDLER_T(x) (void (*)(int))x 148 #define SEM_FLOCK 149 /* warning: mmap doesn't work under 9.04 */ 150 #define SHMEM_MMAP_FLAGS MAP_FILE | MAP_VARIABLE | MAP_SHARED 151 152 #elif defined (IRIX) 153 154 #define AUTH_DBM 155 #define BSD_RLIMIT 156 #undef BSD_SIGNALS 157 #define DAEMON_UNIX_MOBRULE 158 #define DLL_CAPABLE 159 #define DLL_DLOPEN 160 #define DLL_DLOPEN_FLAGS RTLD_NOW 161 #define DNS_CACHE 162 #define FILE_INHERIT_FCNTL 163 #define FILE_MMAP_FLAGS MAP_SHARED 164 #define HAS_STATVFS 165 #define HAVE_ATEXIT 166 #define HAVE_STRTOK_R 167 #define HAVE_TIME_R 2 /* arg count */ 168 #define JAVA_STATIC_LINK 169 #define NEED_CRYPT_H 170 #define NET_SOCKETS 171 #define SA_HANDLER_T(x) (void (*)(int))x 172 #define SEM_FLOCK 173 #define SHMEM_MMAP_FLAGS MAP_SHARED 174 #define THROW_HACK throw() 175 176 #elif defined(Linux) 177 178 #define HAS_IPV6 179 #define AUTH_DBM 180 #define BSD_RLIMIT 181 #undef BSD_SIGNALS 182 #define DAEMON_NEEDS_SEMAPHORE 183 #define DAEMON_UNIX_MOBRULE 184 #define DLL_CAPABLE 185 #define DLL_DLOPEN 186 #define DLL_DLOPEN_FLAGS RTLD_NOW 187 #define DNS_CACHE 188 #define FILE_INHERIT_FCNTL 189 #define FILE_MMAP_FLAGS MAP_SHARED 190 #define SEM_FLOCK 191 #define SHMEM_MMAP_FLAGS MAP_SHARED 192 #define HAS_STATVFS 193 #define HAVE_ATEXIT 194 #define HAVE_STRTOK_R 195 #define HAVE_TIME_R 2 /* arg count */ 196 #define NEED_CRYPT_H 197 #undef NEED_FILIO 198 #define NEED_GHN_PROTO 199 #define NET_SOCKETS 200 #define SA_HANDLER_T(x) (void (*)(int))x 201 #undef NEED_GHN_PROTO 202 203 #elif defined(NCR) 204 205 #define AUTH_DBM 206 #undef BSD_RLIMIT 207 /* #define DAEMON_NEEDS_SEMAPHORE */ 208 #define DAEMON_UNIX_MOBRULE 209 #define DLL_CAPABLE 210 #define DLL_DLOPEN 211 #define DLL_DLOPEN_FLAGS RTLD_NOW 212 #define DNS_CACHE 213 #define FILE_INHERIT_FCNTL 214 #define FILE_MMAP_FLAGS MAP_SHARED 215 #define HAS_STATVFS 216 #define HAVE_ATEXIT 217 #define HAVE_STRTOK_R 218 #define JAVA_STATIC_LINK 219 #define NEED_CRYPT_H 220 #define NEED_FILIO 221 #define NEED_GHN_PROTO 222 #define NET_SOCKETS 223 #define SEM_FLOCK 224 #define SHMEM_MMAP_FLAGS MAP_SHARED 225 226 #elif defined(NEC) 227 228 #define DNS_CACHE 229 #define AUTH_DBM 230 #undef BSD_RLIMIT 231 #define DAEMON_NEEDS_SEMAPHORE 232 #define DAEMON_UNIX_MOBRULE 233 #define DLL_DLOPEN 234 #define DLL_DLOPEN_FLAGS RTLD_NOW 235 #define DLL_CAPABLE 236 #define FILE_INHERIT_FCNTL 237 #define FILE_MMAP_FLAGS MAP_SHARED 238 #define HAS_STATVFS 239 #define HAVE_ATEXIT 240 #define HAVE_STRTOK_R 241 #define HAVE_TIME_R 2 /* arg count */ 242 #define JAVA_STATIC_LINK 243 #define NEED_CRYPT_H 244 #define NEED_FILIO 245 #define NET_SOCKETS 246 #define SEM_FLOCK 247 #define SHMEM_MMAP_FLAGS MAP_SHARED 248 249 #elif defined(OSF1) 250 251 #define HAS_IPV6 252 #define AUTH_DBM 253 #define BSD_RLIMIT 254 #undef BSD_SIGNALS 255 #define BSD_TIME 256 #define DAEMON_UNIX_MOBRULE 257 #define DAEMON_NEEDS_SEMAPHORE 258 #define DLL_CAPABLE 259 #define DLL_DLOPEN 260 #define DLL_DLOPEN_FLAGS RTLD_NOW 261 #define DNS_CACHE 262 #define FILE_INHERIT_FCNTL 263 #define FILE_MMAP_FLAGS MAP_SHARED 264 #define HAVE_ATEXIT 265 #define HAVE_STRFTIME /* no cftime */ 266 #define HAVE_TIME_R 2 /* ctime_r arg count */ 267 #define NET_SOCKETS 268 #define SA_HANDLER_T(x) (void (*)(int))x 269 #define SEM_FLOCK 270 #define SHMEM_MMAP_FLAGS MAP_SHARED 271 272 #elif defined(SCO) 273 274 #define AUTH_DBM 275 #undef BSD_RLIMIT 276 #undef BSD_SIGNALS 277 #define DAEMON_NEEDS_SEMAPHORE 278 #define DAEMON_UNIX_MOBRULE 279 #define DLL_CAPABLE 280 #define DLL_DLOPEN 281 #define DLL_DLOPEN_FLAGS RTLD_NOW 282 #define DNS_CACHE 283 #define FILE_INHERIT_FCNTL 284 #define FILE_MMAP_FLAGS MAP_SHARED 285 #define HAS_STATVFS 286 #define HAVE_ATEXIT 287 #undef NEED_CRYPT_H 288 #undef NEED_FILIO 289 #undef NEED_GHN_PROTO 290 #undef NEED_SETEID_PROTO /* setegid, seteuid */ 291 #define NET_SOCKETS 292 #define SEM_FLOCK 293 #define SHMEM_MMAP_FLAGS MAP_SHARED 294 #define SA_HANDLER_T(x) (void (*)(int))x 295 296 297 #elif defined(SNI) 298 299 #define AUTH_DBM 300 #undef BSD_RLIMIT 301 #define DAEMON_NEEDS_SEMAPHORE 302 #define DAEMON_UNIX_MOBRULE 303 #define DLL_CAPABLE 304 #define DLL_DLOPEN 305 #define DLL_DLOPEN_FLAGS RTLD_NOW 306 #define DNS_CACHE 307 #define FILE_INHERIT_FCNTL 308 #define FILE_MMAP_FLAGS MAP_SHARED 309 #define HAS_STATVFS 310 #define HAVE_ATEXIT 311 #define JAVA_STATIC_LINK 312 #define NEED_CRYPT_H 313 #define NEED_FILIO 314 #define NET_SOCKETS 315 #define SEM_FLOCK 316 #define SHMEM_MMAP_FLAGS MAP_SHARED 317 #define USE_PIPE 318 319 #elif defined(SOLARIS) 320 321 #if defined(ENABLE_IPV6) 322 #define HAS_IPV6 323 #endif 324 #define AUTH_DBM 325 #define BSD_RLIMIT 326 #undef BSD_SIGNALS 327 #define DAEMON_NEEDS_SEMAPHORE 328 #define DAEMON_UNIX_MOBRULE 329 #define DLL_CAPABLE 330 #define DLL_DLOPEN 331 #define DLL_DLOPEN_FLAGS RTLD_NOW|RTLD_FIRST 332 #define DNS_CACHE 333 #define FILE_INHERIT_FCNTL 334 #define FILE_MMAP_FLAGS MAP_SHARED 335 #define HAS_STATVFS 336 #define HAVE_ATEXIT 337 #define HAVE_STRTOK_R 338 #define HAVE_TIME_R 3 /* arg count */ 339 #define NEED_CRYPT_H 340 #define NEED_FILIO 341 #define NEED_GHN_PROTO 342 #define NET_SOCKETS 343 #if OSVERSION > 504 344 #define SA_HANDLER_T(x) x 345 #endif 346 #if OSVERSION >= 506 347 #undef NEED_GHN_PROTO 348 #endif 349 #define SEM_FLOCK 350 #define SHMEM_MMAP_FLAGS MAP_SHARED 351 352 #elif defined (SONY) 353 354 #define AUTH_DBM 355 #undef BSD_RLIMIT 356 #define DAEMON_NEEDS_SEMAPHORE 357 #define DAEMON_UNIX_MOBRULE 358 #define DLL_CAPABLE 359 #define FILE_INHERIT_FCNTL 360 #define FILE_MMAP_FLAGS MAP_SHARED 361 #define HAVE_ATEXIT 362 #define NEED_CRYPT_H 363 #define NEED_FILIO 364 #define NET_SOCKETS 365 #define SEM_FLOCK 366 #define SHMEM_MMAP_FLAGS MAP_SHARED 367 368 #elif defined(SUNOS4) 369 370 #define AUTH_DBM 371 #define BSD_MAIL 372 #define BSD_RLIMIT 373 #define BSD_SIGNALS 374 #define BSD_TIME 375 #define DAEMON_UNIX_MOBRULE 376 #define DLL_CAPABLE 377 #define DLL_DLOPEN 378 #define DLL_DLOPEN_FLAGS 1 379 #define DNS_CACHE 380 #define FILE_INHERIT_FCNTL 381 #define FILE_MMAP_FLAGS MAP_SHARED 382 #define HAS_STATFS 383 #undef HAVE_ATEXIT 384 #undef NEED_CRYPT_H 385 #define NEED_CRYPT_PROTO 386 #define NEED_FILIO 387 #define NET_SOCKETS 388 #define SEM_FLOCK 389 #define SHMEM_MMAP_FLAGS MAP_SHARED 390 391 #elif defined(UNIXWARE) 392 393 #define AUTH_DBM 394 #undef BSD_RLIMIT 395 #define DAEMON_UNIX_MOBRULE 396 #define DLL_CAPABLE 397 #define DLL_DLOPEN 398 #define DLL_DLOPEN_FLAGS RTLD_NOW 399 #define DNS_CACHE 400 #define FILE_INHERIT_FCNTL 401 #define FILE_MMAP_FLAGS MAP_SHARED 402 #define HAS_STATVFS 403 #define HAVE_ATEXIT 404 #define NEED_CRYPT_H 405 #define NEED_FILIO 406 #define NEED_GHN_PROTO 407 #define NEED_SETEID_PROTO /* setegid, seteuid */ 408 #define NET_SOCKETS 409 #define SEM_FLOCK 410 #define SHMEM_MMAP_FLAGS MAP_SHARED 411 412 #ifndef boolean 413 #define boolean boolean 414 #endif 415 416 #elif defined (XP_WIN32) /* Windows NT */ 417 418 #include <wtypes.h> 419 #include <winbase.h> 420 421 #define AUTH_DBM 422 #define DAEMON_WIN32 423 #define DLL_CAPABLE 424 #define DLL_WIN32 425 #define DNS_CACHE 426 #define LOG_BUFFERING 427 #define HAVE_STRFTIME /* no cftime */ 428 #define NEED_CRYPT_PROTO 429 #define NEEDS_WRITEV 430 #define NET_SOCKETS 431 #define NO_DOMAINNAME 432 #ifdef BUILD_DLL 433 #if defined (NSAPI_PUBLIC) 434 #undef NSAPI_PUBLIC 435 #endif 436 #define NSAPI_PUBLIC __declspec(dllexport) 437 #else 438 #if defined (NSAPI_PUBLIC) 439 #undef NSAPI_PUBLIC 440 #endif 441 #define NSAPI_PUBLIC 442 #endif /* BUILD_DLL */ 443 #define SEM_WIN32 444 #define THREAD_ANY 445 #define THREAD_NSPR_KERNEL 446 #define USE_NSPR 447 #define USE_STRFTIME /* no cftime */ 448 #define FILE_DEV_NULL "\\\\.\NUL" 449 450 #endif /* Windows NT */ 451 452 /* --- Begin defaults for values not defined above --- */ 453 454 #ifndef DAEMON_LISTEN_SIZE 455 #define DAEMON_LISTEN_SIZE 128 456 #endif /* !DAEMON_LISTEN_SIZE */ 457 458 #ifndef NSAPI_PUBLIC 459 #define NSAPI_PUBLIC 460 #endif 461 462 #ifndef SA_HANDLER_T 463 #define SA_HANDLER_T(x) (void (*)())x 464 #endif 465 466 #ifndef THROW_HACK 467 #define THROW_HACK /* as nothing */ 468 #endif 469 470 #ifndef FILE_DEV_NULL 471 #define FILE_DEV_NULL "/dev/null" 472 #endif 473 474 /* --- End defaults for values not defined above --- */ 475 476 /* --- Begin the great debate --- */ 477 478 /* NS_MAIL builds sec-key.c which calls systhread_init, which requires */ 479 /* that USE_NSPR is defined when systhr.c is compiled. --lachman */ 480 /* MCC_PROXY does the same thing now --nbreslow -- LIKE HELL --ari */ 481 #if (defined(MCC_HTTPD) || defined(MCC_ADMSERV) || defined(MCC_PROXY) || defined(NS_MAIL)) && defined(XP_UNIX) 482 #define USE_NSPR 483 /* XXXrobm This is UNIX-only for the moment */ 484 #define LOG_BUFFERING 485 #ifdef SW_THREADS 486 #define THREAD_NSPR_USER 487 #else 488 #define THREAD_NSPR_KERNEL 489 #endif 490 #define THREAD_ANY 491 #endif 492 493 /* --- End the great debate --- */ 494 495 #ifndef APSTUDIO_READONLY_SYMBOLS 496 497 #ifndef NSPR_PRIO_H 498 //include "prio.h" 499 #define NSPR_PRIO_H 500 #endif /* !NSPR_PRIO_H */ 501 502 /* 503 * These types have to be defined early, because they are defined 504 * as (void *) in the public API. 505 */ 506 507 /* TODO: remove */ 508 //ifndef SYS_FILE_T 509 //typedef PRFileDesc *SYS_FILE; 510 //define SYS_FILE_T PRFileDesc * 511 //endif /* !SYS_FILE_T */ 512 513 //ifndef SYS_NETFD_T 514 //typedef PRFileDesc *SYS_NETFD; 515 //define SYS_NETFD_T PRFileDesc * 516 //endif /* !SYS_NETFD_T */ 517 518 #ifdef SEM_WIN32 519 520 typedef HANDLE SEMAPHORE; 521 #define SEMAPHORE_T HANDLE 522 #define SEM_ERROR NULL 523 /* That oughta hold them (I hope) */ 524 #define SEM_MAXVALUE 32767 525 526 #elif defined(SEM_FLOCK) 527 528 //define SEMAPHORE_T int 529 //typedef int SEMAPHORE; 530 //define SEM_ERROR -1 531 532 #elif defined(SEM_POSIX) 533 534 #define SEM_ERROR ((void *)(-1)) 535 typedef void* SEMAPHORE_T; 536 537 #else /* ! SEM_WIN32 */ 538 539 // TODO 540 //typedef int SEMAPHORE; 541 //define SEMAPHORE_T int 542 //define SEM_ERROR -1 543 544 #endif /* SEM_WIN32 */ 545 546 #endif /* !APSTUDIO_READONLY_SYMBOLS */ 547 548 #ifndef XP_CPLUSPLUS 549 #ifdef __cplusplus 550 #define XP_CPLUSPLUS 551 #endif /* __cplusplus */ 552 #endif /* !XP_CPLUSPLUS */ 553 554 #endif /* BASE_SYSTEMS_H */ 555