From debb91ecdd39a7039abdc6b2fb4c9b79956fc758 Mon Sep 17 00:00:00 2001
From: Alfred Wingate <parona@protonmail.com>
Date: Sun, 17 Dec 2023 14:35:31 +0200
Subject: [PATCH 4/5] Fix c99 compatibility in configure script

Signed-off-by: Alfred Wingate <parona@protonmail.com>
--- a/configure.ac
+++ b/configure.ac
@@ -486,19 +486,20 @@ AC_MSG_RESULT([$ac_cv_pnt_arith_type])
 AC_CHECK_FUNCS(abort)
 AC_MSG_CHECKING([abort safe])
 AC_RUN_IFELSE([AC_LANG_SOURCE([[
+#include <stdlib.h>
 static int main_b = 0;
 static char heap_mem[102400], *heap_p = heap_mem;
-free () { if (main_b) _exit(0); }
+void free () { if (main_b) exit(0); }
 char *malloc (int size) {
   char *pnt;
-  if (main_b) _exit(0);
+  if (main_b) exit(0);
   pnt = heap_p;
   heap_p += size;
   return pnt;
 }
 char *calloc (int number, int size) {
   char *start, *pnt, *end;
-  if (main_b) _exit(0);
+  if (main_b) exit(0);
   /* it should be already 0s */
   start = malloc (number * size);
   pnt = start;
@@ -508,7 +509,7 @@ char *calloc (int number, int size) {
 }
 char *realloc (char *old_pnt, int new_size) {
   char *start, *pnt, *end;
-  if (main_b) _exit(0);
+  if (main_b) exit(0);
   start = malloc (new_size);
   pnt = start;
   end = start + new_size;
@@ -549,6 +550,7 @@ AC_LINK_IFELSE([AC_LANG_PROGRAM([[
 AC_CHECK_FUNCS(getenv)
 AC_MSG_CHECKING([getenv safe])
 AC_RUN_IFELSE([AC_LANG_SOURCE([[
+#include <stdlib.h>
 static char heap_mem[102400], *heap_p = heap_mem;
 free (char *pnt) {
 }
@@ -651,6 +653,7 @@ fi
 #
 AC_MSG_CHECKING([constructor attribute])
 AC_RUN_IFELSE([AC_LANG_SOURCE([[
+#include <stdlib.h>
 /* if we call the loc_con constructor then exit with error code 0 */
 static void loc_con() __attribute__((constructor));
 static void loc_con() { exit(0); }
@@ -666,6 +669,7 @@ int main() { return 1; }
 #
 AC_MSG_CHECKING([destructor attribute])
 AC_RUN_IFELSE([AC_LANG_SOURCE([[
+#include <stdlib.h>
 /* if we call the loc_decon destructor then exit with error code 0 */
 static void loc_decon() __attribute__((destructor));
 static void loc_decon() { exit(0); }
-- 
2.43.0

