From 65a80ffdff888675da8f051a0050501ba0cb854d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Antonin=20D=C3=A9cimo?= <antonin@tarides.com>
Date: Thu, 20 Feb 2025 23:31:04 +0100
Subject: [PATCH] AC_C_STATIC_ARRAY_DECLARATOR

---
 0001-AC_C_STATIC_ARRAY_DECLARATOR.patch | 48 +++++++++++++++++++++++++
 lib/autoconf/c.m4                       | 25 +++++++++++++
 2 files changed, 73 insertions(+)
 create mode 100644 0001-AC_C_STATIC_ARRAY_DECLARATOR.patch

diff --git a/0001-AC_C_STATIC_ARRAY_DECLARATOR.patch b/0001-AC_C_STATIC_ARRAY_DECLARATOR.patch
new file mode 100644
index 00000000..c2cdb470
--- /dev/null
+++ b/0001-AC_C_STATIC_ARRAY_DECLARATOR.patch
@@ -0,0 +1,48 @@
+From e940aa777bbc657e592529843736093c32adde47 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Antonin=20D=C3=A9cimo?= <antonin@tarides.com>
+Date: Thu, 20 Feb 2025 23:31:04 +0100
+Subject: [PATCH] AC_C_STATIC_ARRAY_DECLARATOR
+
+---
+ lib/autoconf/c.m4 | 25 +++++++++++++++++++++++++
+ 1 file changed, 25 insertions(+)
+
+diff --git a/lib/autoconf/c.m4 b/lib/autoconf/c.m4
+index bafa72c1..a4596d16 100644
+--- a/lib/autoconf/c.m4
++++ b/lib/autoconf/c.m4
+@@ -2379,6 +2379,31 @@ AC_DEFUN([AC_C_VARARRAYS],
+ ])
+ 
+ 
++# AC_C_STATIC_ARRAY_DECLARATOR
++# ----------------------------
++# Check whether the C compiler supports the C99 static keyword keyword
++# appearing within the [ and ] of array type derivations in function
++# parameters.
++AC_DEFUN([AC_C_STATIC_ARRAY_DECLARATOR],
++[
++  AC_CACHE_CHECK([if $CC supports the static keyword in array declarators],
++    ac_cv_c_static_array_declarator,
++    [AC_COMPILE_IFELSE(
++       [AC_LANG_PROGRAM(
++	  [[static void f(int array[static 16]) { }]],
++	  [[]])],
++       [ac_cv_c_static_array_declarator=yes],
++       [ac_cv_c_static_array_declarator=no])])
++  if test $ac_cv_c_static_array_declarator = yes; then
++    AC_DEFINE([STATIC_ARRAY_DECLARATOR], [static],
++      [Define to nothing if the C compiler supports the 'static' keyword
++       appearing within the [ and ] of array type derivations in function
++       parameters.])
++  else
++    AC_DEFINE([STATIC_ARRAY_DECLARATOR], [])
++  fi
++])
++
+ # AC_C_TYPEOF
+ # -----------
+ # Check if the C compiler supports GCC's typeof syntax.
+-- 
+2.45.1
+
diff --git a/lib/autoconf/c.m4 b/lib/autoconf/c.m4
index bafa72c1..e9c93736 100644
--- a/lib/autoconf/c.m4
+++ b/lib/autoconf/c.m4
@@ -2379,6 +2379,31 @@ AC_DEFUN([AC_C_VARARRAYS],
 ])
 
 
+# AC_C_STATIC_ARRAY_DECLARATOR
+# ----------------------------
+# Check whether the C compiler supports the C99 static keyword keyword
+# appearing within the [ and ] of array type derivations in function
+# parameters.
+AC_DEFUN([AC_C_STATIC_ARRAY_DECLARATOR],
+[
+  AC_CACHE_CHECK([if $CC supports the static keyword in array declarators],
+    ac_cv_c_static_array_declarator,
+    [AC_COMPILE_IFELSE(
+       [AC_LANG_PROGRAM(
+	  [[static void f(int array[static 16]) { }]],
+	  [[]])],
+       [ac_cv_c_static_array_declarator=yes],
+       [ac_cv_c_static_array_declarator=no])])
+  if test $ac_cv_c_static_array_declarator = yes; then
+    AC_DEFINE([STATIC_ARRAY_DECLARATOR], [static],
+      [Define to empty if the C compiler doesn't support the 'static'
+       keyword appearing within the [ and ] of array type derivations in
+       function parameters.])
+  else
+    AC_DEFINE([STATIC_ARRAY_DECLARATOR], [])
+  fi
+])
+
 # AC_C_TYPEOF
 # -----------
 # Check if the C compiler supports GCC's typeof syntax.
-- 
2.45.1

