[CLN-list] [patch] do not use `exit' in tests

Ralf Wildenhues Ralf.Wildenhues at gmx.de
Wed Apr 19 16:21:57 CEST 2006


Upcoming Autoconf-2.60 will not provide a declaration for exit;
it has turned out that tracking MSVC incompatibilites here is
a lot of work.  Instead, returning from main is suggested as a
viable alternative (the systems where that was not portable are
not likely to be used any more).

The following patch does that for the macros in CLN.

Cheers,
Ralf

	* m4/longdouble.m4 (CL_LONGDOUBLE): `return', rather than `exit'
	from main.
	* m4/longlong.m4 (CL_LONGLONG): Likewise.
	* m4/times.m4 (CL_TIMES_CLOCK): Likewise.
	* m4/general.m4 (CL_CC_WORKS): Likewise, do this for a C test to
	work when users set `$CC' to a C++ compiler.

Index: m4/general.m4
===================================================================
RCS file: /home/cvs/cln/m4/general.m4,v
retrieving revision 1.1
diff -u -r1.1 general.m4
--- m4/general.m4	29 Aug 2005 13:18:40 -0000	1.1
+++ m4/general.m4	11 Apr 2006 10:04:22 -0000
@@ -93,7 +93,7 @@
 [AC_CACHE_CHECK(whether CC works at all, cl_cv_prog_cc_works, [
 AC_LANG_SAVE()
 AC_LANG_C()
-AC_TRY_RUN([int main() { exit(0); }],
+AC_TRY_RUN([int main() { return 0; }],
 cl_cv_prog_cc_works=yes, cl_cv_prog_cc_works=no,
 AC_TRY_LINK([], [], cl_cv_prog_cc_works=yes, cl_cv_prog_cc_works=no))
 AC_LANG_RESTORE()
Index: m4/longdouble.m4
===================================================================
RCS file: /home/cvs/cln/m4/longdouble.m4,v
retrieving revision 1.1
diff -u -r1.1 longdouble.m4
--- m4/longdouble.m4	29 Aug 2005 13:18:40 -0000	1.1
+++ m4/longdouble.m4	11 Apr 2006 10:04:22 -0000
@@ -12,7 +12,7 @@
 AC_DEFUN([CL_LONGDOUBLE],
 [AC_CACHE_CHECK(for long double type, cl_cv_c_longdouble, [
 AC_TRY_RUN([int main()
-{ long double x = 2.7182818284590452354L; x = x*x; exit (x==0.0L); }],
+{ long double x = 2.7182818284590452354L; x = x*x; return x==0.0L; }],
 cl_cv_c_longdouble=yes, cl_cv_c_longdouble=no, [
 dnl When cross-compiling, use the test from gnulib.
 AC_TRY_COMPILE([
Index: m4/longlong.m4
===================================================================
RCS file: /home/cvs/cln/m4/longlong.m4,v
retrieving revision 1.1
diff -u -r1.1 longlong.m4
--- m4/longlong.m4	29 Aug 2005 13:18:40 -0000	1.1
+++ m4/longlong.m4	11 Apr 2006 10:04:22 -0000
@@ -19,11 +19,11 @@
    miscompiled. */
 #if defined(__m68k__) || (defined(_IBMR2) || defined(__powerpc))
 #if defined(__GNUC__) && (__GNUC__ == 2) && (__GNUC_MINOR__ <= 7)
-  exit(1);
+  return 1;
 #endif
 #endif
   { long x = 944938507; long y = 737962842; long z = 162359677;
-    exit(!(((long long) x)*((long long) y)>>32 == z));
+    return !(((long long) x)*((long long) y)>>32 == z);
   }
 }],
 cl_cv_c_longlong=yes, cl_cv_c_longlong=no, [
Index: m4/times.m4
===================================================================
RCS file: /home/cvs/cln/m4/times.m4,v
retrieving revision 1.1
diff -u -r1.1 times.m4
--- m4/times.m4	29 Aug 2005 13:18:40 -0000	1.1
+++ m4/times.m4	11 Apr 2006 10:04:22 -0000
@@ -29,12 +29,12 @@
   clock_t result2;
   int ticks;
   result1 = times(&buffer);
-  if ((result1 == (clock_t)0) || (result1 == (clock_t)(-1))) exit(1);
+  if ((result1 == (clock_t)0) || (result1 == (clock_t)(-1))) return 1;
   sleep(1);
   result2 = times(&buffer);
-  if ((result2 == (clock_t)0) || (result2 == (clock_t)(-1))) exit(1);
+  if ((result2 == (clock_t)0) || (result2 == (clock_t)(-1))) return 1;
   ticks = result2 - result1;
-  exit(!((ticks >= CLK_TCK/2) && (ticks <= 3*CLK_TCK/2)));
+  return !((ticks >= CLK_TCK/2) && (ticks <= 3*CLK_TCK/2));
 }], cl_cv_func_times_return=yes, cl_cv_func_times_return=no,
 dnl When cross-compiling, don't assume anything.
 cl_cv_func_times_return="guessing no")


More information about the CLN-list mailing list