From 6627b2c7cc64c85353b2bce7396084fecaa1ea3a Mon Sep 17 00:00:00 2001
From: barracuda156 <vital.had@gmail.com>
Date: Fri, 4 Aug 2023 13:17:21 +0800
Subject: [PATCH] Fixes for modern GCC

diff --git configure.ac configure.ac
index a754c2da18..3568ea7ccd 100644
--- configure.ac
+++ configure.ac
@@ -975,9 +975,24 @@
   RDC_PROG_CXX_FFLAGS([no-math-errno unsafe-math-optimizations no-rounding-math no-signaling-nans cx-limited-range])
   AC_LANG_POP
 
-AH_BOTTOM([
+  dnl Check for -ffast-math
+  VLC_SAVE_FLAGS
+  CFLAGS="${CFLAGS} -ffast-math"
+  CXXFLAGS="${CXXFLAGS} -ffast-math"
+  OBJCFLAGS="${OBJCFLAGS} -ffast-math"
+  AC_CACHE_CHECK([if $CC accepts -ffast-math], [ac_cv_c_fast_math], [
+    AC_COMPILE_IFELSE([AC_LANG_PROGRAM()], [
+      ac_cv_c_fast_math=yes
+    ], [
+      ac_cv_c_fast_math=no
+    ])
+  ])
+  AS_IF([test "${ac_cv_c_fast_math}" = "no"], [VLC_RESTORE_FLAGS])
+  AH_BOTTOM([
+#ifndef __FAST_MATH__
 # pragma STDC FENV_ACCESS OFF
 # pragma STDC FP_CONTRACT ON
+#endif
 ])
 
   dnl Check for -funroll-loops

--- include/vlc_fixups.h
+++ include/vlc_fixups.h
@@ -239,9 +239,12 @@ static inline locale_t newlocale(int mask, const char * locale, locale_t base)
 }
 #endif
 
-#if !defined (HAVE_STATIC_ASSERT)
-# define _Static_assert(x, s) ((void) sizeof (struct { unsigned:-!(x); }))
-# define static_assert _Static_assert
+/* static_assert missing in assert.h */
+#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L && __STDC_VERSION__ < 202311L
+#   include <assert.h>
+#   ifndef static_assert
+#   define static_assert _Static_assert
+#   endif
 #endif
 
 /* Alignment of critical static data structures */
diff --git modules/control/Modules.am modules/control/Modules.am
index 88693de23c..56633eae42 100644
--- modules/control/Modules.am
+++ modules/control/Modules.am
@@ -9,7 +9,7 @@ SOURCES_oldrc = rc.c
 libvlc_motion_la_SOURCES = motionlib.c motionlib.h
 if HAVE_DARWIN
 libvlc_motion_la_SOURCES += unimotion.c unimotion.h
-libvlc_motion_la_CFLAGS = $(AM_CFLAGS) -fconstant-cfstrings
+libvlc_motion_la_CFLAGS = $(AM_CFLAGS) -mconstant-cfstrings
 endif
 libvlc_motion_la_LDFLAGS = -static
 noinst_LTLIBRARIES = libvlc_motion.la