From fa61d32dfcf1fdd521f68a868c23e945deec1780 Mon Sep 17 00:00:00 2001 From: Susko3 Date: Thu, 24 Oct 2024 00:48:29 +0100 Subject: [PATCH] Exclude symbols that don't work cross-platform As seen when trying to build on Linux in #169. Removes: - Windows-specific begin/end thread symbols that don't do anything - Things that statically depend on `size_t` - 64-bit printf specifiers that depend on int64_t definition (long vs long long) --- SDL3-CS/SDL3/ClangSharp/SDL_stdinc.g.cs | 39 ------------------------- SDL3-CS/SDL3/ClangSharp/SDL_thread.g.cs | 6 ---- SDL3-CS/SDL3/SDL_stdinc.rsp | 10 +++++++ SDL3-CS/SDL3/SDL_thread.rsp | 4 +++ 4 files changed, 14 insertions(+), 45 deletions(-) diff --git a/SDL3-CS/SDL3/ClangSharp/SDL_stdinc.g.cs b/SDL3-CS/SDL3/ClangSharp/SDL_stdinc.g.cs index c1db759..6dc9b96 100644 --- a/SDL3-CS/SDL3/ClangSharp/SDL_stdinc.g.cs +++ b/SDL3-CS/SDL3/ClangSharp/SDL_stdinc.g.cs @@ -619,33 +619,6 @@ namespace SDL [return: NativeTypeName("char *")] public static extern byte* Unsafe_SDL_iconv_string([NativeTypeName("const char *")] byte* tocode, [NativeTypeName("const char *")] byte* fromcode, [NativeTypeName("const char *")] byte* inbuf, [NativeTypeName("size_t")] nuint inbytesleft); - [return: NativeTypeName("bool")] - public static SDLBool SDL_size_mul_check_overflow([NativeTypeName("size_t")] nuint a, [NativeTypeName("size_t")] nuint b, [NativeTypeName("size_t *")] nuint* ret) - { - if (a != 0 && b > 0xffffffffffffffffUL / a) - { - return false; - } - - *ret = a * b; - return true; - } - - [return: NativeTypeName("bool")] - public static SDLBool SDL_size_add_check_overflow([NativeTypeName("size_t")] nuint a, [NativeTypeName("size_t")] nuint b, [NativeTypeName("size_t *")] nuint* ret) - { - if (b > 0xffffffffffffffffUL - a) - { - return false; - } - - *ret = a + b; - return true; - } - - [NativeTypeName("#define SDL_SIZE_MAX SIZE_MAX")] - public const ulong SDL_SIZE_MAX = 0xffffffffffffffffUL; - [NativeTypeName("#define SDL_MAX_SINT8 ((Sint8)0x7F)")] public const sbyte SDL_MAX_SINT8 = ((sbyte)(0x7F)); @@ -703,18 +676,6 @@ namespace SDL [NativeTypeName("#define SDL_FLT_EPSILON 1.1920928955078125e-07F")] public const float SDL_FLT_EPSILON = 1.1920928955078125e-07F; - [NativeTypeName("#define SDL_PRIs64 \"lld\"")] - public static ReadOnlySpan SDL_PRIs64 => "lld"u8; - - [NativeTypeName("#define SDL_PRIu64 \"llu\"")] - public static ReadOnlySpan SDL_PRIu64 => "llu"u8; - - [NativeTypeName("#define SDL_PRIx64 \"llx\"")] - public static ReadOnlySpan SDL_PRIx64 => "llx"u8; - - [NativeTypeName("#define SDL_PRIX64 \"llX\"")] - public static ReadOnlySpan SDL_PRIX64 => "llX"u8; - [NativeTypeName("#define SDL_PRIs32 \"d\"")] public static ReadOnlySpan SDL_PRIs32 => "d"u8; diff --git a/SDL3-CS/SDL3/ClangSharp/SDL_thread.g.cs b/SDL3-CS/SDL3/ClangSharp/SDL_thread.g.cs index 49b61b3..6ba1b5f 100644 --- a/SDL3-CS/SDL3/ClangSharp/SDL_thread.g.cs +++ b/SDL3-CS/SDL3/ClangSharp/SDL_thread.g.cs @@ -79,12 +79,6 @@ namespace SDL [DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern void SDL_CleanupTLS(); - [NativeTypeName("#define SDL_BeginThreadFunction NULL")] - public const int SDL_BeginThreadFunction = 0; - - [NativeTypeName("#define SDL_EndThreadFunction NULL")] - public const int SDL_EndThreadFunction = 0; - [NativeTypeName("#define SDL_PROP_THREAD_CREATE_ENTRY_FUNCTION_POINTER \"SDL.thread.create.entry_function\"")] public static ReadOnlySpan SDL_PROP_THREAD_CREATE_ENTRY_FUNCTION_POINTER => "SDL.thread.create.entry_function"u8; diff --git a/SDL3-CS/SDL3/SDL_stdinc.rsp b/SDL3-CS/SDL3/SDL_stdinc.rsp index 375011b..a4253b3 100644 --- a/SDL3-CS/SDL3/SDL_stdinc.rsp +++ b/SDL3-CS/SDL3/SDL_stdinc.rsp @@ -10,3 +10,13 @@ SDL_SLOW_MEMSET # Prevent SDL from using compiler intrinsics __builtin_mul_overflow and __builtin_add_overflow. --additional --undefine-macro=__has_builtin + +# Exclude symbols that differ on Windows and Unix +--exclude +SDL_size_mul_check_overflow +SDL_size_add_check_overflow +SDL_SIZE_MAX +SDL_PRIs64 +SDL_PRIu64 +SDL_PRIx64 +SDL_PRIX64 diff --git a/SDL3-CS/SDL3/SDL_thread.rsp b/SDL3-CS/SDL3/SDL_thread.rsp index 6b497c5..3e512f5 100644 --- a/SDL3-CS/SDL3/SDL_thread.rsp +++ b/SDL3-CS/SDL3/SDL_thread.rsp @@ -8,3 +8,7 @@ SDL_CreateThread=System.Runtime.Versioning --with-attribute SDL_CreateThread=UnsupportedOSPlatform("windows") SDL_CreateThreadWithStackSize=UnsupportedOSPlatform("windows") + +--exclude +SDL_BeginThreadFunction +SDL_EndThreadFunction