source: branches/gcc-kmk/include/odin.h@ 21787

Last change on this file since 21787 was 21787, checked in by dmik, 14 years ago

Workaround stdcall bug in GCC related to vararg functions.

This can be easily removed once GCC gets fixed.

File size: 4.0 KB
Line 
1/*
2 * ODIN - Build Environment Definition
3 *
4 * Copyright (C) 1999 Patrick Haller <phaller@gmx.net>
5 *
6 * ------------------------------------------------------------
7 * Note: Only compiler linkage definitions and similar stuff
8 * goes here. Nothing else.
9 * ------------------------------------------------------------
10 *
11 */
12
13
14#ifndef _ODIN_H_
15#define _ODIN_H_
16
17
18/***********************************
19 * Compiler Environment Definition *
20 ***********************************/
21
22#ifdef CDECL
23# undef CDECL
24#endif
25
26#ifdef EXPORT
27# undef EXPORT
28#endif
29
30#ifdef WIN32API
31# undef WIN32API
32#endif
33
34#ifdef SYSTEM
35# undef SYSTEM
36#endif
37
38#ifdef PASCAL
39# undef PASCAL
40#endif
41
42#ifdef UNALIGNED
43# undef UNALIGNED
44#endif
45
46
47/* ---------- WATCOM C ---------- */
48#ifdef __WATCOMC__
49 #define CDECL _cdecl
50 #define EXPORT _export
51 #define WIN32API __stdcall
52 #define WINAPI __stdcall
53 #define SYSTEM _System
54 #define PASCAL __stdcall
55 #ifdef __cplusplus
56 #define INLINE inline
57 #else
58 #define INLINE __inline
59 #define inline __inline
60 #endif
61 #define UNALIGNED
62 #define __attribute__(x)
63
64//MN: For some strange reason Watcom doesn't define these for C++!
65// This is not the best place to define them though.
66#ifdef __cplusplus
67 #define min(a,b) (((a) < (b)) ? (a) : (b))
68 #define max(a,b) (((a) > (b)) ? (a) : (b))
69#endif
70
71#else
72
73/* ---------- GCC/EMX ---------- */
74#ifdef __GNUC__
75 #if defined(__GNUC__) && (__GNUC__ <= 3) && (__GNUC_MINOR__ < 2)
76 #error You need gcc >= 3.2 to build Odin32
77 #endif
78 #if !defined(__stdcall__) /* this is also defined in windef.h if !defined(WIN32OS2) */
79 #define __stdcall __attribute__((__stdcall__))
80 #define __cdecl __attribute__((__cdecl__))
81 #endif
82 #define CDECL _cdecl
83 #define EXPORT __attribute__ ((dllexport))
84 #define WIN32API __stdcall
85 #define WINAPI __stdcall
86 #define PASCAL __stdcall
87 #define INLINE static __inline__
88 #define UNALIGNED
89 #if (__GNUC__ < 4)
90 #define NONAMELESSUNION
91 #define NONAMELESSSTRUCT
92 #endif
93 #ifdef __INNOTEK_LIBC__
94 #define SYSTEM _System
95 #else
96 #define SYSTEM CDECL
97 #endif
98
99 #define min(a,b) \
100 ({ __typeof__ (a) _a = (a); \
101 __typeof__ (b) _b = (b); \
102 _a < _b ? _a : _b; })
103 #define max(a,b) \
104 ({ __typeof__ (a) _a = (a); \
105 __typeof__ (b) _b = (b); \
106 _a > _b ? _a : _b; })
107
108 #define _interrupt(n) __asm__ __volatile__ ("int" #n "\n\tnop")
109
110#else
111
112/* ---------- VAC ---------- */
113#if (defined(__IBMCPP__) || defined(__IBMC__))
114
115 #define CDECL __cdecl
116 #define EXPORT _Export
117 #define WIN32API __stdcall
118 #define WINAPI __stdcall
119 #define SYSTEM _System
120 #define PASCAL __stdcall
121 #define UNALIGNED
122 #ifndef __cplusplus
123 #define INLINE _Inline
124 #ifndef inline
125 #define inline INLINE
126 #endif
127 #else
128 #define INLINE inline
129 #endif
130 #define __inline__ INLINE
131 #define __attribute__(x)
132
133
134#ifndef RC_INVOKED
135 //Nameless unions or structures are not supported in C mode
136 //(nameless unions only in CPP mode and nameless unions only in VAC 3.6.5 CPP mode)
137 #ifdef __IBMC__
138 #define NONAMELESSUNION
139 #define NONAMELESSSTRUCT
140 #endif
141 #if (__IBMCPP__ == 300)
142 #define NONAMELESSSTRUCT
143 #endif
144#endif
145
146#ifndef RC_INVOKED
147 #include <builtin.h>
148#endif
149
150#else
151#ifdef RC_INVOKED
152 //SvL: wrc chokes on calling conventions....
153 #define CDECL
154 #define EXPORT
155 #define WIN32API
156 #define WINAPI
157 #define CALLBACK
158 #define SYSTEM
159 #define PASCAL
160 #define UNALIGNED
161 #define __cdecl
162 #define _System
163 #define __inline__
164 #define INLINE
165#else
166/* ---------- ??? ---------- */
167#error No known compiler.
168#endif
169#endif
170#endif
171#endif
172
173#ifdef __GNUC__
174// __stdcall in GCC for OS/2 incorrectly mangles vararg functions; according to
175// MSDN, they should be equal to __cdecl instead of getting the @N suffix
176#define WIN32API_VA __cdecl
177#else
178#define WIN32API_VA WIN32API
179#endif
180
181#endif /* _ODIN_H_*/
182
Note: See TracBrowser for help on using the repository browser.