From: Gwen Weinholt <weinholt@debian.org>
Date: Sat, 4 May 2024 13:05:51 +0200
Subject: Fix implicit declarations of some libc functions

---
 gmalloc.c | 6 ++++--
 unexelf.c | 1 +
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/gmalloc.c b/gmalloc.c
index eef1504..42e96a1 100755
--- a/gmalloc.c
+++ b/gmalloc.c
@@ -49,7 +49,7 @@ License along with GNU Emacs.  If not, see
 #define	__ptr_t		char *
 #endif /* C++ or ANSI C.  */
 
-#if	defined(_LIBC) || defined(STDC_HEADERS) || defined(USG)
+#if	defined(_LIBC) || defined(STDC_HEADERS) || defined(USG) || defined(__STDC__)
 #include <string.h>
 #else
 #ifndef memset
@@ -1631,6 +1631,8 @@ extern size_t __getpagesize PP ((void));
 #define	 __getpagesize()	getpagesize()
 #endif
 
+#include <unistd.h>
+
 #ifndef	_MALLOC_INTERNAL
 #define	_MALLOC_INTERNAL
 #include <malloc.h>
@@ -1643,7 +1645,7 @@ valloc (size)
      __malloc_size_t size;
 {
   if (pagesize == 0)
-    pagesize = __getpagesize ();
+    pagesize = sysconf(_SC_PAGESIZE);
 
   return memalign (pagesize, size);
 }
diff --git a/unexelf.c b/unexelf.c
index 9a2933e..06f40be 100755
--- a/unexelf.c
+++ b/unexelf.c
@@ -410,6 +410,7 @@ temacs:
 extern void fatal (const char *msgid, ...);
 #endif
 
+#include <stdlib.h>
 #include <sys/types.h>
 #include <stdio.h>
 #include <sys/stat.h>
