1 /* @(#)mconfig.h 1.73 19/04/03 Copyright 1995-2019 J. Schilling */ 2 /* 3 * definitions for machine configuration 4 * 5 * Copyright (c) 1995-2019 J. Schilling 6 * 7 * This file must be included before any other file. 8 * If this file is not included before stdio.h you will not be 9 * able to get LARGEFILE support 10 * 11 * Use only cpp instructions. 12 * 13 * NOTE: SING: (Schily Is Not Gnu) 14 */ 15 /* 16 * The contents of this file are subject to the terms of the 17 * Common Development and Distribution License, Version 1.0 only 18 * (the "License"). You may not use this file except in compliance 19 * with the License. 20 * 21 * See the file CDDL.Schily.txt in this distribution for details. 22 * A copy of the CDDL is also available via the Internet at 23 * http://www.opensource.org/licenses/cddl1.txt 24 * 25 * When distributing Covered Code, include this CDDL HEADER in each 26 * file and include the License file CDDL.Schily.txt from this distribution. 27 */ 28 29 #ifndef _SCHILY_MCONFIG_H 30 #define _SCHILY_MCONFIG_H 31 32 /* 33 * Tell our users that this is a Schily SING compile environment. 34 */ 35 #define IS_SCHILY 36 37 /* 38 * We need to do this before we include xconfig.h 39 */ 40 #ifdef NO_LARGEFILES 41 #undef USE_LARGEFILES 42 #endif 43 #ifdef NO_ACL 44 #undef USE_ACL 45 #endif 46 47 /* 48 * Inside <schily/archdefs.h> we get architecture specific Processor defines 49 * fetched from compiler predefinitions only. 50 */ 51 #include <schily/archdefs.h> 52 53 /* 54 * Inside <schily/xconfig.h> we decide whether to use static or dynamic 55 * autoconf stuff. 56 */ 57 #include <schily/xconfig.h> 58 59 /* 60 * Make sure that neither HAVE_LARGEFILES nor USE_LARGEFILES is defined 61 * if the platform does not support large files. 62 */ 63 #ifndef HAVE_LARGEFILES 64 #undef USE_LARGEFILES 65 #endif 66 67 #ifdef __cplusplus 68 extern "C" { 69 #endif 70 71 /* 72 * The NetBSD people want to bother us. 73 * They removed the definition for 'unix' and are bleating for every test 74 * for #if defined(unix). So we need to check for NetBSD early. 75 */ 76 #ifndef IS_UNIX 77 # if defined(__NetBSD__) 78 # define IS_UNIX 79 # endif 80 #endif 81 82 #ifndef IS_UNIX 83 # if (defined(unix) || defined(__unix) || defined(__unix__)) && \ 84 !defined(__DJGPP__) 85 # define IS_UNIX 86 # endif 87 #endif 88 89 #ifdef __MSDOS__ 90 # define IS_MSDOS 91 #endif 92 93 #if defined(tos) || defined(__tos) 94 # define IS_TOS 95 #endif 96 97 #ifdef THINK_C 98 # define IS_MAC 99 #endif 100 101 #if defined(sun) || defined(__sun) || defined(__sun__) 102 # define IS_SUN 103 #endif 104 105 #if defined(__CYGWIN32__) || defined(__CYGWIN__) 106 # define IS_GCC_WIN32 107 # define IS_CYGWIN 108 109 #if defined(unix) || defined(_X86) 110 # define IS_CYGWIN_1 111 #endif 112 #endif 113 114 /* 115 * GCC & Clang address sanitizer detection: 116 */ 117 #if defined(__SANITIZE_ADDRESS__) /* GCC */ 118 #define IS_ASAN 119 #endif 120 #if defined(__has_feature) /* Clang */ 121 #if __has_feature(address_sanitizer) 122 #define IS_ASAN 123 #endif 124 #endif 125 126 127 /* ------------------------------------------------------------------------- */ 128 /* 129 * Some magic that cannot (yet) be figured out with autoconf. 130 */ 131 132 #if defined(sun3) || defined(mc68000) || defined(mc68020) 133 # ifndef HAVE_SCANSTACK 134 # define HAVE_SCANSTACK 135 # endif 136 #endif 137 #ifdef sparc 138 # ifndef HAVE_LDSTUB 139 # define HAVE_LDSTUB 140 # endif 141 # ifndef HAVE_SCANSTACK 142 # define HAVE_SCANSTACK 143 # endif 144 #endif 145 #if defined(__i386_) || defined(i386) 146 # ifndef HAVE_XCHG 147 # define HAVE_XCHG 148 # endif 149 # ifndef HAVE_SCANSTACK 150 # define HAVE_SCANSTACK 151 # endif 152 #endif 153 154 /* 155 * Use of SCANSTACK is disabled by default 156 */ 157 #ifndef USE_SCANSTACK 158 # undef HAVE_SCANSTACK 159 #else 160 /* 161 * But .... 162 * The tests are much better now, so always give it a chance. 163 */ 164 #ifndef HAVE_SCANSTACK 165 # define HAVE_SCANSTACK 166 #endif 167 #endif 168 169 /* 170 * The address sanitizer does not like our frame pointer modifications 171 * and would otherwise warn against a stack corruption. 172 */ 173 #ifdef IS_ASAN 174 # undef HAVE_SCANSTACK 175 #endif 176 177 /* 178 * Allow to overwrite the defines in the makefiles by calling 179 * 180 * make COPTX=-DFORCE_SCANSTACK 181 */ 182 #ifdef FORCE_SCANSTACK 183 # undef NO_SCANSTACK 184 #ifndef HAVE_SCANSTACK 185 # define HAVE_SCANSTACK 186 #endif 187 #ifndef USE_SCANSTACK 188 # define USE_SCANSTACK 189 #endif 190 #endif 191 192 /* 193 * This is the global switch to deactivate stack scanning 194 */ 195 #ifdef NO_SCANSTACK 196 # ifdef HAVE_SCANSTACK 197 # undef HAVE_SCANSTACK 198 # endif 199 #endif 200 201 /* 202 * This is the global switch to deactivate using #pragma weak 203 */ 204 #ifdef NO_PRAGMA_WEAK 205 # ifdef HAVE_PRAGMA_WEAK 206 # undef HAVE_PRAGMA_WEAK 207 # endif 208 #endif 209 210 #ifdef NO_FORK 211 # ifdef HAVE_FORK 212 # undef HAVE_FORK 213 # endif 214 # ifdef HAVE_VFORK 215 # undef HAVE_VFORK 216 # endif 217 #endif 218 #ifdef NO_VFORK 219 # ifdef HAVE_VFORK 220 # undef HAVE_VFORK 221 # endif 222 #endif 223 224 #if defined(SOL2) || defined(SOL2) || \ 225 defined(S5R4) || defined(__S5R4) || defined(SVR4) 226 # ifndef __SVR4 227 # define __SVR4 228 # endif 229 #endif 230 231 #ifdef __SVR4 232 # ifndef SVR4 233 # define SVR4 234 # endif 235 #endif 236 237 /* 238 * SunOS 4.x / SunOS 5.x 239 */ 240 #if defined(IS_SUN) 241 # define HAVE_GETAV0 242 #endif 243 244 /* 245 * AIX 246 */ 247 #if defined(_IBMR2) || defined(_AIX) 248 # ifndef IS_UNIX 249 # define IS_UNIX /* ??? really ??? */ 250 # endif 251 #endif 252 253 /* 254 * QNX 255 */ 256 #if defined(__QNX__) 257 # ifndef IS_UNIX 258 # define IS_UNIX 259 # endif 260 #endif 261 262 /* 263 * Silicon Graphics (must be before SVR4) 264 */ 265 #if defined(sgi) || defined(__sgi) 266 # define __NOT_SVR4__ /* Not a real SVR4 implementation */ 267 #endif 268 269 /* 270 * Data General 271 */ 272 #if defined(__DGUX__) 273 #ifdef XXXXXXX 274 # undef HAVE_MTGET_DSREG 275 # undef HAVE_MTGET_RESID 276 # undef HAVE_MTGET_FILENO 277 # undef HAVE_MTGET_BLKNO 278 #endif 279 # define mt_type mt_model 280 # define mt_dsreg mt_status1 281 # define mt_erreg mt_status2 282 /* 283 * DGUX hides its flock as dg_flock. 284 */ 285 # define HAVE_FLOCK 286 # define flock dg_flock 287 /* 288 * Use the BSD style wait on DGUX to get the resource usages of child 289 * processes. 290 */ 291 # define _BSD_WAIT_FLAVOR 292 #endif 293 294 /* 295 * Apple Rhapsody (This is the name for Mac OS X beta) 296 */ 297 #if defined(__NeXT__) && defined(__TARGET_OSNAME) && __TARGET_OSNAME == rhapsody 298 # define HAVE_OSDEF /* prevent later definitions to overwrite current */ 299 # ifndef IS_UNIX 300 # define IS_UNIX 301 # endif 302 #endif 303 304 /* 305 * NextStep 306 */ 307 #if defined(__NeXT__) && !defined(HAVE_OSDEF) 308 #define NO_PRINT_OVR 309 #undef HAVE_USG_STDIO 310 /* 311 * NeXT Step 3.x uses 312 * __flsbuf(unsigned char, FILE *) 313 * instead of __flsbuf(int, FILE *) 314 */ 315 # ifndef IS_UNIX 316 # define IS_UNIX 317 # endif 318 #endif 319 320 /* 321 * Mac OS X 322 */ 323 #if defined(__APPLE__) && defined(__MACH__) 324 # ifndef IS_UNIX 325 # define IS_UNIX 326 # endif 327 # define IS_MACOS_X 328 #endif 329 330 /* 331 * NextStep 3.x has a broken linker that does not allow us to override 332 * these functions. 333 */ 334 #ifndef __OPRINTF__ 335 336 #ifdef NO_PRINT_OVR 337 # define printf Xprintf 338 # define fprintf Xfprintf 339 # define sprintf Xsprintf 340 #endif 341 342 #endif /* __OPRINTF__ */ 343 344 /* ------------------------------------------------------------------------- */ 345 346 #ifndef _SCHILY_PROTOTYP_H 347 #include <schily/prototyp.h> 348 #endif 349 350 /* 351 * We use HAVE_LONGLONG as generalized test on whether "long long", "__in64" or 352 * something similar exist. 353 * 354 * In case that HAVE_LONGLONG is defined here, this is an indication that 355 * "long long" works. We define HAVE_LONG_LONG to keep this knowledge. 356 */ 357 #ifdef HAVE_LONGLONG 358 # define HAVE_LONG_LONG 359 #endif 360 361 /* 362 * Microsoft C defines _MSC_VER 363 * use __int64 instead of long long and use 0i64 for a signed long long const 364 * and 0ui64 for an unsigned long long const. 365 * 366 * #if defined(HAVE___INT64) 367 * use __int64 368 * #elif defined(HAVE_LONGLONG) 369 * use long long 370 * #endif 371 * 372 * Be very careful here as older MSVC versions do not implement long long but 373 * rather __int64 and once someone makes 'long long' 128 bits on a 64 bit 374 * machine, we may need to check for a MSVC __int128 type. 375 */ 376 #ifndef HAVE_LONGLONG 377 # if defined(HAVE___INT64) 378 # define HAVE_LONGLONG 379 # endif 380 #endif 381 382 /* 383 * gcc 2.x generally implements the "long long" type. 384 */ 385 #ifdef __GNUC__ 386 # if __GNUC__ > 1 387 # ifndef HAVE_LONGLONG 388 # define HAVE_LONGLONG 389 # endif 390 # ifndef HAVE_LONG_LONG 391 # define HAVE_LONG_LONG 392 # endif 393 # endif 394 #endif 395 396 #ifdef __CHAR_UNSIGNED__ /* GNU GCC define (dynamic) */ 397 #ifndef CHAR_IS_UNSIGNED 398 #define CHAR_IS_UNSIGNED /* Sing Schily define (static) */ 399 #endif 400 #endif 401 402 /* 403 * Convert to GNU name 404 */ 405 #ifdef HAVE_STDC_HEADERS 406 # ifndef STDC_HEADERS 407 # define STDC_HEADERS 408 # endif 409 #endif 410 /* 411 * Convert to SCHILY name 412 */ 413 #ifdef STDC_HEADERS 414 # ifndef HAVE_STDC_HEADERS 415 # define HAVE_STDC_HEADERS 416 # endif 417 #endif 418 419 #ifdef IS_UNIX 420 # define HAVE_PATH_DELIM 421 # define PATH_DELIM '/' 422 # define PATH_DELIM_STR "/" 423 # define PATH_ENV_DELIM ':' 424 # define PATH_ENV_DELIM_STR ":" 425 # define far 426 # define near 427 #endif 428 429 /* 430 * Win32 with Gygwin 431 */ 432 #ifdef IS_GCC_WIN32 433 # define HAVE_PATH_DELIM 434 # define PATH_DELIM '/' 435 # define PATH_DELIM_STR "/" 436 # define PATH_ENV_DELIM ':' 437 # define PATH_ENV_DELIM_STR ":" 438 # define HAVE_DOS_DRIVELETTER 439 # define far 440 # define near 441 # define NEED_O_BINARY 442 #endif 443 444 /* 445 * Win32 with Mingw32 446 */ 447 #ifdef __MINGW32__ 448 # define HAVE_PATH_DELIM 449 # define PATH_DELIM '/' 450 # define PATH_DELIM_STR "/" 451 # define PATH_ENV_DELIM ';' 452 # define PATH_ENV_DELIM_STR ";" 453 # define HAVE_DOS_DRIVELETTER 454 # define far 455 # define near 456 # define NEED_O_BINARY 457 #endif 458 459 /* 460 * OS/2 EMX 461 */ 462 #ifdef __EMX__ /* We don't want to call it UNIX */ 463 # define HAVE_PATH_DELIM 464 # define PATH_DELIM '/' 465 # define PATH_DELIM_STR "/" 466 # define PATH_ENV_DELIM ';' 467 # define PATH_ENV_DELIM_STR ";" 468 # define HAVE_DOS_DRIVELETTER 469 # define far 470 # define near 471 # define NEED_O_BINARY 472 #endif 473 474 #ifdef __BEOS__ /* We don't want to call it UNIX */ 475 # define HAVE_PATH_DELIM 476 # define PATH_DELIM '/' 477 # define PATH_DELIM_STR "/" 478 # define PATH_ENV_DELIM ':' 479 # define PATH_ENV_DELIM_STR ":" 480 # define far 481 # define near 482 #endif 483 484 /* 485 * DOS with DJGPP 486 */ 487 #ifdef __DJGPP__ /* We don't want to call it UNIX */ 488 # define HAVE_PATH_DELIM 489 # define PATH_DELIM '/' 490 # define PATH_DELIM_STR "/" 491 # define PATH_ENV_DELIM ';' 492 # define PATH_ENV_DELIM_STR ";" 493 # define HAVE_DOS_DRIVELETTER 494 495 # define NEED_O_BINARY 496 #endif 497 498 /* 499 * Vanilla DOS 500 */ 501 #if defined(IS_MSDOS) && !defined(__DJGPP__) 502 # define HAVE_PATH_DELIM 503 # define PATH_DELIM '\\' 504 # define PATH_DELIM_STR "\\" 505 # define PATH_ENV_DELIM ';' 506 # define PATH_ENV_DELIM_STR ";" 507 # define HAVE_DOS_DRIVELETTER 508 509 # define NEED_O_BINARY 510 #endif 511 512 /* 513 * ATARI TOS 514 */ 515 #ifdef IS_TOS 516 # define HAVE_PATH_DELIM 517 # define PATH_DELIM '\\' 518 # define PATH_DELIM_STR "\\" 519 # define PATH_ENV_DELIM ',' 520 # define PATH_ENV_DELIM_STR "," 521 # define HAVE_DOS_DRIVELETTER 522 # define far 523 # define near 524 #endif 525 526 /* 527 * Mac OS 9 528 */ 529 #ifdef IS_MAC 530 # define HAVE_PATH_DELIM 531 # define PATH_DELIM ':' 532 # define PATH_DELIM_STR ":" 533 # define PATH_ENV_DELIM ';' /* ??? */ 534 # define PATH_ENV_DELIM_STR ";" /* ??? */ 535 # define far 536 # define near 537 #endif 538 539 /* 540 * I hope this will make compilation on unknown OS easier. 541 */ 542 #ifndef HAVE_PATH_DELIM /* Default to POSIX rules */ 543 # define HAVE_PATH_DELIM 544 # define PATH_DELIM '/' 545 # define PATH_DELIM_STR "/" 546 # define PATH_ENV_DELIM ':' 547 # define PATH_ENV_DELIM_STR ":" 548 # define far 549 # define near 550 #endif 551 552 /* 553 * Is there a solution for /dev/tty and similar? 554 */ 555 #ifdef HAVE__DEV_NULL 556 # define DEV_NULL "/dev/null" 557 #else 558 #if defined(_MSC_VER) || defined(__MINGW32__) 559 # define DEV_NULL "NUL" 560 #else 561 /* 562 * What to do here? 563 */ 564 #endif 565 #endif 566 567 #ifdef DBG_MALLOC 568 /* 569 * We need to include this here already in order to make sure that 570 * every program that is based on mconfig.h will include schily/dbgmalloc.h 571 * in case that we specify -DDBG_MALLOC 572 */ 573 #include <schily/dbgmalloc.h> 574 #else 575 #undef DBG_MALLOC_MARK 576 #define DBG_MALLOC_MARK(a) 577 #endif 578 579 #ifdef __cplusplus 580 } 581 #endif 582 583 #endif /* _SCHILY_MCONFIG_H */ 584