[svn] Also check for short for int32_t.

This commit is contained in:
hniksic 2003-10-11 05:41:13 -07:00
parent 9a282c83d7
commit a6f72ca66b
7 changed files with 39 additions and 24 deletions

View File

@ -160,6 +160,7 @@ AC_C_BIGENDIAN
dnl dnl
dnl Check integral type sizes. dnl Check integral type sizes.
dnl dnl
AC_CHECK_SIZEOF(short)
AC_CHECK_SIZEOF(int) AC_CHECK_SIZEOF(int)
AC_CHECK_SIZEOF(long) AC_CHECK_SIZEOF(long)
AC_CHECK_SIZEOF(long long) AC_CHECK_SIZEOF(long long)

View File

@ -1,3 +1,7 @@
2003-10-11 Hrvoje Niksic <hniksic@xemacs.org>
* sysdep.h: Also check size of short for int32_t.
2003-10-11 Hrvoje Niksic <hniksic@xemacs.org> 2003-10-11 Hrvoje Niksic <hniksic@xemacs.org>
* host.c (lookup_host): Use u_int32_t to store the result of * host.c (lookup_host): Use u_int32_t to store the result of

View File

@ -80,6 +80,9 @@ char *alloca ();
significant byte first). */ significant byte first). */
#undef WORDS_BIGENDIAN #undef WORDS_BIGENDIAN
/* Define to the length of short. */
#undef SIZEOF_SHORT
/* Define to the length of int. */ /* Define to the length of int. */
#undef SIZEOF_INT #undef SIZEOF_INT
@ -89,11 +92,6 @@ char *alloca ();
/* Define to the length of long long. */ /* Define to the length of long long. */
#undef SIZEOF_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. */ /* Define this if you want the NLS support. */
#undef HAVE_NLS #undef HAVE_NLS

View File

@ -107,7 +107,7 @@
#define LDOUBLE double #define LDOUBLE double
#endif #endif
#ifdef HAVE_LONG_LONG #if SIZEOF_LONG_LONG != 0
# define LLONG long long # define LLONG long long
#else #else
# define LLONG long # define LLONG long
@ -849,7 +849,7 @@ int main (void)
NULL NULL
}; };
long int_nums[] = { -1, 134, 91340, 341, 0203, 0}; long int_nums[] = { -1, 134, 91340, 341, 0203, 0};
#ifdef HAVE_LONG_LONG #if SIZEOF_LONG_LONG != 0
char *llong_fmt[] = { char *llong_fmt[] = {
"%lld", "%llu", "%lld", "%llu",
"%-1.5lld", "%-1.5llu", "%-1.5lld", "%-1.5llu",
@ -905,7 +905,7 @@ int main (void)
num++; num++;
} }
#ifdef HAVE_LONG_LONG #if SIZEOF_LONG_LONG != 0
for (x = 0; llong_fmt[x] != NULL ; x++) for (x = 0; llong_fmt[x] != NULL ; x++)
for (y = 0; llong_nums[y] != 0 ; y++) for (y = 0; llong_nums[y] != 0 ; y++)
{ {

View File

@ -129,23 +129,19 @@ do { \
} while (0) } while (0)
/* Define a large ("very long") type useful for storing large /* Define a large ("very long") type useful for storing large
non-negative quantities that exceed sizes of normal download, such non-negative quantities that exceed sizes of normal download. Note
as the *total* number of bytes downloaded. To fit today's needs, that this has nothing to do with large file support. For example,
this needs to be an integral type at least 64 bits wide. On the one should be able to say `--quota=10G', large files
machines where `long' is 64-bit, we use long. Otherwise, we check notwithstanding.
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 On the machines where `long' is 64-bit, we use long. Otherwise, we
check for a bunch of non-standard types such as uint64_t. But I check whether `long long' is available and if yes, use that. If
don't see the need for it -- the current test will work on all long long is unavailable, we give up and just use `long'.
modern architectures, and if it fails, nothing bad happens, we just
end up with long.
Note: you cannot use VERY_LONG_TYPE along with printf(). When you Note: you cannot use VERY_LONG_TYPE along with printf(). When you
need to print it, use very_long_to_string(). */ 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 /* either long is "big enough", or long long is unavailable which
leaves long as the only choice. */ leaves long as the only choice. */
# define VERY_LONG_TYPE unsigned long # define VERY_LONG_TYPE unsigned long
@ -243,7 +239,10 @@ void *memcpy ();
int fnmatch (); int fnmatch ();
#endif #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 #ifndef HAVE_INT32_T
# if SIZEOF_INT == 4 # if SIZEOF_INT == 4
@ -252,7 +251,11 @@ typedef int int32_t;
# if SIZEOF_LONG == 4 # if SIZEOF_LONG == 4
typedef long int32_t; typedef long int32_t;
# else # 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 # endif
#endif #endif
@ -264,7 +267,11 @@ typedef unsigned int u_int32_t;
# if SIZEOF_LONG == 4 # if SIZEOF_LONG == 4
typedef unsigned long u_int32_t; typedef unsigned long u_int32_t;
# else # 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 # endif
#endif #endif

View File

@ -183,6 +183,9 @@
/* Define if you have the isatty function. */ /* Define if you have the isatty function. */
#define HAVE_ISATTY #define HAVE_ISATTY
/* Define to the length of short. */
#define SIZEOF_SHORT 2
/* Define to the length of int. */ /* Define to the length of int. */
#define SIZEOF_INT 4 #define SIZEOF_INT 4

View File

@ -187,6 +187,9 @@
/* Define if you have the memmove function */ /* Define if you have the memmove function */
#define HAVE_MEMMOVE 1 #define HAVE_MEMMOVE 1
/* Define to the length of short. */
#define SIZEOF_SHORT 2
/* Define to the length of int. */ /* Define to the length of int. */
#define SIZEOF_INT 4 #define SIZEOF_INT 4
@ -203,4 +206,3 @@
#define HAVE_U_INT32_T 1 #define HAVE_U_INT32_T 1
#endif /* CONFIG_H */ #endif /* CONFIG_H */