# HG changeset patch # User Tassilo Philipp # Date 1664711913 -7200 # Node ID 5d999f5c13d103ff5718eb0ad1f439ad8af23cac # Parent 516d72e982539c52988e773a53a2021ff231c9eb - fixed mingw and cygwin env detection (was always shadowed by _WIN32 macro detection, and __MINGW__ macro check was wrong to begin with) - cosmetic cleanups for consistency - added runtime detection to dyncall_macros.h to handle some edge cases - fixed detection of native thiscall callconv for builds not using MSVC but using (or adhering to) the MSVC runtime (e.g. ReactOS' MinGW based RosBE) diff -r 516d72e98253 -r 5d999f5c13d1 ChangeLog --- a/ChangeLog Sat Oct 01 16:14:00 2022 +0200 +++ b/ChangeLog Sun Oct 02 13:58:33 2022 +0200 @@ -16,6 +16,8 @@ o added macros to feature test implementation for aggregate-by-value and syscall support o windows/x64/masm directives added to specify how stack unwinds (help for debuggers, exception handling, etc.; thanks Raphael Luba) + o fixed detection of native thiscall callconv for builds not using MSVC but using (or adhering to) + the MSVC runtime (e.g. ReactOS' MinGW based RosBE) dyncallback: o new, portable aggregate-by-value callback argument interface o aggregate-by-value (struct, union) support for x64 (win and sysv; thanks Raphael Luba!) diff -r 516d72e98253 -r 5d999f5c13d1 autovar/autovar_OS.h --- a/autovar/autovar_OS.h Sat Oct 01 16:14:00 2022 +0200 +++ b/autovar/autovar_OS.h Sun Oct 02 13:58:33 2022 +0200 @@ -49,10 +49,6 @@ # define OS_DragonFlyBSD #elif defined(__sun__) || defined(__sun) || defined(sun) # define OS_SunOS -#elif defined(__CYGWIN__) -# define OS_Cygwin -#elif defined(__MINGW__) -# define OS_MinGW #elif defined(__nds__) # define OS_NDS #elif defined(__psp__) || defined(PSP) @@ -69,6 +65,14 @@ # define OS_Unknown #endif +#if defined(DC__OS_Win32) || defined(DC__OS_Win64) +# if defined(__CYGWIN__) +# define OS_Cygwin +# elif defined(__MINGW32__) || defined(__MINGW64__) +# define OS_MinGW +# endif +#endif + /** Platforms. */ #if defined(__ANDROID__) diff -r 516d72e98253 -r 5d999f5c13d1 dyncall/dyncall_callvm_x86.c --- a/dyncall/dyncall_callvm_x86.c Sat Oct 01 16:14:00 2022 +0200 +++ b/dyncall/dyncall_callvm_x86.c Sun Oct 02 13:58:33 2022 +0200 @@ -607,7 +607,7 @@ switch(mode) { case DC_CALL_C_DEFAULT: -#if !defined(DC__C_MSVC) +#if !defined(DC__C_MSVC) && !defined(DC__RT_MSVCRT) case DC_CALL_C_DEFAULT_THIS: #endif case DC_CALL_C_ELLIPSIS: @@ -619,7 +619,7 @@ case DC_CALL_C_X86_CDECL: vt = &gVT_x86_cdecl; break; /* also handles DC_CALL_C_X86_WIN32_THIS_GNU */ case DC_CALL_C_X86_WIN32_STD: vt = &gVT_x86_win32_std; break; case DC_CALL_C_X86_WIN32_FAST_MS: vt = &gVT_x86_win32_fast_ms; break; -#if defined(DC__C_MSVC) +#if defined(DC__C_MSVC) || defined(DC__RT_MSVCRT) case DC_CALL_C_DEFAULT_THIS: #endif case DC_CALL_C_X86_WIN32_THIS_MS: vt = &gVT_x86_win32_this_ms; break; diff -r 516d72e98253 -r 5d999f5c13d1 dyncall/dyncall_macros.h --- a/dyncall/dyncall_macros.h Sat Oct 01 16:14:00 2022 +0200 +++ b/dyncall/dyncall_macros.h Sun Oct 02 13:58:33 2022 +0200 @@ -50,83 +50,89 @@ /* MS Windows XP x64/Vista64 or later. */ #if defined(WIN64) || defined(_WIN64) || defined(__WIN64__) -#define DC__OS_Win64 +# define DC__OS_Win64 /* MS Windows NT/95/98/ME/2000/XP/Vista32. */ #elif defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__NT__) || defined(__WINDOWS__) || defined(_WINDOWS) -#define DC__OS_Win32 +# define DC__OS_Win32 /* All the OS' based on Darwin OS (MacOS X, OpenDarwin). Note that '__APPLE__' may be defined for classic MacOS, too. */ /* __MACOSX__ is not defined in gcc assembler mode (switch: -S) */ -/* @@@ TODO: Check for Classic OS */ - #elif defined(__APPLE__) || defined(__Darwin__) -# define DC__OS_Darwin -# if defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) -# define DC__OS_IPhone -# else /* defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) */ -# define DC__OS_MacOSX -# endif +# define DC__OS_Darwin +# if defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) +# define DC__OS_IPhone +# else /* defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) */ +# define DC__OS_MacOSX +# endif /* The most popular open source Unix-like OS - Linux. */ #elif defined(__linux__) || defined(__linux) || defined(__gnu_linux__) -#define DC__OS_Linux +# define DC__OS_Linux /* The most powerful open source Unix-like OS - FreeBSD. */ #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__ */ -#define DC__OS_FreeBSD +# define DC__OS_FreeBSD /* The most secure open source Unix-like OS - OpenBSD. */ #elif defined(__OpenBSD__) -#define DC__OS_OpenBSD +# define DC__OS_OpenBSD /* The most portable open source Unix-like OS - NetBSD. */ #elif defined(__NetBSD__) -#define DC__OS_NetBSD +# define DC__OS_NetBSD /* The FreeBSD fork having heavy clusterization in mind - DragonFlyBSD. */ #elif defined(__DragonFly__) -#define DC__OS_DragonFlyBSD +# define DC__OS_DragonFlyBSD /* Sun's Unix-like OS - SunOS / Solaris. */ #elif defined(__sun__) || defined(__sun) || defined(sun) -#define DC__OS_SunOS - -/* The "Linux-like environment for Windows" - Cygwin. */ -#elif defined(__CYGWIN__) -#define DC__OS_Cygwin - -/* The "Minimalist GNU for Windows" - MinGW. */ -#elif defined(__MINGW__)/*@@@*/ -#define DC__OS_MinGW +# define DC__OS_SunOS /* The Nintendo DS (homebrew) using devkitpro. */ #elif defined(__nds__) -#define DC__OS_NDS +# define DC__OS_NDS /* The PlayStation Portable (homebrew) SDK. */ #elif defined(__psp__) || defined(PSP) -#define DC__OS_PSP +# define DC__OS_PSP /* Haiku (BeOS alike). */ #elif defined(__HAIKU__) -#define DC__OS_BeOS +# define DC__OS_BeOS /* The Unix successor - Plan9 from Bell Labs */ #elif defined(Plan9) || defined(__Plan9__) -#define DC__OS_Plan9 +# define DC__OS_Plan9 /* Digital's Unix-like OS - VMS */ #elif defined(__vms) -#define DC__OS_VMS +# define DC__OS_VMS +/* Tanenbaum's Microkernel OS - Minix */ #elif defined(__minix) -#define DC__OS_Minix - -#else +# define DC__OS_Minix /* Unable to determine OS, which is probably ok (e.g. baremetal stuff, etc.). */ -#define DC__OS_UNKNOWN +#else +# define DC__OS_UNKNOWN + +#endif + + +/* windows sub envs */ +#if defined(DC__OS_Win32) || defined(DC__OS_Win64) + +/* The "Linux-like environment for Windows" - Cygwin. */ +# if defined(__CYGWIN__) +# define DC__OS_Cygwin + +/* The "Minimalist GNU for Windows" - MinGW. */ +# elif defined(__MINGW32__) || defined(__MINGW64__) +# define DC__OS_MinGW +# endif + #endif @@ -137,35 +143,35 @@ /* Intel's C/C++ compiler. */ #if defined(__INTEL_COMPILER) -#define DC__C_Intel +# define DC__C_Intel /* MS C/C++ compiler. */ #elif defined(_MSC_VER) -#define DC__C_MSVC +# define DC__C_MSVC /* LLVM clang. */ #elif defined(__clang__) || defined(__llvm__) -#define DC__C_CLANG +# define DC__C_CLANG /* The GNU Compiler Collection - GCC. */ #elif defined(__GNUC__) -#define DC__C_GNU +# define DC__C_GNU /* Watcom compiler. */ #elif defined(__WATCOMC__) -#define DC__C_WATCOM +# define DC__C_WATCOM /* Portable C Compiler. */ #elif defined(__PCC__) -#define DC__C_PCC +# define DC__C_PCC /* Sun Pro C. */ #elif defined(__SUNPRO_C) -#define DC__C_SUNPRO +# define DC__C_SUNPRO /* Undetected C Compiler. */ #else -#define DC__C_UNKNOWN +# define DC__C_UNKNOWN #endif @@ -181,9 +187,9 @@ # define DC__Arch_Itanium #elif defined(_M_PPC) || defined(__powerpc__) || defined(__powerpc) || defined(__POWERPC__) || defined(__ppc__) || defined(__power__) # if defined(__ppc64__) || defined(_ARCH_PPC64) || defined(__power64__) || defined(__powerpc64__) -# define DC__Arch_PPC64 +# define DC__Arch_PPC64 # else -# define DC__Arch_PPC32 +# define DC__Arch_PPC32 # endif #elif defined(__mips64__) || defined(__mips64) # define DC__Arch_MIPS64 @@ -205,6 +211,13 @@ +/* -- Runtime ------------------------------------------------------- */ + +#if defined(__MSVCRT__) +# define DC__RT_MSVCRT +#endif + + /* -- Rough OS classification --------------------------------------- */ #if defined(DC__OS_Win32) || defined(DC__OS_Win64) @@ -230,9 +243,9 @@ #if defined(DC__Arch_ARM_ARM) || defined(DC__Arch_ARM_THUMB) # if defined(__ARM_EABI__) || defined(DC__OS_NDS) # if defined (__ARM_PCS_VFP) && (__ARM_PCS_VFP == 1) -# define DC__ABI_ARM_HF +# define DC__ABI_ARM_HF # else -# define DC__ABI_ARM_EABI +# define DC__ABI_ARM_EABI # endif # elif defined(__APCS_32__) # define DC__ABI_ARM_OABI @@ -285,12 +298,12 @@ # elif (defined(DC__Arch_PPC64) && (DC__ABI_PPC64_ELF_V == 2)) || defined(MIPSEL) || defined(_MIPSEL) || defined(__MIPSEL) || defined(__MIPSEL__) || defined(__ARMEL__) || defined(__AARCH64EL__) # define DC__Endian_LITTLE # elif defined(DC__Arch_Sparc64) && !defined(__BYTE_ORDER__) /* Sparc64 default is big-endian, except if explicitly defined */ -# define DC__Endian_BIG +# define DC__Endian_BIG # elif defined(BYTE_ORDER) || defined(_BYTE_ORDER) || defined(__BYTE_ORDER__) /* explicitly set byte order, either through compiler or platform specific endian.h */ # if (defined(BIG_ENDIAN) && (BYTE_ORDER == BIG_ENDIAN)) || (defined(_BIG_ENDIAN) && (_BYTE_ORDER == _BIG_ENDIAN)) || (defined(__ORDER_BIG_ENDIAN__) && (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__)) -# define DC__Endian_BIG +# define DC__Endian_BIG # elif (defined(LITTLE_ENDIAN) && (BYTE_ORDER == LITTLE_ENDIAN)) || (defined(_LITTLE_ENDIAN) && (_BYTE_ORDER == _LITTLE_ENDIAN)) || (defined(__ORDER_LITTLE_ENDIAN__) && (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__)) -# define DC__Endian_LITTLE +# define DC__Endian_LITTLE # endif # elif (defined(_BIG_ENDIAN) && (_BIG_ENDIAN == 1)) || (defined(__BIG_ENDIAN__) && (__BIG_ENDIAN__ == 1)) /* explicitly set as on/off */ # define DC__Endian_BIG @@ -317,12 +330,12 @@ /* syscalls */ #if (defined(DC__Arch_Intel_x86) || (defined(DC__Arch_AMD64) && defined(DC_UNIX)) || defined(DC__Arch_PPC32) || defined(DC__Arch_PPC64)) && \ !defined(DC__OS_MacOSX) && !defined(DC__OS_Plan9) && !defined(DC__OS_NDS) && !defined(DC__OS_PSP) && !defined(DC__OS_Minix) && !defined(DC__OS_SunOS) && !defined(DC__OS_BeOS) -# define DC__Feature_Syscall +# define DC__Feature_Syscall #endif /* aggregate (struct, union) by value */ #if defined(DC__Arch_AMD64) -# define DC__Feature_AggrByVal +# define DC__Feature_AggrByVal #endif