Assert that the variable used as array index is not negative before using it.
[geos.git] / acsite.m4
blobe7e2badb8cafef6b37d2ea1f07c705ff826a61b6
1 # This has been taken from postgres-7.3.4 local macros
4 # PGAC_TYPE_64BIT_INT(TYPE)
5 # -------------------------
6 # Check if TYPE is a working 64 bit integer type. Set HAVE_TYPE_64 to
7 # yes or no respectively, and define HAVE_TYPE_64 if yes.
8 AC_DEFUN([PGAC_TYPE_64BIT_INT],
9 [define([Ac_define], [translit([have_$1_64], [a-z *], [A-Z_P])])dnl
10 define([Ac_cachevar], [translit([pgac_cv_type_$1_64], [ *], [_p])])dnl
11 AC_CACHE_CHECK([whether $1 is 64 bits], [Ac_cachevar],
12 [AC_TRY_RUN(
15 #include <inttypes.h>
17 typedef $1 int64;
20  * These are globals to discourage the compiler from folding all the
21  * arithmetic tests down to compile-time constants.
22  */
23 int64 a = 20000001;
24 int64 b = 40000005;
26 int does_int64_work()
28   int64 c,d;
30   if (sizeof(int64) != 8)
31     return 0;                   /* definitely not the right size */
33   /* Do perfunctory checks to see if 64-bit arithmetic seems to work */
34   c = a * b;
35   d = (c + b) / b;
36   if (d != a+1)
37     return 0;
38   return 1;
40 main() {
41   exit(! does_int64_work());
42 }],
43 [Ac_cachevar=yes],
44 [Ac_cachevar=no],
45 [Ac_cachevar=no
46 dnl We will do better here with Autoconf 2.50
47 AC_MSG_WARN([64 bit arithmetic disabled when cross-compiling])])])
49 Ac_define=$Ac_cachevar
50 if test x"$Ac_cachevar" = xyes ; then
51   AC_DEFINE(Ac_define,, [Set to 1 if `]$1[' is 64 bits])
53 undefine([Ac_define])dnl
54 undefine([Ac_cachevar])dnl
55 ])# PGAC_TYPE_64BIT_INT