From 8b1aeab78314ecdeaccbcd72e3589887d717f218 Mon Sep 17 00:00:00 2001 From: Darshit Shah Date: Tue, 29 Dec 2020 01:22:38 +0100 Subject: [PATCH] Remove portability handling code for wgint Gnulib's stdint.h module promises a C99 compliant stdint.h file on all platforms. Thus allowing us to directly use the fixed wodth integer type, int64_t wihout needing to resort to all the checks being performed. * src/wget.h: Assume that int64_t is always available and use it * src/mswindows.h: Remove portability code since gnulib handles it * configure.ac: Remove sizeof checks for integer types that are no longer used --- configure.ac | 4 ---- src/mswindows.h | 16 -------------- src/wget.h | 56 +++++++++++-------------------------------------- 3 files changed, 12 insertions(+), 64 deletions(-) diff --git a/configure.ac b/configure.ac index 91e49bee..b8a60e2c 100644 --- a/configure.ac +++ b/configure.ac @@ -319,11 +319,7 @@ dnl Check sizes of integer types. These are used to find n-bit dnl integral types on older systems that fail to provide intN_t and dnl uintN_t typedefs. dnl -AC_CHECK_SIZEOF([short]) -AC_CHECK_SIZEOF([int]) AC_CHECK_SIZEOF([long]) -AC_CHECK_SIZEOF([long long]) -AC_CHECK_SIZEOF([void *]) dnl dnl Checks for non-universal or system-specific types. diff --git a/src/mswindows.h b/src/mswindows.h index 0a8b97ac..5012232f 100644 --- a/src/mswindows.h +++ b/src/mswindows.h @@ -69,22 +69,6 @@ as that of the covered work. */ #include -/* Define a wgint type under Windows. */ -typedef __int64 wgint; -#define SIZEOF_WGINT 8 - -/* str_to_wgint is a function with the semantics of strtol[l], but - which works on wgint. */ -#if defined HAVE_STRTOLL -# define str_to_wgint strtoll -#elif defined HAVE__STRTOI64 -# define str_to_wgint _strtoi64 -#else -# define str_to_wgint strtoll -# define NEED_STRTOLL -# define strtoll_type __int64 -#endif - #define PATH_SEPARATOR '\\' /* ioctl needed by set_windows_fd_as_blocking_socket() */ diff --git a/src/wget.h b/src/wget.h index fcc0d361..5dd45db6 100644 --- a/src/wget.h +++ b/src/wget.h @@ -135,59 +135,27 @@ as that of the covered work. */ 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 +/* Gnulib's stdint.h module essentially guarantees the existence of int64_t. + * Thus we can simply assume it always exists and use it. + * However, just as a defensive tactic, a fallback has been implemented here + * with a compile time warning. + */ +#ifndef HAVE_INT64_T +# warning "int64_t not defined. Our portability layer should have caught this" /* Fall back to using long, which is always available and in most cases large enough. */ typedef long wgint; # define SIZEOF_WGINT SIZEOF_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 + typedef int64_t wgint; +# define SIZEOF_WGINT 8 #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 str_to_wgint strtol + #define WGINT_MAX TYPE_MAXIMUM (wgint) -/* Declare our strtoll replacement. */ -#ifdef NEED_STRTOLL -strtoll_type strtoll (const char *, char **, int); -#endif - /* Now define a large numeric type useful for storing sizes of *sums* of downloads, such as the value of the --quota option. This should be a type able to hold 2G+ values even on systems without large