H. Peter Anvin | c1494ac | 2007-04-13 19:58:42 +0000 | [diff] [blame] | 1 | /* ----------------------------------------------------------------------- * |
| 2 | * |
| 3 | * Copyright 2007 The NASM Authors - All Rights Reserved |
| 4 | * |
| 5 | * This program is free software; you can redistribute it and/or modify |
| 6 | * it under the terms of the license given in the file "License" |
| 7 | * distributed in the NASM archive. |
| 8 | * |
| 9 | * ----------------------------------------------------------------------- */ |
| 10 | |
| 11 | /* |
| 12 | * compiler.h |
| 13 | * |
| 14 | * Compiler-specific macros for NASM. Feel free to add support for |
| 15 | * other compilers in here. |
H. Peter Anvin | fe50195 | 2007-10-02 21:53:51 -0700 | [diff] [blame^] | 16 | * |
| 17 | * This header file should be included before any other header. |
H. Peter Anvin | c1494ac | 2007-04-13 19:58:42 +0000 | [diff] [blame] | 18 | */ |
| 19 | |
H. Peter Anvin | fe50195 | 2007-10-02 21:53:51 -0700 | [diff] [blame^] | 20 | #ifndef NASM_COMPILER_H |
| 21 | #define NASM_COMPILER_H 1 |
H. Peter Anvin | c40f89e | 2007-04-13 20:06:41 +0000 | [diff] [blame] | 22 | |
| 23 | #ifdef HAVE_CONFIG_H |
| 24 | # include "config.h" |
| 25 | #endif |
H. Peter Anvin | c1494ac | 2007-04-13 19:58:42 +0000 | [diff] [blame] | 26 | |
H. Peter Anvin | fe50195 | 2007-10-02 21:53:51 -0700 | [diff] [blame^] | 27 | /* Request as many features as we can */ |
| 28 | #define _GNU_SOURCE |
| 29 | #define _ISO99_SOURCE |
| 30 | #define _POSIX_SOURCE |
| 31 | #define _POSIX_C_SOURCE 200112L |
| 32 | #define _XOPEN_SOURCE 600 |
| 33 | #define _XOPEN_SOURCE_EXTENDED |
| 34 | |
H. Peter Anvin | c1494ac | 2007-04-13 19:58:42 +0000 | [diff] [blame] | 35 | #ifdef __GNUC__ |
| 36 | # if __GNUC__ >= 4 |
| 37 | # define HAVE_GNUC_4 |
| 38 | # endif |
| 39 | # if __GNUC__ >= 3 |
| 40 | # define HAVE_GNUC_3 |
| 41 | # endif |
| 42 | #endif |
| 43 | |
| 44 | #ifdef __GNUC__ |
| 45 | # define _unused __attribute__((unused)) |
| 46 | #else |
| 47 | # define _unused |
| 48 | #endif |
| 49 | |
H. Peter Anvin | b8af9aa | 2007-09-17 13:53:14 -0700 | [diff] [blame] | 50 | /* Some versions of MSVC have these only with underscores in front */ |
H. Peter Anvin | 304b605 | 2007-09-28 10:50:20 -0700 | [diff] [blame] | 51 | #include <stddef.h> |
| 52 | #include <stdarg.h> |
H. Peter Anvin | fe50195 | 2007-10-02 21:53:51 -0700 | [diff] [blame^] | 53 | #include <stdio.h> |
H. Peter Anvin | b8af9aa | 2007-09-17 13:53:14 -0700 | [diff] [blame] | 54 | |
H. Peter Anvin | 304b605 | 2007-09-28 10:50:20 -0700 | [diff] [blame] | 55 | #ifndef HAVE_SNPRINTF |
| 56 | # ifdef HAVE__SNPRINTF |
| 57 | # define snprintf _snprintf |
| 58 | # else |
| 59 | int snprintf(char *, size_t, const char *, ...); |
| 60 | # endif |
H. Peter Anvin | b8af9aa | 2007-09-17 13:53:14 -0700 | [diff] [blame] | 61 | #endif |
| 62 | |
H. Peter Anvin | 304b605 | 2007-09-28 10:50:20 -0700 | [diff] [blame] | 63 | #ifndef HAVE_VSNPRINTF |
| 64 | # ifdef HAVE__VSNPRINT |
| 65 | # define vsnprintf _vsnprintf |
| 66 | # else |
| 67 | int vsnprintf(char *, size_t, const char *, va_list); |
| 68 | # endif |
H. Peter Anvin | b8af9aa | 2007-09-17 13:53:14 -0700 | [diff] [blame] | 69 | #endif |
| 70 | |
H. Peter Anvin | fe50195 | 2007-10-02 21:53:51 -0700 | [diff] [blame^] | 71 | #endif /* NASM_COMPILER_H */ |