[svn] Allow 64-bit wgint without LFS.

This commit is contained in:
hniksic 2006-06-26 11:31:28 -07:00
parent 48f21f4a71
commit 19c5c1d52f
6 changed files with 58 additions and 32 deletions

View 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>

View 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

View 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)

View 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. */

View 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. */

View 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. */
/* 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. */
#ifndef WINDOWS
typedef off_t wgint;
#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