blob: e9b62e59cf64f1b4c79851315e2ea85b71272968 [file] [log] [blame]
Bjorn Reese45029602001-08-21 09:23:53 +00001/*************************************************************************
2 *
3 * $Id$
4 *
5 * Copyright (C) 2001 Bjorn Reese <breese@users.sourceforge.net>
6 *
7 * Permission to use, copy, modify, and distribute this software for any
8 * purpose with or without fee is hereby granted, provided that the above
9 * copyright notice and this permission notice appear in all copies.
10 *
11 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
12 * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
13 * MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE AUTHORS AND
14 * CONTRIBUTORS ACCEPT NO RESPONSIBILITY IN ANY CONCEIVABLE MANNER.
15 *
16 ************************************************************************/
17
Bjorn Reese026d29f2002-01-19 15:40:18 +000018#ifndef TRIO_TRIODEF_H
19#define TRIO_TRIODEF_H
Bjorn Reese45029602001-08-21 09:23:53 +000020
21/*************************************************************************
22 * Platform and compiler support detection
23 */
24#if defined(__GNUC__)
25# define TRIO_COMPILER_GCC
26#elif defined(__SUNPRO_C)
27# define TRIO_COMPILER_SUNPRO
28#elif defined(__SUNPRO_CC)
29# define TRIO_COMPILER_SUNPRO
30# define __SUNPRO_C __SUNPRO_CC
31#elif defined(__xlC__) || defined(__IBMC__) || defined(__IBMCPP__)
32# define TRIO_COMPILER_XLC
33#elif defined(_AIX) && !defined(__GNUC__)
34# define TRIO_COMPILER_XLC /* Workaround for old xlc */
35#elif defined(__DECC) || defined(__DECCXX)
36# define TRIO_COMPILER_DECC
Daniel Veillardb7c29c32002-09-25 22:44:43 +000037#elif defined(__osf__) && defined(__LANGUAGE_C__)
38# define TRIO_COMPILER_DECC /* Workaround for old DEC C compilers */
Bjorn Reese45029602001-08-21 09:23:53 +000039#elif defined(_MSC_VER)
40# define TRIO_COMPILER_MSVC
Daniel Veillardb7c29c32002-09-25 22:44:43 +000041#elif defined(__BORLANDC__)
42# define TRIO_COMPILER_BCB
Bjorn Reese45029602001-08-21 09:23:53 +000043#endif
44
45#if defined(unix) || defined(__unix) || defined(__unix__)
46# define TRIO_PLATFORM_UNIX
47#elif defined(TRIO_COMPILER_XLC) || defined(_AIX)
48# define TRIO_PLATFORM_UNIX
49#elif defined(TRIO_COMPILER_DECC) || defined(__osf__)
50# define TRIO_PLATFORM_UNIX
51#elif defined(__NetBSD__)
52# define TRIO_PLATFORM_UNIX
53#elif defined(__QNX__)
54# define TRIO_PLATFORM_UNIX
Bjorn Reese026d29f2002-01-19 15:40:18 +000055# define TRIO_PLATFORM_QNX
Daniel Veillard3c5ed912002-01-08 10:36:16 +000056#elif defined(__CYGWIN__)
57# define TRIO_PLATFORM_UNIX
Bjorn Reese45029602001-08-21 09:23:53 +000058#elif defined(AMIGA) && defined(TRIO_COMPILER_GCC)
59# define TRIO_PLATFORM_UNIX
60#elif defined(TRIO_COMPILER_MSVC) || defined(WIN32) || defined(_WIN32)
61# define TRIO_PLATFORM_WIN32
Bjorn Reese026d29f2002-01-19 15:40:18 +000062#elif defined(VMS) || defined(__VMS)
63# define TRIO_PLATFORM_VMS
64#elif defined(mpeix) || defined(__mpexl)
65# define TRIO_PLATFORM_MPEIX
Bjorn Reese45029602001-08-21 09:23:53 +000066#endif
67
Daniel Veillardb7c29c32002-09-25 22:44:43 +000068#if defined(__STDC__) || defined(TRIO_COMPILER_MSVC)
69# define TRIO_COMPILER_SUPPORTS_C89
Bjorn Reese45029602001-08-21 09:23:53 +000070# if defined(__STDC_VERSION__)
Daniel Veillardb7c29c32002-09-25 22:44:43 +000071# define TRIO_COMPILER_SUPPORTS_C90
Bjorn Reese45029602001-08-21 09:23:53 +000072# if (__STDC_VERSION__ >= 199409L)
73# define TRIO_COMPILER_SUPPORTS_C94
74# endif
75# if (__STDC_VERSION__ >= 199901L)
76# define TRIO_COMPILER_SUPPORTS_C99
77# endif
78# elif defined(TRIO_COMPILER_SUNPRO)
79# if (__SUNPRO_C >= 0x420)
80# define TRIO_COMPILER_SUPPORTS_C94
81# endif
82# endif
83#endif
84
85#if defined(_XOPEN_SOURCE)
86# if defined(_XOPEN_SOURCE_EXTENDED)
87# define TRIO_COMPILER_SUPPORTS_UNIX95
88# endif
89# if (_XOPEN_VERSION >= 500)
90# define TRIO_COMPILER_SUPPORTS_UNIX98
91# endif
Daniel Veillardb7c29c32002-09-25 22:44:43 +000092# if (_XOPEN_VERSION >= 600)
93# define TRIO_COMPILER_SUPPORTS_UNIX01
94# endif
Bjorn Reese45029602001-08-21 09:23:53 +000095#endif
96
Bjorn Reese026d29f2002-01-19 15:40:18 +000097/*************************************************************************
98 * Generic defines
99 */
100
101#if !defined(TRIO_PUBLIC)
102# define TRIO_PUBLIC
103#endif
104#if !defined(TRIO_PRIVATE)
105# define TRIO_PRIVATE static
106#endif
107
Daniel Veillardb7c29c32002-09-25 22:44:43 +0000108#if !(defined(TRIO_COMPILER_SUPPORTS_C89) || defined(__cplusplus))
109# define TRIO_COMPILER_ANCIENT
110#endif
111
112#if defined(TRIO_COMPILER_ANCIENT)
Bjorn Reese026d29f2002-01-19 15:40:18 +0000113# define TRIO_CONST
114# define TRIO_VOLATILE
Daniel Veillardb7c29c32002-09-25 22:44:43 +0000115# define TRIO_SIGNED
116typedef double trio_long_double_t;
117typedef char * trio_pointer_t;
118# define TRIO_SUFFIX_LONG(x) x
Bjorn Reese026d29f2002-01-19 15:40:18 +0000119# define TRIO_PROTO(x) ()
Daniel Veillardb7c29c32002-09-25 22:44:43 +0000120# define TRIO_NOARGS
121# define TRIO_ARGS1(list,a1) list a1;
122# define TRIO_ARGS2(list,a1,a2) list a1; a2;
123# define TRIO_ARGS3(list,a1,a2,a3) list a1; a2; a3;
124# define TRIO_ARGS4(list,a1,a2,a3,a4) list a1; a2; a3; a4;
125# define TRIO_ARGS5(list,a1,a2,a3,a4,a5) list a1; a2; a3; a4; a5;
126# define TRIO_ARGS6(list,a1,a2,a3,a4,a5,a6) list a1; a2; a3; a4; a5; a6;
127# define TRIO_VARGS2(list,a1,a2) list a1; a2
128# define TRIO_VARGS3(list,a1,a2,a3) list a1; a2; a3
129# define TRIO_VARGS4(list,a1,a2,a3,a4) list a1; a2; a3; a4
130# define TRIO_VARGS5(list,a1,a2,a3,a4,a5) list a1; a2; a3; a4; a5
131# define TRIO_VA_DECL va_dcl
132# define TRIO_VA_START(x,y) va_start((x))
133# define TRIO_VA_END(x) va_end(x)
134#else /* ANSI C */
135# define TRIO_CONST const
136# define TRIO_VOLATILE volatile
137# define TRIO_SIGNED signed
138typedef long double trio_long_double_t;
139typedef void * trio_pointer_t;
140# define TRIO_SUFFIX_LONG(x) x ## L
141# define TRIO_PROTO(x) x
142# define TRIO_NOARGS void
143# define TRIO_ARGS1(list,a1) (a1)
144# define TRIO_ARGS2(list,a1,a2) (a1,a2)
145# define TRIO_ARGS3(list,a1,a2,a3) (a1,a2,a3)
146# define TRIO_ARGS4(list,a1,a2,a3,a4) (a1,a2,a3,a4)
147# define TRIO_ARGS5(list,a1,a2,a3,a4,a5) (a1,a2,a3,a4,a5)
148# define TRIO_ARGS6(list,a1,a2,a3,a4,a5,a6) (a1,a2,a3,a4,a5,a6)
149# define TRIO_VARGS2 TRIO_ARGS2
150# define TRIO_VARGS3 TRIO_ARGS3
151# define TRIO_VARGS4 TRIO_ARGS4
152# define TRIO_VARGS5 TRIO_ARGS5
153# define TRIO_VA_DECL ...
154# define TRIO_VA_START(x,y) va_start((x),(y))
155# define TRIO_VA_END(x) va_end(x)
Bjorn Reese026d29f2002-01-19 15:40:18 +0000156#endif
157
158#if defined(TRIO_COMPILER_SUPPORTS_C99) || defined(__cplusplus)
159# define TRIO_INLINE inline
160#elif defined(TRIO_COMPILER_GCC)
161# define TRIO_INLINE __inline__
Daniel Veillardb7c29c32002-09-25 22:44:43 +0000162#elif defined(TRIO_COMPILER_MSVC)
163# define TRIO_INLINE _inline
164#elif defined(TRIO_COMPILER_BCB)
165# define TRIO_INLINE __inline
Bjorn Reese026d29f2002-01-19 15:40:18 +0000166#else
167# define TRIO_INLINE
168#endif
169
170#endif /* TRIO_TRIODEF_H */