From 55934bc85e4d57c8d87960ac0cc543a5fad5833f Mon Sep 17 00:00:00 2001
From: Anonymous Maarten <[EMAIL REDACTED]>
Date: Mon, 2 Sep 2024 14:12:02 +0200
Subject: [PATCH] include: add SDL_RESTRICT for restricted pointer aliasing
---
include/SDL3/SDL_begin_code.h | 10 ++++++++++
src/dynapi/gendynapi.py | 1 +
2 files changed, 11 insertions(+)
diff --git a/include/SDL3/SDL_begin_code.h b/include/SDL3/SDL_begin_code.h
index f418c6109d855..ff5ba02733938 100644
--- a/include/SDL3/SDL_begin_code.h
+++ b/include/SDL3/SDL_begin_code.h
@@ -225,3 +225,13 @@
#define SDL_ALLOC_SIZE2(p1, p2)
#endif
#endif /* SDL_ALLOC_SIZE2 not defined */
+
+#ifndef SDL_RESTRICT
+#if defined(__GNUC__)
+#define SDL_RESTRICT __restrict__
+#elif defined(_MSC_VER)
+#define SDL_RESTRICT __restrict
+#else
+#define SDL_RESTRICT
+#endif
+#endif
diff --git a/src/dynapi/gendynapi.py b/src/dynapi/gendynapi.py
index 7c5f430f180ae..e96026cdda480 100755
--- a/src/dynapi/gendynapi.py
+++ b/src/dynapi/gendynapi.py
@@ -180,6 +180,7 @@ def main():
func = re.sub(r" SDL_RELEASE\(.*\)", "", func);
func = re.sub(r" SDL_RELEASE_SHARED\(.*\)", "", func);
func = re.sub(r" SDL_RELEASE_GENERIC\(.*\)", "", func);
+ func = func.replace(" SDL_RESTRICT", "");
# Should be a valid function here
match = reg_parsing_function.match(func)