1From 09ce52fe375a6fc1ccf51b6b691aaa2c3f53fbd5 Mon Sep 17 00:00:00 2001 2From: Bernd Kuhls <bernd.kuhls@t-online.de> 3Date: Fri, 3 Jun 2022 16:26:03 +0200 4Subject: [PATCH] Fix uClibc build 5MIME-Version: 1.0 6Content-Type: text/plain; charset=UTF-8 7Content-Transfer-Encoding: 8bit 8 9Fixes build errors with uClibc and gcc-9.3.0: 10 11../src/gallium/drivers/lima/lima_texture.c:47:15: error: expected 12 declaration specifiers or ‘...’ before ‘__builtin_offsetof’ 13 47 | static_assert(offsetof(lima_tex_desc, va) == 24, 14 "lima_tex_desc->va offset isn't 24"); 15 16../src/egl/main/egldisplay.c: In function ‘_eglGetNativePlatformFromEnv’: 17 ../src/egl/main/egldisplay.c:101:4: error: implicit declaration of 18 function ‘static_assert’ [-Werror=implicit-function-declaration] 101 | 19 static_assert(ARRAY_SIZE(egl_platforms) == _EGL_NUM_PLATFORMS, 20 21../src/util/macros.h:74:4: error: implicit declaration of function 22 ‘static_assert’ [-Werror=implicit-function-declaration] 23 74 | static_assert(cond, #cond); \ 24 | ^~~~~~~~~~~~~ 25 26Upstream: https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13898 27 28Signed-off-by: Bernd Kuhls <bernd.kuhls@t-online.de> 29[rebased for 23.2.0] 30Signed-off-by: Bernd Kuhls <bernd@kuhls.net> 31--- 32 src/util/compiler.h | 10 ++++++++++ 33 src/util/macros.h | 1 + 34 2 files changed, 11 insertions(+) 35 36diff --git a/src/util/compiler.h b/src/util/compiler.h 37index d184ad455af..b5c56807acc 100644 38--- a/src/util/compiler.h 39+++ b/src/util/compiler.h 40@@ -35,6 +35,17 @@ 41 42 43 #include <assert.h> 44+ 45+/* 46+ * C11 static_assert() macro 47+ * assert.h only defines that name for C11 and above 48+ */ 49+#if !defined(__cplusplus) 50+#ifndef static_assert 51+#define static_assert _Static_assert 52+#endif 53+#endif 54+ 55 #include <limits.h> 56 #include <stdarg.h> 57 #include <stdbool.h> 58diff --git a/src/util/macros.h b/src/util/macros.h 59index 22b18303826..8f73ee72693 100644 60--- a/src/util/macros.h 61+++ b/src/util/macros.h 62@@ -31,6 +31,7 @@ 63 #include <stddef.h> 64 #include <stdint.h> 65 #include <stdio.h> 66+#include "util/compiler.h" 67 68 #ifdef _GAMING_XBOX 69 #define strdup _strdup 70-- 712.34.1 72 73