dyncall/dyncall_macros.h

Sat, 27 May 2017 19:57:34 +0200

author
Tassilo Philipp
date
Sat, 27 May 2017 19:57:34 +0200
changeset 268
03f0b683918a
parent 261
b625f2e11911
child 281
f5577f6bf97a
permissions
-rw-r--r--

- reintroduced .note.GNU-stack section, as mentioned in prev commit

     1 /*
     3  Package: dyncall
     4  Library: dyncall
     5  File: dyncall/dyncall_macros.h
     6  Description: Platform detection macros
     7  License:
     9    Copyright (c) 2007-2015 Daniel Adler <dadler@uni-goettingen.de>,
    10                            Tassilo Philipp <tphilipp@potion-studios.com>
    12    Permission to use, copy, modify, and distribute this software for any
    13    purpose with or without fee is hereby granted, provided that the above
    14    copyright notice and this permission notice appear in all copies.
    16    THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
    17    WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
    18    MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
    19    ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
    20    WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
    21    ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
    22    OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
    24 */
    28 /*
    30   dyncall macros
    32   Platform detection, specific defines and configuration.
    33   The purpose of this file is to provide coherent platform and compiler
    34   specific defines. So instead of defines like WIN32, _OpenBSD_ or
    35   __GNUC__, one should use DC__OS_Win32, DC__OS_OpenBSD or DC__C_GNU,
    36   respectively.
    38   REVISION
    39   2007/12/11 initial
    41 */
    44 #ifndef DYNCALL_MACROS_H
    45 #define DYNCALL_MACROS_H
    48 /* Platform specific defines. */
    50 /* MS Windows XP x64/Vista64 or later. */
    51 #if defined(WIN64) || defined(_WIN64) || defined(__WIN64__)
    52 #define DC__OS_Win64
    54 /* MS Windows NT/95/98/ME/2000/XP/Vista32. */
    55 #elif defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__NT__) || defined(__WINDOWS__) || defined(_WINDOWS)
    56 #define DC__OS_Win32
    58 /* All the OS' based on Darwin OS (MacOS X, OpenDarwin). Note that '__APPLE__' may be defined for classic MacOS, too. */
    59 /* __MACOSX__ is not defined in gcc assembler mode (switch: -S) */
    60 /* @@@ TODO: Check for Classic OS */
    62 #elif defined(__APPLE__) || defined(__Darwin__)
    63 #  define DC__OS_Darwin
    64 #  if defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__)
    65 #    define DC__OS_IPhone
    66 #  else /* defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) */
    67 #    define DC__OS_MacOSX
    68 #  endif
    70 /* The most popular open source Unix-like OS - Linux. */
    71 #elif defined(__linux__) || defined(__linux) || defined(__gnu_linux__)
    72 #define DC__OS_Linux
    74 /* The most powerful open source Unix-like OS - FreeBSD. */
    75 #elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) /* latter is (also) used by systems using FreeBSD kernel, e.g. Debian/kFreeBSD, which could be detected specifically by also checking for __GLIBC__ */
    76 #define DC__OS_FreeBSD
    78 /* The most secure open source Unix-like OS - OpenBSD. */
    79 #elif defined(__OpenBSD__)
    80 #define DC__OS_OpenBSD
    82 /* The most portable open source Unix-like OS - NetBSD. */
    83 #elif defined(__NetBSD__)
    84 #define DC__OS_NetBSD
    86 /* The FreeBSD fork having heavy clusterization in mind - DragonFlyBSD. */
    87 #elif defined(__DragonFly__)
    88 #define DC__OS_DragonFlyBSD
    90 /* Sun's Unix-like OS - SunOS / Solaris. */
    91 #elif defined(__sun__) || defined(__sun) || defined(sun)
    92 #define DC__OS_SunOS
    94 /* The "Linux-like environment for Windows" - Cygwin. */
    95 #elif defined(__CYGWIN__)
    96 #define DC__OS_Cygwin
    98 /* The "Minimalist GNU for Windows" - MinGW. */
    99 #elif defined(__MINGW__)/*@@@*/
   100 #define DC__OS_MinGW
   102 /* The Nintendo DS (homebrew) using devkitpro. */
   103 #elif defined(__nds__)
   104 #define DC__OS_NDS
   106 /* The PlayStation Portable (homebrew) SDK. */
   107 #elif defined(__psp__) || defined(PSP)
   108 #define DC__OS_PSP
   110 /* Haiku (BeOS alike). */
   111 #elif defined(__HAIKU__)
   112 #define DC__OS_BeOS
   114 /* The Unix successor - Plan9 from Bell Labs */
   115 #elif defined(Plan9) || defined(__Plan9__)
   116 #define DC__OS_Plan9
   118 /* Digital's Unix-like OS - VMS */
   119 #elif defined(__vms)
   120 #define DC__OS_VMS
   122 #elif defined(__minix)
   123 #define DC__OS_Minix
   125 #else
   127 /* Unable to determine OS, which is probably ok (e.g. baremetal stuff, etc.). */
   128 #define DC__OS_UNKNOWN
   129 #endif
   133 /* Compiler specific defines. Do not change the order, because  */
   134 /* some of the compilers define flags for compatible ones, too. */
   136 /* Intel's C/C++ compiler. */
   137 #if defined(__INTEL_COMPILER)
   138 #define DC__C_Intel
   140 /* MS C/C++ compiler. */
   141 #elif defined(_MSC_VER)
   142 #define DC__C_MSVC
   144 /* LLVM clang. */
   145 #elif defined(__clang__) || defined(__llvm__)
   146 #define DC__C_CLANG
   148 /* The GNU Compiler Collection - GCC. */
   149 #elif defined(__GNUC__)
   150 #define DC__C_GNU
   152 /* Watcom compiler. */
   153 #elif defined(__WATCOMC__)
   154 #define DC__C_WATCOM
   156 /* Portable C Compiler. */
   157 #elif defined(__PCC__)
   158 #define DC__C_PCC
   160 /* Sun Pro C. */
   161 #elif defined(__SUNPRO_C)
   162 #define DC__C_SUNPRO
   164 /* Undetected C Compiler. */
   165 #else
   166 #define DC__C_UNKNOWN
   167 #endif
   171 /* Architecture. */
   173 /* Check architecture. */
   174 #if defined(_M_X64_) || defined(_M_AMD64) || defined(__amd64__) || defined(__amd64) || defined(__x86_64__) || defined(__x86_64) 
   175 # define DC__Arch_AMD64
   176 #elif defined(_M_IX86) || defined(__i386__) || defined(__i486__) || defined(__i586__) || defined(__i686__) || defined(__386__) || defined(__i386)
   177 # define DC__Arch_Intel_x86
   178 #elif defined(_M_IA64) || defined(__ia64__)
   179 # define DC__Arch_Itanium
   180 #elif defined(_M_PPC) || defined(__powerpc__) || defined(__powerpc) || defined(__POWERPC__) || defined(__ppc__) || defined(__power__)
   181 # if defined(__ppc64__) || defined(_ARCH_PPC64) || defined(__power64__) || defined(__powerpc64__)
   182 #   define DC__Arch_PPC64
   183 # else
   184 #   define DC__Arch_PPC32
   185 # endif
   186 #elif defined(__mips64__) || defined(__mips64)
   187 # define DC__Arch_MIPS64
   188 #elif defined(_M_MRX000) || defined(__mips__) || defined(__mips) || defined(_mips)
   189 # define DC__Arch_MIPS
   190 #elif defined(__arm__)
   191 # define DC__Arch_ARM
   192 #elif defined(__aarch64__)
   193 # define DC__Arch_ARM64
   194 #elif defined(__sh__)
   195 # define DC__Arch_SuperH
   196 #elif defined(__sparc) || defined(__sparc__)
   197 # if defined(__sparcv9) || defined(__sparc_v9__) || defined(__sparc64__) || defined(__arch64__)
   198 #  define DC__Arch_Sparc64
   199 # else
   200 #  define DC__Arch_Sparc
   201 # endif
   202 #endif
   206 /* Rough OS classification. */
   208 #if defined(DC__OS_Win32) || defined(DC__OS_Win64)
   209 # define DC_WINDOWS
   210 #elif defined(DC__OS_Plan9)
   211 # define DC_PLAN9
   212 #elif defined(DC__OS_NDS) || defined(DC__OS_PSP)
   213 # define DC_OTHER
   214 #else
   215 # define DC_UNIX
   216 #endif
   220 /* Misc machine-dependent modes, ABIs, etc.. */
   222 #if defined(__arm__) && !defined(__thumb__)
   223 # define DC__Arch_ARM_ARM
   224 #elif defined(__arm__) && defined(__thumb__)
   225 # define DC__Arch_ARM_THUMB
   226 #endif
   228 #if defined(DC__Arch_ARM_ARM) || defined(DC__Arch_ARM_THUMB)
   229 # if defined(__ARM_EABI__) || defined(DC__OS_NDS)
   230 #  if defined (__ARM_PCS_VFP) && (__ARM_PCS_VFP == 1)
   231 #    define DC__ABI_ARM_HF
   232 #  else
   233 #    define DC__ABI_ARM_EABI
   234 #  endif
   235 # elif defined(__APCS_32__)
   236 #  define DC__ABI_ARM_OABI
   237 # endif
   238 #endif /* ARM */
   240 #if defined(DC__Arch_MIPS) || defined(DC__Arch_MIPS64)
   241 # if defined(_ABIO32) || defined(_MIPS_ARCH_MIPS1) || defined(_MIPS_ARCH_MIPS2)
   242 #  define DC__ABI_MIPS_O32
   243 # elif defined(_ABI64) || defined(_mips_n64)
   244 #  define DC__ABI_MIPS_N64
   245 # elif defined(_ABIN32)
   246 #  define DC__ABI_MIPS_N32
   247 # else
   248 #  define DC__ABI_MIPS_EABI
   249 # endif
   250 /*@@@implement/support: __mips_hard_float*/
   251 #endif /* MIPS */
   253 #if defined(DC__Arch_PPC64)
   254 # if defined(_CALL_ELF)
   255 #  define DC__ABI_PPC64_ELF_V _CALL_ELF
   256 # else
   257 #  define DC__ABI_PPC64_ELF_V 0 /* 0 means not explicitly set, otherwise this is 1 (big endian) and 2 (little endian) */
   258 # endif
   259 #endif /* PPC64 */
   262 /* Endian detection. */
   263 #if defined(DC__Arch_Intel_x86) || defined(DC__Arch_AMD64) /* always little */
   264 # define DC__Endian_LITTLE
   265 #elif defined(DC__Arch_Sparc)                              /* always purely big until v9 */
   266 # define DC__Endian_BIG
   267 #else                                                      /* all others are bi-endian */
   268 /* @@@check flags used on following bi-endianness archs:
   269 DC__Arch_ARM
   270 DC__Arch_ARM64
   271 DC__Arch_Itanium
   272 DC__Arch_PPC32
   273 DC__Arch_PPC64
   274 DC__Arch_SuperH
   275 */
   276 # if (defined(DC__Arch_PPC64) && (DC__ABI_PPC64_ELF_V == 1)) || defined(_BIG_ENDIAN) || defined(MIPSEB) || defined(_MIPSEB) || defined(__MIPSEB) || defined(__MIPSEB__)
   277 #  define DC__Endian_BIG
   278 # elif (defined(DC__Arch_PPC64) && (DC__ABI_PPC64_ELF_V == 2)) || defined(_LITTLE_ENDIAN) || defined(MIPSEL) || defined(_MIPSEL) || defined(__MIPSEL) || defined(__MIPSEL__)
   279 #  define DC__Endian_LITTLE
   280 # elif defined(DC__Arch_Sparc64) && !defined(__BYTE_ORDER__) /* Sparc64 default is big-endian, except if explicitly defined */
   281 #    define DC__Endian_BIG
   282 # elif defined(__BYTE_ORDER__) /* explicitly set */
   283 #  if defined(__ORDER_BIG_ENDIAN__) && (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__)
   284 #    define DC__Endian_BIG
   285 #  elif defined(__ORDER_LITTLE_ENDIAN__) && (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__)
   286 #    define DC__Endian_LITTLE
   287 #  endif
   288 # endif /* no else, leave unset if not sure */
   289 #endif
   292 /* Internal macro/tag. */
   293 #if !defined(DC_API)
   294 # define DC_API
   295 #endif
   297 #endif /* DYNCALL_MACROS_H */