Update codebase to remove clang warnings (and a couple of legit errors
[typhoon.git] / src / compiler.h
1 /**
2
3 Copyright (c) Scott Gasch
4
5 Module Name:
6
7     system.h
8
9 Abstract:
10
11 Author:
12
13     Scott Gasch ([email protected]) 8 Apr 2004
14
15 Revision History:
16
17     $Id: compiler.h 349 2008-06-28 02:48:59Z scott $
18
19 **/
20
21 #ifndef COMPILER_H_
22 #define COMPILER_H_
23
24 #if defined _MSC_VER
25
26 #include <io.h>
27
28 #pragma warning(disable:4201) // nonstandard extension: nameless struct/union
29 #pragma warning(disable:4214) // nonstandard extension: bitfields struct
30
31 #define PROFILE                    ""
32 #define ALIGN64                    __declspec(align(64))
33 #define TB_FASTCALL                __fastcall
34 #define COMPILER_STRING            "Microsoft(R) Visual C/C++ %u\n", _MSC_VER
35 #define open                       _open
36 #define write                      _write
37 #define COMPILER_LONGLONG          __int64
38 #define COMPILER_VSNPRINTF         _vsnprintf
39 #define CDECL                      __cdecl
40 #define FASTCALL                   __fastcall
41 #define INLINE                     __inline
42 #define FORCEINLINE                __forceinline
43 #define NORETURN
44 #define CONSTFUNCT
45 #define COMPILER_LONGLONG_HEX_FORMAT "I64x"
46 #define COMPILER_LONGLONG_UNSIGNED_FORMAT "I64u"
47 #define STRNCMPI                   _strnicmp
48 #define STRCMPI                    strcmpi
49 #define STRDUP                     SystemStrDup
50
51 #elif defined __GNUC__
52
53 #include <unistd.h>
54
55 extern int errno;
56
57 #define COMPILER_STRING            "GCC "__VERSION__"\n"
58 #define BUILD_STRING               __OPTIMIZE__
59
60 #define O_BINARY                   (0)
61 #define O_RANDOM                   (0)
62 #define _S_IREAD                   (0)
63 #define _S_IWRITE                  (0)
64
65 #define ALIGN64 // __attribute__ (aligned(64)) does not work
66 #define COMPILER_LONGLONG          long long
67 #define COMPILER_VSNPRINTF         vsnprintf
68 #ifndef SIXTYFOUR
69 #define CDECL                      __attribute__((cdecl))
70 #endif
71 #define FASTCALL                   __attribute__((__regparm__(3)))
72 #define INLINE                     __inline__
73 #define FORCEINLINE                __attribute__((always_inline))
74 #define NORETURN                   __attribute__((noreturn))
75 #define CONSTFUNCT                 __attribute__((const))
76 #define COMPILER_LONGLONG_HEX_FORMAT "llx"
77 #define COMPILER_LONGLONG_UNSIGNED_FORMAT "llu"
78 #define STRNCMPI                   strncasecmp
79 #define STRCMPI                    strcasecmp
80 #define STRDUP                     SystemStrDup
81 #define TB_FASTCALL // __attribute__((__regparm__(3)))
82
83 #else
84
85 #error "Unknown compiler, please edit compiler.h"
86
87 #endif /* What compiler?! */
88
89 #endif /* COMPILER_H_ */