1 /* ----------------------------------------------------------------------- *
3 * Copyright 2007 The NASM Authors - All Rights Reserved
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.
9 * ----------------------------------------------------------------------- */
14 * Compiler-specific macros for NASM. Feel free to add support for
15 * other compilers in here.
17 * This header file should be included before any other header.
20 #ifndef NASM_COMPILER_H
21 #define NASM_COMPILER_H 1
25 /* autoconf doesn't define these if they are redundant, but we want to
26 be able to #ifdef them... */
28 /* Default these to unsupported unless we have config.h */
35 #endif /* HAVE_CONFIG_H */
37 /* This is required to get the standard <inttypes.h> macros when compiling
38 with a C++ compiler. This must be defined *before* <inttypes.h> is
39 included, directly or indirectly. */
40 #define __STDC_CONSTANT_MACROS 1
41 #define __STDC_LIMIT_MACROS 1
42 #define __STDC_FORMAT_MACROS 1
54 # define _unused __attribute__((unused))
59 /* Some versions of MSVC have these only with underscores in front */
65 # ifdef HAVE__SNPRINTF
66 # define snprintf _snprintf
68 int snprintf(char *, size_t, const char *, ...);
72 #ifndef HAVE_VSNPRINTF
73 # ifdef HAVE__VSNPRINT
74 # define vsnprintf _vsnprintf
76 int vsnprintf(char *, size_t, const char *, va_list);
80 #ifndef __cplusplus /* C++ has false, true, bool as keywords */
81 # ifdef HAVE_STDBOOL_H
84 /* This is sort of dangerous, since casts will behave different than
85 casting to the standard boolean type. Always use !!, not (bool). */
86 typedef enum bool { false, true } bool;
90 /* Some misguided platforms hide the defs for these */
91 #if defined(HAVE_STRCASECMP) && !HAVE_DECL_STRCASECMP
92 int strcasecmp(const char *, const char *);
95 #if defined(HAVE_STRICMP) && !HAVE_DECL_STRICMP
96 int stricmp(const char *, const char *);
99 #if defined(HAVE_STRNCASECMP) && !HAVE_DECL_STRNCASECMP
100 int strncasecmp(const char *, const char *, size_t);
103 #if defined(HAVE_STRNICMP) && !HAVE_DECL_STRNICMP
104 int strnicmp(const char *, const char *, size_t);
107 #if defined(HAVE_STRSEP) && !HAVE_DECL_STRSEP
108 char *strsep(char **, const char *);
112 * Define this to 1 for faster performance if this is a littleendian
113 * platform which can do unaligned memory references. It is safe
114 * to leave it defined to 0 even if that is true.
116 #if defined(__386__) || defined(__i386__) || defined(__x86_64__)
117 # define X86_MEMORY 1
118 # ifndef WORDS_LITTLEENDIAN
119 # define WORDS_LITTLEENDIAN 1
122 # define X86_MEMORY 0
126 * Hints to the compiler that a particular branch of code is more or
127 * less likely to be taken.
129 #if defined(__GNUC__) && __GNUC__ >= 3
130 # define likely(x) __builtin_expect(!!(x), 1)
131 # define unlikely(x) __builtin_expect(!!(x), 0)
133 # define likely(x) (!!(x))
134 # define unlikely(x) (!!(x))
137 #endif /* NASM_COMPILER_H */