blob: b7f26f2ee6b411e923aa620f0b588f79e8eccab2 [file] [log] [blame]
H. Peter Anvinc1494ac2007-04-13 19:58:42 +00001/* ----------------------------------------------------------------------- *
2 *
3 * Copyright 2007 The NASM Authors - All Rights Reserved
4 *
5 * This program is free software; you can redistribute it and/or modify
Beroset095e6a22007-12-29 09:44:23 -05006 * it under the terms of the license given in the file "LICENSE"
H. Peter Anvinc1494ac2007-04-13 19:58:42 +00007 * 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 Anvinfe501952007-10-02 21:53:51 -070016 *
17 * This header file should be included before any other header.
H. Peter Anvinc1494ac2007-04-13 19:58:42 +000018 */
19
H. Peter Anvinfe501952007-10-02 21:53:51 -070020#ifndef NASM_COMPILER_H
21#define NASM_COMPILER_H 1
H. Peter Anvinc40f89e2007-04-13 20:06:41 +000022
23#ifdef HAVE_CONFIG_H
24# include "config.h"
25#endif
H. Peter Anvinc1494ac2007-04-13 19:58:42 +000026
H. Peter Anvin687b3632007-10-11 12:50:24 -070027/* This is required to get the standard <inttypes.h> macros when compiling
28 with a C++ compiler. This must be defined *before* <inttypes.h> is
29 included, directly or indirectly. */
30#define __STDC_CONSTANT_MACROS 1
31#define __STDC_LIMIT_MACROS 1
32#define __STDC_FORMAT_MACROS 1
33
H. Peter Anvinc1494ac2007-04-13 19:58:42 +000034#ifdef __GNUC__
35# if __GNUC__ >= 4
36# define HAVE_GNUC_4
37# endif
38# if __GNUC__ >= 3
39# define HAVE_GNUC_3
40# endif
41#endif
42
43#ifdef __GNUC__
44# define _unused __attribute__((unused))
45#else
46# define _unused
47#endif
48
H. Peter Anvinb8af9aa2007-09-17 13:53:14 -070049/* Some versions of MSVC have these only with underscores in front */
H. Peter Anvin304b6052007-09-28 10:50:20 -070050#include <stddef.h>
51#include <stdarg.h>
H. Peter Anvinfe501952007-10-02 21:53:51 -070052#include <stdio.h>
H. Peter Anvinb8af9aa2007-09-17 13:53:14 -070053
H. Peter Anvin304b6052007-09-28 10:50:20 -070054#ifndef HAVE_SNPRINTF
55# ifdef HAVE__SNPRINTF
56# define snprintf _snprintf
57# else
58int snprintf(char *, size_t, const char *, ...);
59# endif
H. Peter Anvinb8af9aa2007-09-17 13:53:14 -070060#endif
61
H. Peter Anvin304b6052007-09-28 10:50:20 -070062#ifndef HAVE_VSNPRINTF
63# ifdef HAVE__VSNPRINT
64# define vsnprintf _vsnprintf
65# else
66int vsnprintf(char *, size_t, const char *, va_list);
67# endif
H. Peter Anvinb8af9aa2007-09-17 13:53:14 -070068#endif
69
H. Peter Anvin6867acc2007-10-10 14:58:45 -070070#ifndef __cplusplus /* C++ has false, true, bool as keywords */
71# ifdef HAVE_STDBOOL_H
72# include <stdbool.h>
73# else
74typedef enum { false, true } bool;
75# endif
76#endif
77
H. Peter Anvinc13d31a2007-10-26 18:49:29 -070078/* Some misguided platforms hide the defs for these */
79#if defined(HAVE_STRCASECMP) && !HAVE_DECL_STRCASECMP
80int strcasecmp(const char *, const char *);
81#endif
82
83#if defined(HAVE_STRICMP) && !HAVE_DECL_STRICMP
84int stricmp(const char *, const char *);
85#endif
86
87#if defined(HAVE_STRNCASECMP) && !HAVE_DECL_STRNCASECMP
88int strncasecmp(const char *, const char *, size_t);
89#endif
90
91#if defined(HAVE_STRNICMP) && !HAVE_DECL_STRNICMP
92int strnicmp(const char *, const char *, size_t);
93#endif
94
95#if defined(HAVE_STRSEP) && !HAVE_DECL_STRSEP
96char *strsep(char **, const char *);
97#endif
98
H. Peter Anvind1fb15c2007-11-13 09:37:59 -080099/*
100 * Define this to 1 for faster performance if this is a littleendian
101 * platform which can do unaligned memory references. It is safe
102 * to leave it defined to 0 even if that is true.
103 */
104#if defined(__i386__) || defined(__x86_64__)
105# define X86_MEMORY 1
106#else
107# define X86_MEMORY 0
108#endif
109
H. Peter Anvinfe501952007-10-02 21:53:51 -0700110#endif /* NASM_COMPILER_H */