]> andersk Git - openssh.git/commitdiff
- (dtucker) [configure.ac] Bug #1171: Don't use printf("%lld", longlong)
authordtucker <dtucker>
Mon, 13 Mar 2006 08:06:51 +0000 (08:06 +0000)
committerdtucker <dtucker>
Mon, 13 Mar 2006 08:06:51 +0000 (08:06 +0000)
   since not all platforms support it.  Instead, use internal equivalent while
   computing LLONG_MIN and LLONG_MAX.  Remove special case for alpha-dec-osf*
   as it's no longer required.  Tested by Bernhard Simon, ok djm@

ChangeLog
configure.ac

index 8b41194ab6961d4f62b9da9c017d043a574ab0ce..d94d34c2c75ab2c0670aa5a63c10cf3b37faf201 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+20060313
+ - (dtucker) [configure.ac] Bug #1171: Don't use printf("%lld", longlong)
+   since not all platforms support it.  Instead, use internal equivalent while
+   computing LLONG_MIN and LLONG_MAX.  Remove special case for alpha-dec-osf*
+   as it's no longer required.  Tested by Bernhard Simon, ok djm@
+
 20060304
  - (dtucker) [contrib/cygwin/ssh-host-config] Require use of lastlog as a
    file rather than directory, required as Cygwin will be importing lastlog(1).
index 6a9c8e047d8a34a3a8340d504f1bc877e317c810..3f9c55f6e105218c67f2d0875d6e241f52e55b2c 100644 (file)
@@ -2132,6 +2132,34 @@ if test -z "$have_llong_max"; then
 #define __USE_ISOC99
 #include <limits.h>
 #define DATA "conftest.llminmax"
+#define my_abs(a) ((a) < 0 ? ((a) * -1) : (a))
+
+/*
+ * printf in libc on some platforms (eg old Tru64) does not understand %lld so
+ * we do this the hard way.
+ */
+static int
+fprint_ll(FILE *f, long long n)
+{
+       unsigned int i;
+       int l[sizeof(long long) * 8];
+
+       if (n < 0)
+               if (fprintf(f, "-") < 0)
+                       return -1;
+       for (i = 0; n != 0; i++) {
+               l[i] = my_abs(n % 10);
+               n /= 10;
+       }
+       do {
+               if (fprintf(f, "%d", l[--i]) < 0)
+                       return -1;
+       } while (i != 0);
+       if (fprintf(f, " ") < 0)
+               return -1;
+       return 0;
+}
+
 int main(void) {
        FILE *f;
        long long i, llmin, llmax = 0;
@@ -2153,14 +2181,18 @@ int main(void) {
 
        /* Sanity check */
        if (llmin + 1 < llmin || llmin - 1 < llmin || llmax + 1 > llmax
-           || llmax - 1 > llmax) {
+           || llmax - 1 > llmax || llmin == llmax || llmin == 0
+           || llmax == 0 || llmax < LONG_MAX || llmin > LONG_MIN) {
                fprintf(f, "unknown unknown\n");
                exit(2);
        }
 
-       if (fprintf(f ,"%lld %lld", llmin, llmax) < 0)
+       if (fprint_ll(f, llmin) < 0)
                exit(3);
-
+       if (fprint_ll(f, llmax) < 0)
+               exit(4);
+       if (fclose(f) < 0)
+               exit(5);
        exit(0);
 }
                ]])],
@@ -2168,17 +2200,6 @@ int main(void) {
                        llong_min=`$AWK '{print $1}' conftest.llminmax`
                        llong_max=`$AWK '{print $2}' conftest.llminmax`
 
-                       # snprintf on some Tru64s doesn't understand "%lld"
-                       case "$host" in
-                       alpha-dec-osf*)
-                               if test "x$ac_cv_sizeof_long_long_int" = "x8" &&
-                                 test "x$llong_max" = "xld"; then
-                                       llong_min="-9223372036854775808"
-                                       llong_max="9223372036854775807"
-                               fi
-                               ;;
-                       esac
-
                        AC_MSG_RESULT($llong_max)
                        AC_DEFINE_UNQUOTED(LLONG_MAX, [${llong_max}LL],
                            [max value of long long calculated by configure])
This page took 0.040597 seconds and 5 git commands to generate.