2013-03-22 05:30:31 +04:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
|
|
|
* $Id: triodef.h,v 1.36 2010/09/12 11:08:08 breese Exp $
|
|
|
|
*
|
|
|
|
* Copyright (C) 2001 Bjorn Reese <breese@users.sourceforge.net>
|
|
|
|
*
|
|
|
|
* Permission to use, copy, modify, and distribute this software for any
|
|
|
|
* purpose with or without fee is hereby granted, provided that the above
|
|
|
|
* copyright notice and this permission notice appear in all copies.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
|
|
|
|
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
|
|
|
|
* MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE AUTHORS AND
|
|
|
|
* CONTRIBUTORS ACCEPT NO RESPONSIBILITY IN ANY CONCEIVABLE MANNER.
|
|
|
|
*
|
|
|
|
************************************************************************/
|
|
|
|
|
|
|
|
#ifndef TRIO_TRIODEF_H
|
|
|
|
#define TRIO_TRIODEF_H
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
* Compiler support detection
|
|
|
|
*/
|
|
|
|
|
|
|
|
#if defined(__GNUC__)
|
2019-11-06 17:24:51 +03:00
|
|
|
#define TRIO_COMPILER_GCC
|
2013-03-22 05:30:31 +04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(__SUNPRO_CC)
|
2019-11-06 17:24:51 +03:00
|
|
|
#define TRIO_COMPILER_SUNPRO __SUNPRO_CC
|
2013-03-22 05:30:31 +04:00
|
|
|
#else
|
2019-11-06 17:24:51 +03:00
|
|
|
#if defined(__SUNPRO_C)
|
|
|
|
#define TRIO_COMPILER_SUNPRO __SUNPRO_C
|
|
|
|
#endif
|
2013-03-22 05:30:31 +04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(__xlC__) || defined(__IBMC__) || defined(__IBMCPP__)
|
2019-11-06 17:24:51 +03:00
|
|
|
#define TRIO_COMPILER_XLC
|
2013-03-22 05:30:31 +04:00
|
|
|
#else
|
2019-11-06 17:24:51 +03:00
|
|
|
#if defined(_AIX) && !defined(__GNUC__)
|
|
|
|
#define TRIO_COMPILER_XLC /* Workaround for old xlc */
|
|
|
|
#endif
|
2013-03-22 05:30:31 +04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(__DECC) || defined(__DECCXX)
|
2019-11-06 17:24:51 +03:00
|
|
|
#define TRIO_COMPILER_DECC
|
2013-03-22 05:30:31 +04:00
|
|
|
#else
|
2019-11-06 17:24:51 +03:00
|
|
|
#if defined(__osf__) && defined(__LANGUAGE_C__) && !defined(__GNUC__)
|
|
|
|
#define TRIO_COMPILER_DECC /* Workaround for old DEC C compilers */
|
|
|
|
#endif
|
2013-03-22 05:30:31 +04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(__HP_aCC) || defined(__HP_cc)
|
2019-11-06 17:24:51 +03:00
|
|
|
#define TRIO_COMPILER_HP
|
2013-03-22 05:30:31 +04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(sgi) || defined(__sgi)
|
2019-11-06 17:24:51 +03:00
|
|
|
#define TRIO_COMPILER_MIPSPRO
|
2013-03-22 05:30:31 +04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(_MSC_VER)
|
2019-11-06 17:24:51 +03:00
|
|
|
#define TRIO_COMPILER_MSVC
|
2013-03-22 05:30:31 +04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(__BORLANDC__)
|
2019-11-06 17:24:51 +03:00
|
|
|
#define TRIO_COMPILER_BCB
|
2013-03-22 05:30:31 +04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
* Platform support detection
|
|
|
|
*/
|
|
|
|
|
|
|
|
#if defined(VMS) || defined(__VMS)
|
2019-11-06 17:24:51 +03:00
|
|
|
#define TRIO_PLATFORM_VMS
|
2013-03-22 05:30:31 +04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(unix) || defined(__unix) || defined(__unix__)
|
2019-11-06 17:24:51 +03:00
|
|
|
#define TRIO_PLATFORM_UNIX
|
2013-03-22 05:30:31 +04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(TRIO_COMPILER_XLC) || defined(_AIX)
|
2019-11-06 17:24:51 +03:00
|
|
|
#define TRIO_PLATFORM_UNIX
|
2013-03-22 05:30:31 +04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(TRIO_COMPILER_DECC) || defined(__osf___)
|
2019-11-06 17:24:51 +03:00
|
|
|
#if !defined(TRIO_PLATFORM_VMS)
|
|
|
|
#define TRIO_PLATFORM_UNIX
|
|
|
|
#endif
|
2013-03-22 05:30:31 +04:00
|
|
|
#endif
|
|
|
|
|
2018-05-02 18:57:16 +03:00
|
|
|
#if defined(__NetBSD__) || defined(__FreeBSD__) || defined(__DragonFly__)
|
2019-11-06 17:24:51 +03:00
|
|
|
#define TRIO_PLATFORM_UNIX
|
2013-03-22 05:30:31 +04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(__Lynx__)
|
2019-11-06 17:24:51 +03:00
|
|
|
#define TRIO_PLATFORM_UNIX
|
|
|
|
#define TRIO_PLATFORM_LYNX
|
2013-03-22 05:30:31 +04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(__APPLE__) && defined(__MACH__)
|
2019-11-06 17:24:51 +03:00
|
|
|
#define TRIO_PLATFORM_UNIX
|
2013-03-22 05:30:31 +04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(__QNX__)
|
2019-11-06 17:24:51 +03:00
|
|
|
#define TRIO_PLATFORM_UNIX
|
|
|
|
#define TRIO_PLATFORM_QNX
|
2013-03-22 05:30:31 +04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(__CYGWIN__)
|
2019-11-06 17:24:51 +03:00
|
|
|
#define TRIO_PLATFORM_UNIX
|
2013-03-22 05:30:31 +04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(AMIGA) && defined(TRIO_COMPILER_GCC)
|
2019-11-06 17:24:51 +03:00
|
|
|
#define TRIO_PLATFORM_UNIX
|
2013-03-22 05:30:31 +04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(TRIO_COMPILER_MSVC) || defined(WIN32) || defined(_WIN32)
|
2019-11-06 17:24:51 +03:00
|
|
|
#define TRIO_PLATFORM_WIN32
|
2013-03-22 05:30:31 +04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(_WIN32_WCE)
|
2019-11-06 17:24:51 +03:00
|
|
|
#define TRIO_PLATFORM_WINCE
|
2013-03-22 05:30:31 +04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(mpeix) || defined(__mpexl)
|
2019-11-06 17:24:51 +03:00
|
|
|
#define TRIO_PLATFORM_MPEIX
|
2013-03-22 05:30:31 +04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(_AIX)
|
2019-11-06 17:24:51 +03:00
|
|
|
#define TRIO_PLATFORM_AIX
|
2013-03-22 05:30:31 +04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(__hpux)
|
2019-11-06 17:24:51 +03:00
|
|
|
#define TRIO_PLATFORM_HPUX
|
2013-03-22 05:30:31 +04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(sun) || defined(__sun__)
|
2019-11-06 17:24:51 +03:00
|
|
|
#if defined(__SVR4) || defined(__svr4__)
|
|
|
|
#define TRIO_PLATFORM_SOLARIS
|
|
|
|
#else
|
|
|
|
#define TRIO_PLATFORM_SUNOS
|
|
|
|
#endif
|
2013-03-22 05:30:31 +04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
* Standards support detection
|
|
|
|
*/
|
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
#if defined(__STDC__) || defined(_MSC_EXTENSIONS) || defined(TRIO_COMPILER_BCB)
|
|
|
|
#define PREDEF_STANDARD_C89
|
2013-03-22 05:30:31 +04:00
|
|
|
#endif
|
|
|
|
#if defined(__STDC_VERSION__)
|
2019-11-06 17:24:51 +03:00
|
|
|
#define PREDEF_STANDARD_C90
|
2013-03-22 05:30:31 +04:00
|
|
|
#endif
|
|
|
|
#if (__STDC_VERSION__ - 0 >= 199409L)
|
2019-11-06 17:24:51 +03:00
|
|
|
#define PREDEF_STANDARD_C94
|
2013-03-22 05:30:31 +04:00
|
|
|
#endif
|
|
|
|
#if (__STDC_VERSION__ - 0 >= 199901L)
|
2019-11-06 17:24:51 +03:00
|
|
|
#define PREDEF_STANDARD_C99
|
2013-03-22 05:30:31 +04:00
|
|
|
#endif
|
|
|
|
#if defined(TRIO_COMPILER_SUNPRO) && (TRIO_COMPILER_SUNPRO >= 0x420)
|
2019-11-06 17:24:51 +03:00
|
|
|
#if !defined(PREDEF_STANDARD_C94)
|
|
|
|
#define PREDEF_STANDARD_C94
|
|
|
|
#endif
|
2013-03-22 05:30:31 +04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(__cplusplus)
|
2019-11-06 17:24:51 +03:00
|
|
|
#define PREDEF_STANDARD_CXX
|
|
|
|
#if __cplusplus - 0 >= 199711L
|
|
|
|
#define PREDEF_STANDARD_CXX89
|
|
|
|
#endif
|
2013-03-22 05:30:31 +04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(TRIO_PLATFORM_UNIX)
|
2019-11-06 17:24:51 +03:00
|
|
|
#include <unistd.h>
|
2013-03-22 05:30:31 +04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(_POSIX_VERSION)
|
2019-11-06 17:24:51 +03:00
|
|
|
#define PREDEF_STANDARD_POSIX _POSIX_VERSION
|
|
|
|
#if (_POSIX_VERSION >= 199506L)
|
|
|
|
#define PREDEF_STANDARD_POSIX_1996
|
|
|
|
#endif
|
2013-03-22 05:30:31 +04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if (_XOPEN_VERSION - 0 >= 3) || defined(_XOPEN_XPG3)
|
2019-11-06 17:24:51 +03:00
|
|
|
#define PREDEF_STANDARD_XPG3
|
2013-03-22 05:30:31 +04:00
|
|
|
#endif
|
|
|
|
#if (_XOPEN_VERSION - 0 >= 4) || defined(_XOPEN_XPG4)
|
2019-11-06 17:24:51 +03:00
|
|
|
#define PREDEF_STANDARD_XPG4
|
2013-03-22 05:30:31 +04:00
|
|
|
#endif
|
2019-11-06 17:24:51 +03:00
|
|
|
#if (_XOPEN_VERSION - 0 > 4) || (defined(_XOPEN_UNIX) && (_XOPEN_VERSION - 0 == 4))
|
|
|
|
#define PREDEF_STANDARD_UNIX95
|
2013-03-22 05:30:31 +04:00
|
|
|
#endif
|
|
|
|
#if (_XOPEN_VERSION - 0 >= 500)
|
2019-11-06 17:24:51 +03:00
|
|
|
#define PREDEF_STANDARD_UNIX98
|
2013-03-22 05:30:31 +04:00
|
|
|
#endif
|
|
|
|
#if (_XOPEN_VERSION - 0 >= 600)
|
2019-11-06 17:24:51 +03:00
|
|
|
#define PREDEF_STANDARD_UNIX03
|
2013-03-22 05:30:31 +04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
* Generic defines
|
|
|
|
*/
|
|
|
|
|
|
|
|
#if !defined(TRIO_PUBLIC)
|
2019-11-06 17:24:51 +03:00
|
|
|
#define TRIO_PUBLIC
|
2013-03-22 05:30:31 +04:00
|
|
|
#endif
|
|
|
|
#if !defined(TRIO_PRIVATE)
|
2019-11-06 17:24:51 +03:00
|
|
|
#define TRIO_PRIVATE static
|
2013-03-22 05:30:31 +04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if !(defined(PREDEF_STANDARD_C89) || defined(PREDEF_STANDARD_CXX))
|
2019-11-06 17:24:51 +03:00
|
|
|
#define TRIO_COMPILER_ANCIENT
|
2013-03-22 05:30:31 +04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(TRIO_COMPILER_ANCIENT)
|
2019-11-06 17:24:51 +03:00
|
|
|
#define TRIO_CONST
|
|
|
|
#define TRIO_VOLATILE
|
|
|
|
#define TRIO_SIGNED
|
2013-03-22 05:30:31 +04:00
|
|
|
typedef double trio_long_double_t;
|
2019-11-06 17:24:51 +03:00
|
|
|
typedef char* trio_pointer_t;
|
|
|
|
#define TRIO_SUFFIX_LONG(x) x
|
|
|
|
#define TRIO_PROTO(x) ()
|
|
|
|
#define TRIO_NOARGS
|
|
|
|
#define TRIO_ARGS1(list, a1) list a1;
|
|
|
|
#define TRIO_ARGS2(list, a1, a2) \
|
|
|
|
list a1; \
|
|
|
|
a2;
|
|
|
|
#define TRIO_ARGS3(list, a1, a2, a3) \
|
|
|
|
list a1; \
|
|
|
|
a2; \
|
|
|
|
a3;
|
|
|
|
#define TRIO_ARGS4(list, a1, a2, a3, a4) \
|
|
|
|
list a1; \
|
|
|
|
a2; \
|
|
|
|
a3; \
|
|
|
|
a4;
|
|
|
|
#define TRIO_ARGS5(list, a1, a2, a3, a4, a5) \
|
|
|
|
list a1; \
|
|
|
|
a2; \
|
|
|
|
a3; \
|
|
|
|
a4; \
|
|
|
|
a5;
|
|
|
|
#define TRIO_ARGS6(list, a1, a2, a3, a4, a5, a6) \
|
|
|
|
list a1; \
|
|
|
|
a2; \
|
|
|
|
a3; \
|
|
|
|
a4; \
|
|
|
|
a5; \
|
|
|
|
a6;
|
|
|
|
#define TRIO_ARGS7(list, a1, a2, a3, a4, a5, a6, a7) \
|
|
|
|
list a1; \
|
|
|
|
a2; \
|
|
|
|
a3; \
|
|
|
|
a4; \
|
|
|
|
a5; \
|
|
|
|
a6; \
|
|
|
|
a7;
|
|
|
|
#define TRIO_ARGS8(list, a1, a2, a3, a4, a5, a6, a7, a8) \
|
|
|
|
list a1; \
|
|
|
|
a2; \
|
|
|
|
a3; \
|
|
|
|
a4; \
|
|
|
|
a5; \
|
|
|
|
a6; \
|
|
|
|
a7; \
|
|
|
|
a8;
|
|
|
|
#define TRIO_VARGS2(list, a1, a2) \
|
|
|
|
list a1; \
|
|
|
|
a2
|
|
|
|
#define TRIO_VARGS3(list, a1, a2, a3) \
|
|
|
|
list a1; \
|
|
|
|
a2; \
|
|
|
|
a3
|
|
|
|
#define TRIO_VARGS4(list, a1, a2, a3, a4) \
|
|
|
|
list a1; \
|
|
|
|
a2; \
|
|
|
|
a3; \
|
|
|
|
a4
|
|
|
|
#define TRIO_VARGS5(list, a1, a2, a3, a4, a5) \
|
|
|
|
list a1; \
|
|
|
|
a2; \
|
|
|
|
a3; \
|
|
|
|
a4; \
|
|
|
|
a5
|
|
|
|
#define TRIO_VA_DECL va_dcl
|
|
|
|
#define TRIO_VA_START(x, y) va_start(x)
|
|
|
|
#define TRIO_VA_END(x) va_end(x)
|
2013-03-22 05:30:31 +04:00
|
|
|
#else /* ANSI C */
|
2019-11-06 17:24:51 +03:00
|
|
|
#define TRIO_CONST const
|
|
|
|
#define TRIO_VOLATILE volatile
|
|
|
|
#define TRIO_SIGNED signed
|
2013-03-22 05:30:31 +04:00
|
|
|
typedef long double trio_long_double_t;
|
2019-11-06 17:24:51 +03:00
|
|
|
typedef void* trio_pointer_t;
|
|
|
|
#define TRIO_SUFFIX_LONG(x) x##L
|
|
|
|
#define TRIO_PROTO(x) x
|
|
|
|
#define TRIO_NOARGS void
|
|
|
|
#define TRIO_ARGS1(list, a1) (a1)
|
|
|
|
#define TRIO_ARGS2(list, a1, a2) (a1, a2)
|
|
|
|
#define TRIO_ARGS3(list, a1, a2, a3) (a1, a2, a3)
|
|
|
|
#define TRIO_ARGS4(list, a1, a2, a3, a4) (a1, a2, a3, a4)
|
|
|
|
#define TRIO_ARGS5(list, a1, a2, a3, a4, a5) (a1, a2, a3, a4, a5)
|
|
|
|
#define TRIO_ARGS6(list, a1, a2, a3, a4, a5, a6) (a1, a2, a3, a4, a5, a6)
|
|
|
|
#define TRIO_ARGS7(list, a1, a2, a3, a4, a5, a6, a7) (a1, a2, a3, a4, a5, a6, a7)
|
|
|
|
#define TRIO_ARGS8(list, a1, a2, a3, a4, a5, a6, a7, a8) (a1, a2, a3, a4, a5, a6, a7, a8)
|
|
|
|
#define TRIO_VARGS2 TRIO_ARGS2
|
|
|
|
#define TRIO_VARGS3 TRIO_ARGS3
|
|
|
|
#define TRIO_VARGS4 TRIO_ARGS4
|
|
|
|
#define TRIO_VARGS5 TRIO_ARGS5
|
|
|
|
#define TRIO_VA_DECL ...
|
|
|
|
#define TRIO_VA_START(x, y) va_start(x, y)
|
|
|
|
#define TRIO_VA_END(x) va_end(x)
|
2013-03-22 05:30:31 +04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(PREDEF_STANDARD_C99) || defined(PREDEF_STANDARD_CXX)
|
2019-11-06 17:24:51 +03:00
|
|
|
#define TRIO_INLINE inline
|
2013-03-22 05:30:31 +04:00
|
|
|
#else
|
2019-11-06 17:24:51 +03:00
|
|
|
#if defined(TRIO_COMPILER_GCC)
|
|
|
|
#define TRIO_INLINE __inline__
|
|
|
|
#endif
|
|
|
|
#if defined(TRIO_COMPILER_MSVC)
|
|
|
|
#define TRIO_INLINE _inline
|
|
|
|
#endif
|
|
|
|
#if defined(TRIO_COMPILER_BCB)
|
|
|
|
#define TRIO_INLINE __inline
|
|
|
|
#endif
|
2013-03-22 05:30:31 +04:00
|
|
|
#endif
|
|
|
|
#if !defined(TRIO_INLINE)
|
2019-11-06 17:24:51 +03:00
|
|
|
#define TRIO_INLINE
|
2013-03-22 05:30:31 +04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
* Workarounds
|
|
|
|
*/
|
|
|
|
|
|
|
|
#if defined(TRIO_PLATFORM_VMS)
|
|
|
|
/*
|
|
|
|
* Computations done with constants at compile time can trigger these
|
|
|
|
* even when compiling with IEEE enabled.
|
|
|
|
*/
|
2019-11-06 17:24:51 +03:00
|
|
|
#pragma message disable(UNDERFLOW, FLOATOVERFL)
|
2013-03-22 05:30:31 +04:00
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
#if (__CRTL_VER < 80210001)
|
2013-03-22 05:30:31 +04:00
|
|
|
/*
|
|
|
|
* Although the compiler supports C99 language constructs, the C
|
|
|
|
* run-time library does not contain all C99 functions.
|
|
|
|
*/
|
2019-11-06 17:24:51 +03:00
|
|
|
#if defined(PREDEF_STANDARD_C99)
|
|
|
|
#undef PREDEF_STANDARD_C99
|
|
|
|
#endif
|
|
|
|
#endif
|
2013-03-22 05:30:31 +04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Not all preprocessors supports the LL token.
|
|
|
|
*/
|
|
|
|
#if defined(TRIO_COMPILER_MSVC) || defined(TRIO_COMPILER_BCB)
|
|
|
|
#else
|
2019-11-06 17:24:51 +03:00
|
|
|
#define TRIO_COMPILER_SUPPORTS_LL
|
2013-03-22 05:30:31 +04:00
|
|
|
#endif
|
|
|
|
|
2015-05-05 21:27:17 +03:00
|
|
|
#if defined(TRIO_PLATFORM_UNIX) && !defined(HAVE_MATH_C99_LONG_DOUBLE)
|
2019-11-06 17:24:51 +03:00
|
|
|
#define TRIO_NO_FLOORL 1
|
|
|
|
#define TRIO_NO_CEILL 1
|
|
|
|
#define TRIO_NO_POWL 1
|
|
|
|
#define TRIO_NO_FMODL 1
|
|
|
|
#define TRIO_NO_LOG10L 1
|
2013-03-22 05:30:31 +04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif /* TRIO_TRIODEF_H */
|