From a6f72ca66b1ca3c83fb7336c5895af9ae0a3c202 Mon Sep 17 00:00:00 2001 From: hniksic Date: Sat, 11 Oct 2003 05:41:13 -0700 Subject: [PATCH] [svn] Also check for short for int32_t. --- configure.in | 1 + src/ChangeLog | 4 ++++ src/config.h.in | 8 +++----- src/snprintf.c | 6 +++--- src/sysdep.h | 39 +++++++++++++++++++++++---------------- windows/config.h.bor | 3 +++ windows/config.h.ms | 4 +++- 7 files changed, 40 insertions(+), 25 deletions(-) diff --git a/configure.in b/configure.in index d5f3ffd7..d9104895 100644 --- a/configure.in +++ b/configure.in @@ -160,6 +160,7 @@ AC_C_BIGENDIAN dnl dnl Check integral type sizes. dnl +AC_CHECK_SIZEOF(short) AC_CHECK_SIZEOF(int) AC_CHECK_SIZEOF(long) AC_CHECK_SIZEOF(long long) diff --git a/src/ChangeLog b/src/ChangeLog index 2e7fc750..eaa9ec49 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,7 @@ +2003-10-11 Hrvoje Niksic + + * sysdep.h: Also check size of short for int32_t. + 2003-10-11 Hrvoje Niksic * host.c (lookup_host): Use u_int32_t to store the result of diff --git a/src/config.h.in b/src/config.h.in index c05f00c3..64d1459f 100644 --- a/src/config.h.in +++ b/src/config.h.in @@ -80,6 +80,9 @@ char *alloca (); significant byte first). */ #undef WORDS_BIGENDIAN +/* Define to the length of short. */ +#undef SIZEOF_SHORT + /* Define to the length of int. */ #undef SIZEOF_INT @@ -89,11 +92,6 @@ char *alloca (); /* Define to the length of long long. */ #undef SIZEOF_LONG_LONG -#undef HAVE_LONG_LONG -#if SIZEOF_LONG_LONG != 0 -# define HAVE_LONG_LONG -#endif - /* Define this if you want the NLS support. */ #undef HAVE_NLS diff --git a/src/snprintf.c b/src/snprintf.c index f8dffa4a..5baa98b6 100644 --- a/src/snprintf.c +++ b/src/snprintf.c @@ -107,7 +107,7 @@ #define LDOUBLE double #endif -#ifdef HAVE_LONG_LONG +#if SIZEOF_LONG_LONG != 0 # define LLONG long long #else # define LLONG long @@ -849,7 +849,7 @@ int main (void) NULL }; long int_nums[] = { -1, 134, 91340, 341, 0203, 0}; -#ifdef HAVE_LONG_LONG +#if SIZEOF_LONG_LONG != 0 char *llong_fmt[] = { "%lld", "%llu", "%-1.5lld", "%-1.5llu", @@ -905,7 +905,7 @@ int main (void) num++; } -#ifdef HAVE_LONG_LONG +#if SIZEOF_LONG_LONG != 0 for (x = 0; llong_fmt[x] != NULL ; x++) for (y = 0; llong_nums[y] != 0 ; y++) { diff --git a/src/sysdep.h b/src/sysdep.h index 2defc65a..05a0e773 100644 --- a/src/sysdep.h +++ b/src/sysdep.h @@ -129,23 +129,19 @@ do { \ } while (0) /* Define a large ("very long") type useful for storing large - non-negative quantities that exceed sizes of normal download, such - as the *total* number of bytes downloaded. To fit today's needs, - this needs to be an integral type at least 64 bits wide. On the - machines where `long' is 64-bit, we use long. Otherwise, we check - whether `long long' is available and if yes, use that. If long - long is unavailable, we give up and just use `long'. - - This check could be smarter and moved to configure, which could - check for a bunch of non-standard types such as uint64_t. But I - don't see the need for it -- the current test will work on all - modern architectures, and if it fails, nothing bad happens, we just - end up with long. + non-negative quantities that exceed sizes of normal download. Note + that this has nothing to do with large file support. For example, + one should be able to say `--quota=10G', large files + notwithstanding. + + On the machines where `long' is 64-bit, we use long. Otherwise, we + check whether `long long' is available and if yes, use that. If + long long is unavailable, we give up and just use `long'. Note: you cannot use VERY_LONG_TYPE along with printf(). When you need to print it, use very_long_to_string(). */ -#if (SIZEOF_LONG >= 8) || !defined(HAVE_LONG_LONG) +#if SIZEOF_LONG >= 8 || SIZEOF_LONG_LONG == 0 /* either long is "big enough", or long long is unavailable which leaves long as the only choice. */ # define VERY_LONG_TYPE unsigned long @@ -243,7 +239,10 @@ void *memcpy (); int fnmatch (); #endif -/* Provide 32-bit types for the code that really needs it. */ +/* Provide 32-bit types. Most code shouldn't care, but there is code + that really needs a 32-bit integral type. If int32_t and u_int32_t + are present, we use them, otherwise we pick one of int/short/long, + and throw an error if none of them works. */ #ifndef HAVE_INT32_T # if SIZEOF_INT == 4 @@ -252,7 +251,11 @@ typedef int int32_t; # if SIZEOF_LONG == 4 typedef long int32_t; # else - "Cannot determine a 32-bit type" +# if SIZEOF_SHORT == 4 +typedef short int32_t; +# else + #error "Cannot determine a 32-bit type" +# endif # endif # endif #endif @@ -264,7 +267,11 @@ typedef unsigned int u_int32_t; # if SIZEOF_LONG == 4 typedef unsigned long u_int32_t; # else - "Cannot determine a 32-bit type" +# if SIZEOF_SHORT == 4 +typedef unsigned short u_int32_t; +# else + #error "Cannot determine a 32-bit type" +# endif # endif # endif #endif diff --git a/windows/config.h.bor b/windows/config.h.bor index 459ce396..a350c90b 100644 --- a/windows/config.h.bor +++ b/windows/config.h.bor @@ -183,6 +183,9 @@ /* Define if you have the isatty function. */ #define HAVE_ISATTY +/* Define to the length of short. */ +#define SIZEOF_SHORT 2 + /* Define to the length of int. */ #define SIZEOF_INT 4 diff --git a/windows/config.h.ms b/windows/config.h.ms index b825ce95..c3a3ca8b 100644 --- a/windows/config.h.ms +++ b/windows/config.h.ms @@ -187,6 +187,9 @@ /* Define if you have the memmove function */ #define HAVE_MEMMOVE 1 +/* Define to the length of short. */ +#define SIZEOF_SHORT 2 + /* Define to the length of int. */ #define SIZEOF_INT 4 @@ -203,4 +206,3 @@ #define HAVE_U_INT32_T 1 #endif /* CONFIG_H */ - -- 2.39.2