bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSK(OSS) compilation problem


From: Paul Eggert
Subject: Re: NSK(OSS) compilation problem
Date: Tue, 07 Nov 2006 22:22:04 -0800
User-agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/21.4 (gnu/linux)

Matthew Woehlke <address@hidden> writes:

> Eh? How is testing if ((1<<1)>>1) == 1 "too strict"?

It's not.  But it wasn't clear from your earlier posting whether the
failure was 1LL<<1>>1 or 1LL<<63>>63.  The latter is not required to
yield 1 (assuming long long is 64 bits), because C doesn't define the
semantics of right shift of a negative integer.

> btw, was I supposed to see something different from your version? It
> is admittedly much more platform-agnostic (I wasn't trying :-)), but I
> didn't see anything that would cause me to expect yours to give
> different results.

Good.  That's what we want.  We want a test case that fails
reliably on your platform but should succeed reliably on any
conforming host.

I installed the following patch into gnulib and will install
something similar into Autoconf shortly.

2006-11-07  Paul Eggert  <address@hidden>

        * m4/longlong.m4 (AC_TYPE_LONG_LONG_INT): Detect bug in
        Tandem NonStop Kernel (OSS) cc -O circa 2004, reported by
        Matthew Woehlke.

--- m4/longlong.m4      11 Oct 2006 15:37:54 -0000      1.10
+++ m4/longlong.m4      8 Nov 2006 06:21:25 -0000
@@ -1,4 +1,4 @@
-# longlong.m4 serial 8
+# longlong.m4 serial 9
 dnl Copyright (C) 1999-2006 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -11,7 +11,7 @@ dnl From Paul Eggert.
 # assume 2.61 everywhere.
 
 # Note: If the type 'long long int' exists but is only 32 bits large
-# (as on some very old compilers), AC_TYPE_LONG_LONG_INT will not be
+# (as on some very old compilers), HAVE_LONG_LONG_INT will not be
 # defined. In this case you can treat 'long long int' like 'long int'.
 
 AC_DEFUN([AC_TYPE_LONG_LONG_INT],
@@ -28,9 +28,33 @@ AC_DEFUN([AC_TYPE_LONG_LONG_INT],
          [[long long int llmax = 9223372036854775807ll;
            return ((ll << 63) | (ll >> 63) | (ll < i) | (ll > i)
                    | (llmax / ll) | (llmax % ll));]])],
-       [ac_cv_type_long_long_int=yes],
+       [dnl This catches a bug in Tandem NonStop Kernel (OSS) cc -O circa 2004.
+       dnl If cross compiling, assume the bug isn't important, since
+       dnl nobody cross compiles for this platform as far as we know.
+        AC_RUN_IFELSE(
+         [AC_LANG_PROGRAM(
+            address@hidden:@include <limits.h>
+              @%:@ifndef LLONG_MAX
+              @%:@ define HALF \
+                       (1LL << (sizeof (long long int) * CHAR_BIT - 2))
+              @%:@ define LLONG_MAX (HALF - 1 + HALF)
+              @%:@endif]],
+            [[long long int n = 1;
+              int i;
+              for (i = 0; ; i++)
+                {
+                  long long int m = n << i;
+                  if (m >> i != n)
+                    return 1;
+                  if (LLONG_MAX / 2 < m)
+                    break;
+                }
+              return 0;]])],
+         [ac_cv_type_long_long_int=yes],
+         [ac_cv_type_long_long_int=no],
+         [ac_cv_type_long_long_int=cross-compiling])],
        [ac_cv_type_long_long_int=no])])
-  if test $ac_cv_type_long_long_int = yes; then
+  if test $ac_cv_type_long_long_int != no; then
     AC_DEFINE([HAVE_LONG_LONG_INT], 1,
       [Define to 1 if the system has the type `long long int'.])
   fi




reply via email to

[Prev in Thread] Current Thread [Next in Thread]