]> sjero.net Git - wget/commitdiff
[svn] Allow 64-bit wgint without LFS.
authorhniksic <devnull@localhost>
Mon, 26 Jun 2006 18:31:28 +0000 (11:31 -0700)
committerhniksic <devnull@localhost>
Mon, 26 Jun 2006 18:31:28 +0000 (11:31 -0700)
configure.in
src/ChangeLog
src/cmpt.c
src/mswindows.h
src/sysdep.h
src/wget.h

index 436efc9958431581242faa9a68334d07215849e8..529d16b12bbd2a96c200940f9b9a0197648df080 100644 (file)
@@ -189,7 +189,7 @@ dnl Checks for non-universal or system-specific types.
 dnl
 AC_TYPE_SIZE_T
 AC_TYPE_PID_T
-AC_CHECK_TYPES([uint32_t, uintptr_t])
+AC_CHECK_TYPES([uint32_t, uintptr_t, int64_t])
 AC_CHECK_TYPES(sig_atomic_t, [], [], [
 #include <stdio.h>
 #include <sys/types.h>
index e17229ebcd5a97e224460c0603ffd0b553f0ab23..51c194f8686c5d9363c6c5f9d8f02d8c2a3ce29c 100644 (file)
@@ -1,3 +1,8 @@
+2006-06-26  Hrvoje Niksic  <hniksic@xemacs.org>
+
+       * wget.h (wgint): Typedef to any 64-bit (or larger) type we can
+       find, not necessarily off_t or long.
+
 2006-06-26  Hrvoje Niksic  <hniksic@xemacs.org>
 
        * cmpt.c (strtoll): Check for overflow and underflow without
index aed889f158fa75c2d67fad8a4d9c9c004290bf8c..a6b2607389f307afbc8dd7f52702681298351940 100644 (file)
@@ -1315,8 +1315,6 @@ char_value (char c, int base)
   return value;
 }
 
-#define TYPE_MAXIMUM(t) ((t) (~ (~ (t) 0 << (sizeof (t) * CHAR_BIT - 1))))
-
 #define STRTOLL_MAX TYPE_MAXIMUM (strtoll_type)
 /* This definition assumes two's complement arithmetic */
 #define STRTOLL_MIN (-STRTOLL_MAX - 1)
index 8b9330b0be2d701488179e8973918b86ed4fbace..c61c56edbf87130767ca4f274b1923249faadb09 100644 (file)
@@ -84,7 +84,6 @@ so, delete this exception statement from your version.  */
 /* Define a wgint type under Windows. */
 typedef __int64 wgint;
 #define SIZEOF_WGINT 8
-#define WGINT_MAX LL (9223372036854775807)
 
 /* str_to_wgint is a function with the semantics of strtol[l], but
    which works on wgint.  */
index 38963901b1a73cb13ea640efda59d99348784178..9ac67a8e0919f8d928f5514a3a16218289716525 100644 (file)
@@ -112,13 +112,8 @@ typedef unsigned char _Bool;
 # define CHAR_BIT 8
 #endif
 
-/* Used by wget.h to define SIZEOF_WGINT. */
-#ifndef LONG_MAX
-# define LONG_MAX ((long) ~((unsigned long)1 << (CHAR_BIT * sizeof (long) - 1)))
-#endif
-#ifndef LLONG_MAX
-# define LLONG_MAX ((long long) ~((unsigned long long)1 << (CHAR_BIT * sizeof (long long) - 1)))
-#endif
+/* From gnulib, simplified to assume a signed type. */
+#define TYPE_MAXIMUM(t) ((t) (~ (~ (t) 0 << (sizeof (t) * CHAR_BIT - 1))))
 
 /* These are defined in cmpt.c if missing, so we must declare
    them.  */
index d0303e4070de258a71d6c124c3836641d16d2a21..ee27b8f103d74cd22a17b56e04b7608ec0d18d1a 100644 (file)
@@ -119,31 +119,60 @@ so, delete this exception statement from your version.  */
 
 #define DEBUGP(args) do { IF_DEBUG { debug_logprintf args; } } while (0)
 
-/* Define an integer type that works for file sizes, content lengths,
-   and such.  Normally we could just use off_t, but off_t is always
-   32-bit on Windows.  */
-
-#ifndef WINDOWS
-typedef off_t wgint;
+/* Pick an integer type large enough for file sizes, content lengths,
+   and such.  Because today's files can be very large, it should be a
+   signed integer at least 64 bits wide.  This can't be typedeffed to
+   off_t because: a) off_t is always 32-bit on Windows, and b) we
+   don't necessarily want to tie having a 64-bit type for internal
+   calculations to having LFS support.  */
+
+#ifdef WINDOWS
+  /* nothing to do, see mswindows.h */
+#elif SIZEOF_LONG >= 8
+  /* long is large enough, so use it. */
+  typedef long wgint;
+# define SIZEOF_WGINT SIZEOF_LONG
+#elif SIZEOF_LONG_LONG >= 8
+  /* long long is large enough and available, use that */
+  typedef long long wgint;
+# define SIZEOF_WGINT SIZEOF_LONG_LONG
+#elif HAVE_INT64_T
+  typedef int64_t wgint;
+# define SIZEOF_WGINT 8
+#elif SIZEOF_OFF_T >= 8
+  /* In case off_t is typedeffed to a large non-standard type that our
+     tests don't find. */
+  typedef off_t wgint;
 # define SIZEOF_WGINT SIZEOF_OFF_T
+#else
+  /* Fall back to using long, which is always available and in most
+     cases large enough. */
+typedef long off_t;
+# define SIZEOF_WGINT SIZEOF_LONG
+#endif
 
-/* Pick the strtol-like function that will work with wgint.  */
-# if SIZEOF_WGINT == SIZEOF_LONG
-#  define str_to_wgint strtol
-#  define WGINT_MAX LONG_MAX
-# else
-#  define WGINT_MAX LLONG_MAX
-#  ifdef HAVE_STRTOLL
-#   define str_to_wgint strtoll
-#  elif defined HAVE_STRTOIMAX /* HPUX 11.0 has strtoimax, but no strtoll */
-#   define str_to_wgint strtoimax
-#  else
-#   define str_to_wgint strtoll
-#   define NEED_STRTOLL
-#   define strtoll_type long long
-#  endif
+/* Pick a strtol-compatible function that will work with wgint.  The
+   choices are strtol, strtoll, or our own implementation of strtoll
+   in cmpt.c, activated with NEED_STRTOLL.  */
+
+#ifdef WINDOWS
+  /* nothing to do, see mswindows.h */
+#elif SIZEOF_WGINT == SIZEOF_LONG
+# define str_to_wgint strtol
+#elif SIZEOF_WGINT == SIZEOF_LONG_LONG
+# define str_to_wgint strtoll
+# ifndef HAVE_STRTOLL
+#  define NEED_STRTOLL
+#  define strtoll_type long long
 # endif
-#endif /* not WINDOWS */
+#else
+  /* wgint has a strange size; synthesize strtoll and use it. */
+# define str_to_wgint strtoll
+# define NEED_STRTOLL
+# define strtoll_type wgint
+#endif
+
+#define WGINT_MAX TYPE_MAXIMUM (wgint)
 
 /* Declare our strtoll replacement. */
 #ifdef NEED_STRTOLL