From d1450dbe2ab1cc06fd54af265014dfcf68c08cc1 Mon Sep 17 00:00:00 2001 From: Darren Tucker Date: Mon, 13 Mar 2006 19:06:51 +1100 Subject: - (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@ --- ChangeLog | 8 +++++++- configure.ac | 53 +++++++++++++++++++++++++++++++++++++---------------- 2 files changed, 44 insertions(+), 17 deletions(-) diff --git a/ChangeLog b/ChangeLog index 76129a5e4..f95f561f8 100644 --- 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). @@ -3892,4 +3898,4 @@ - (djm) Trim deprecated options from INSTALL. Mention UsePAM - (djm) Fix quote handling in sftp; Patch from admorten AT umich.edu -$Id: ChangeLog,v 1.4138 2006/03/03 22:00:19 dtucker Exp $ +$Id: ChangeLog,v 1.4139 2006/03/13 08:06:51 dtucker Exp $ diff --git a/configure.ac b/configure.ac index 0781d59fe..adef4f675 100644 --- a/configure.ac +++ b/configure.ac @@ -1,4 +1,4 @@ -# $Id: configure.ac,v 1.332 2006/02/26 01:31:49 dtucker Exp $ +# $Id: configure.ac,v 1.333 2006/03/13 08:06:51 dtucker Exp $ # # Copyright (c) 1999-2004 Damien Miller # @@ -15,7 +15,7 @@ # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. AC_INIT(OpenSSH, Portable, openssh-unix-dev@mindrot.org) -AC_REVISION($Revision: 1.332 $) +AC_REVISION($Revision: 1.333 $) AC_CONFIG_SRCDIR([ssh.c]) AC_CONFIG_HEADER(config.h) @@ -2132,6 +2132,34 @@ if test -z "$have_llong_max"; then #define __USE_ISOC99 #include #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]) -- cgit v1.2.3