Blob Blame History Raw
Fix implicit function declarations and implicit ints, for
compatibility with future compilers.

Submitted upstream: <https://sourceforge.net/p/sdcc/patches/458/>

Part of the issues are in a bundled copy of GNU binutils; these have
already been fixed in binutils/GCC upstream.

diff --git a/support/cpp/aclocal.m4 b/support/cpp/aclocal.m4
index b30c780296875596..be352e4820823eeb 100644
--- a/support/cpp/aclocal.m4
+++ b/support/cpp/aclocal.m4
@@ -351,17 +351,18 @@ changequote({{{,}}})dnl
 #include <signal.h>
 #include <setjmp.h>
 #include <stdio.h>
+#include <stdlib.h>
 
 #if !defined (MAP_ANONYMOUS) && defined (MAP_ANON)
 # define MAP_ANONYMOUS MAP_ANON
 #endif
 
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
+
 /* This mess was copied from the GNU getpagesize.h.  */
 #ifndef HAVE_GETPAGESIZE
-# ifdef HAVE_UNISTD_H
-#  include <unistd.h>
-# endif
-
 /* Assume that all systems that can run configure have sys/param.h.  */
 # ifndef HAVE_SYS_PARAM_H
 #  define HAVE_SYS_PARAM_H 1
@@ -661,22 +662,22 @@ int main()
 
   fd = open("conftestdata$$", O_RDONLY);
   if (fd < 0)
-    exit(1);
+    return 1;
 
   if (fstat (fd, &st))
-    exit(2);
+    return 2;
 
   x = (char*)mmap(0, st.st_size, PROT_READ, MAP_PRIVATE, fd, 0);
   if (x == (char *) -1)
-    exit(3);
+    return 3;
 
   if (x[0] != '1' || x[1] != ' ' || x[2] != '1' || x[3] != ' ')
-    exit(4);
+    return 4;
 
   if (munmap(x, st.st_size) < 0)
-    exit(5);
+    return 5;
 
-  exit(0);
+  return 0;
 }], ac_cv_func_mmap_file=yes, ac_cv_func_mmap_file=no,
 ac_cv_func_mmap_file=no)])
 if test $ac_cv_func_mmap_file = yes; then
diff --git a/support/sdbinutils/libiberty/aclocal.m4 b/support/sdbinutils/libiberty/aclocal.m4
index bf8a907100f9d210..1c1a399bdd0b769d 100644
--- a/support/sdbinutils/libiberty/aclocal.m4
+++ b/support/sdbinutils/libiberty/aclocal.m4
@@ -15,6 +15,7 @@ AC_CACHE_CHECK([for working strncmp], ac_cv_func_strncmp_works,
 /* Test by Jim Wilson and Kaveh Ghazi.
    Check whether strncmp reads past the end of its string parameters. */
 #include <sys/types.h>
+#include <string.h>
 
 #ifdef HAVE_FCNTL_H
 #include <fcntl.h>
@@ -41,7 +42,8 @@ AC_CACHE_CHECK([for working strncmp], ac_cv_func_strncmp_works,
 
 #define MAP_LEN 0x10000
 
-main ()
+int
+main (void)
 {
 #if defined(HAVE_MMAP) || defined(HAVE_MMAP_ANYWHERE)
   char *p;
@@ -49,7 +51,7 @@ main ()
 
   dev_zero = open ("/dev/zero", O_RDONLY);
   if (dev_zero < 0)
-    exit (1);
+    return 1;
   
   p = (char *) mmap (0, MAP_LEN, PROT_READ|PROT_WRITE,
 		     MAP_ANON|MAP_PRIVATE, dev_zero, 0);
@@ -57,7 +59,7 @@ main ()
     p = (char *) mmap (0, MAP_LEN, PROT_READ|PROT_WRITE,
 		       MAP_ANON|MAP_PRIVATE, -1, 0);
   if (p == (char *)-1)
-    exit (2);
+    return 2;
   else
     {
       char *string = "__si_type_info";
@@ -69,7 +71,7 @@ main ()
       strncmp (r, q, 14);
     }
 #endif /* HAVE_MMAP || HAVE_MMAP_ANYWHERE */
-  exit (0);
+  return 0;
 }
 ], ac_cv_func_strncmp_works=yes, ac_cv_func_strncmp_works=no,
   ac_cv_func_strncmp_works=yes)
@@ -147,7 +149,8 @@ if test $ac_cv_os_cray = yes; then
 fi
 
 AC_CACHE_CHECK(stack direction for C alloca, ac_cv_c_stack_direction,
-[AC_TRY_RUN([find_stack_direction ()
+[AC_TRY_RUN([int
+find_stack_direction (void)
 {
   static char *addr = 0;
   auto char dummy;
@@ -159,9 +162,10 @@ AC_CACHE_CHECK(stack direction for C alloca, ac_cv_c_stack_direction,
   else
     return (&dummy > addr) ? 1 : -1;
 }
-main ()
+int
+main (void)
 {
-  exit (find_stack_direction() < 0);
+  return find_stack_direction() < 0;
 }], 
   ac_cv_c_stack_direction=1,
   ac_cv_c_stack_direction=-1,