From 4fbe435cbe94c57fa333671560cd9024708f2bba Mon Sep 17 00:00:00 2001 From: Susko3 Date: Sat, 6 Apr 2024 00:30:30 +0200 Subject: [PATCH] Fix errors in `SDL_stdinc.g.cs` with define magic --- SDL3-CS/SDL3/ClangSharp/SDL_stdinc.g.cs | 27 ------------------------- SDL3-CS/SDL3/SDL_stdinc.rsp | 12 +++++++++++ 2 files changed, 12 insertions(+), 27 deletions(-) create mode 100644 SDL3-CS/SDL3/SDL_stdinc.rsp diff --git a/SDL3-CS/SDL3/ClangSharp/SDL_stdinc.g.cs b/SDL3-CS/SDL3/ClangSharp/SDL_stdinc.g.cs index 0582c1e..0ee5e82 100644 --- a/SDL3-CS/SDL3/ClangSharp/SDL_stdinc.g.cs +++ b/SDL3-CS/SDL3/ClangSharp/SDL_stdinc.g.cs @@ -517,11 +517,6 @@ namespace SDL return 0; } - public static int SDL_size_mul_overflow_builtin([NativeTypeName("size_t")] nuint a, [NativeTypeName("size_t")] nuint b, [NativeTypeName("size_t *")] nuint* ret) - { - return (__builtin_mul_overflow(a, b, ret)) ? 1 : 0 == 0 ? 0 : -1; - } - public static int SDL_size_add_overflow([NativeTypeName("size_t")] nuint a, [NativeTypeName("size_t")] nuint b, [NativeTypeName("size_t *")] nuint* ret) { if (b > 0xffffffffffffffffUL - a) @@ -533,19 +528,6 @@ namespace SDL return 0; } - public static int SDL_size_add_overflow_builtin([NativeTypeName("size_t")] nuint a, [NativeTypeName("size_t")] nuint b, [NativeTypeName("size_t *")] nuint* ret) - { - return (__builtin_add_overflow(a, b, ret)) ? 1 : 0 == 0 ? 0 : -1; - } - - [DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] - [return: NativeTypeName("bool")] - public static extern byte __builtin_mul_overflow(__arglist); - - [DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] - [return: NativeTypeName("bool")] - public static extern byte __builtin_add_overflow(__arglist); - [NativeTypeName("#define SDL_SIZE_MAX SIZE_MAX")] public const ulong SDL_SIZE_MAX = 0xffffffffffffffffUL; @@ -636,15 +618,6 @@ namespace SDL [NativeTypeName("#define SDL_PRIX32 \"X\"")] public static ReadOnlySpan SDL_PRIX32 => "X"u8; - [NativeTypeName("#define SDL_memcpy memcpy")] - public static readonly delegate* SDL_memcpy = &memcpy; - - [NativeTypeName("#define SDL_memmove memmove")] - public static readonly delegate* SDL_memmove = &memmove; - - [NativeTypeName("#define SDL_memset memset")] - public static readonly delegate* SDL_memset = &memset; - [NativeTypeName("#define SDL_PI_D 3.141592653589793238462643383279502884")] public const double SDL_PI_D = 3.141592653589793238462643383279502884; diff --git a/SDL3-CS/SDL3/SDL_stdinc.rsp b/SDL3-CS/SDL3/SDL_stdinc.rsp new file mode 100644 index 0000000..375011b --- /dev/null +++ b/SDL3-CS/SDL3/SDL_stdinc.rsp @@ -0,0 +1,12 @@ +# Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +# See the LICENCE file in the repository root for full licence text. + +# Prevent SDL memory functions from being defined to compiler intrinsic ones +--define-macro +SDL_SLOW_MEMCPY +SDL_SLOW_MEMMOVE +SDL_SLOW_MEMSET + +# Prevent SDL from using compiler intrinsics __builtin_mul_overflow and __builtin_add_overflow. +--additional +--undefine-macro=__has_builtin