Commit 5895949a authored by Paul Eggert's avatar Paul Eggert

Port to Tandem NSK OSS, which has 64-bit signed int but at most

32-bit unsigned int.  Problem reported by Matthew Woehlke in:
http://lists.gnu.org/archive/html/bug-coreutils/2006-10/msg00062.html
More generally, don't assume that 64-bit signed int is available
if unsigned int is, and vice versa.
* lib/inttypes_.h (_PRIu64_PREFIX, _SCNu64_PREFIX): Depend on
unsigned symbols, not on their signed counterparts.
* lib/stdint_.h (uint64_t, uint_least64_t, uint_fast64_t, uintmax_t):
(UINT64_MAX, UINT_LEAST64_MAX, UINT_FAST64_MAX, UINTMAX_MAX):
(UINT64_C, UINTMAX_C):
Likewise.
* lib/strtoimax.c (strtoll): Depend on signed symbols, not their
unsigned counterparts.
(Have_long_long, Unsigned): New macros.
(Int): Renamed from INT.
(strtoimax): Use the new macros.
* m4/stdint.m4 (gl_STDINT_H): Require AC_TYPE_UNSIGNED_LONG_LONG_INT
and substitute HAVE_UNSIGNED_LONG_LONG_INT.
* modules/inttypes (inttypes.h): Substitute
HAVE_UNSIGNED_LONG_LONG_INT.
* modules/stdint (stdint.h): Likewise.
(Files): Add m4/ulonglong.m4.
parent d1118c8e
2006-10-10 Paul Eggert <eggert@cs.ucla.edu>
Port to Tandem NSK OSS, which has 64-bit signed int but at most
32-bit unsigned int. Problem reported by Matthew Woehlke in:
http://lists.gnu.org/archive/html/bug-coreutils/2006-10/msg00062.html
More generally, don't assume that 64-bit signed int is available
if unsigned int is, and vice versa.
* lib/inttypes_.h (_PRIu64_PREFIX, _SCNu64_PREFIX): Depend on
unsigned symbols, not on their signed counterparts.
* lib/stdint_.h (uint64_t, uint_least64_t, uint_fast64_t, uintmax_t):
(UINT64_MAX, UINT_LEAST64_MAX, UINT_FAST64_MAX, UINTMAX_MAX):
(UINT64_C, UINTMAX_C):
Likewise.
* lib/strtoimax.c (strtoll): Depend on signed symbols, not their
unsigned counterparts.
(Have_long_long, Unsigned): New macros.
(Int): Renamed from INT.
(strtoimax): Use the new macros.
* m4/stdint.m4 (gl_STDINT_H): Require AC_TYPE_UNSIGNED_LONG_LONG_INT
and substitute HAVE_UNSIGNED_LONG_LONG_INT.
* modules/inttypes (inttypes.h): Substitute
HAVE_UNSIGNED_LONG_LONG_INT.
* modules/stdint (stdint.h): Likewise.
(Files): Add m4/ulonglong.m4.
2006-10-10 Bruno Haible <bruno@clisp.org>
Fix a gcc -Wshadow warning.
......
......@@ -172,11 +172,11 @@
# endif
# endif
# ifdef UINT64_MAX
# if INT64_MAX == LONG_MAX
# if UINT64_MAX == ULONG_MAX
# define _PRIu64_PREFIX "l"
# elif defined _MSC_VER || defined __MINGW32__
# define _PRIu64_PREFIX "I64"
# elif @HAVE_LONG_LONG_INT@ && LONG_MAX >> 30 == 1
# elif @HAVE_UNSIGNED_LONG_LONG_INT@ && ULONG_MAX >> 31 == 1
# define _PRIu64_PREFIX "ll"
# endif
# if !defined PRIo64 || @PRI_MACROS_BROKEN@
......@@ -665,11 +665,11 @@
# endif
# endif
# ifdef UINT64_MAX
# if INT64_MAX == LONG_MAX
# if UINT64_MAX == ULONG_MAX
# define _SCNu64_PREFIX "l"
# elif defined _MSC_VER || defined __MINGW32__
# define _SCNu64_PREFIX "I64"
# elif @HAVE_LONG_LONG_INT@ && LONG_MAX >> 30 == 1
# elif @HAVE_UNSIGNED_LONG_LONG_INT@ && ULONG_MAX >> 31 == 1
# define _SCNu64_PREFIX "ll"
# endif
# if !defined SCNo64 || @PRI_MACROS_BROKEN@
......
......@@ -124,15 +124,20 @@
#define uint32_t unsigned int
#undef int64_t
#undef uint64_t
#if LONG_MAX >> 31 >> 31 == 1
# define int64_t long int
# define uint64_t unsigned long int
#elif defined _MSC_VER
# define int64_t __int64
# define uint64_t unsigned __int64
#elif @HAVE_LONG_LONG_INT@
# define int64_t long long int
#endif
#undef uint64_t
#if ULONG_MAX >> 31 >> 31 >> 1 == 1
# define uint64_t unsigned long int
#elif defined _MSC_VER
# define uint64_t unsigned __int64
#elif @HAVE_UNSIGNED_LONG_LONG_INT@
# define uint64_t unsigned long long int
#endif
......@@ -164,6 +169,8 @@
#define uint_least32_t uint32_t
#ifdef int64_t
# define int_least64_t int64_t
#endif
#ifdef uint64_t
# define uint_least64_t uint64_t
#endif
......@@ -193,6 +200,8 @@
#define uint_fast32_t unsigned int_fast32_t
#ifdef int64_t
# define int_fast64_t int64_t
#endif
#ifdef uint64_t
# define uint_fast64_t uint64_t
#endif
......@@ -209,15 +218,20 @@
public header files. */
#undef intmax_t
#undef uintmax_t
#if @HAVE_LONG_LONG_INT@ && LONG_MAX >> 30 == 1
# define intmax_t long long int
# define uintmax_t unsigned long long int
#elif defined int64_t
# define intmax_t int64_t
# define uintmax_t uint64_t
#else
# define intmax_t long int
#endif
#undef uintmax_t
#if @HAVE_UNSIGNED_LONG_LONG_INT@ && ULONG_MAX >> 31 == 1
# define uintmax_t unsigned long long int
#elif defined int64_t
# define uintmax_t uint64_t
#else
# define uintmax_t unsigned long int
#endif
......@@ -253,10 +267,13 @@
#undef INT64_MIN
#undef INT64_MAX
#undef UINT64_MAX
#ifdef int64_t
# define INT64_MIN (~ INT64_MAX)
# define INT64_MAX INTMAX_C (9223372036854775807)
#endif
#undef UINT64_MAX
#ifdef uint64_t
# define UINT64_MAX UINTMAX_C (18446744073709551615)
#endif
......@@ -289,10 +306,13 @@
#undef INT_LEAST64_MIN
#undef INT_LEAST64_MAX
#undef UINT_LEAST64_MAX
#ifdef int64_t
# define INT_LEAST64_MIN INT64_MIN
# define INT_LEAST64_MAX INT64_MAX
#endif
#undef UINT_LEAST64_MAX
#ifdef uint64_t
# define UINT_LEAST64_MAX UINT64_MAX
#endif
......@@ -325,10 +345,13 @@
#undef INT_FAST64_MIN
#undef INT_FAST64_MAX
#undef UINT_FAST64_MAX
#ifdef int64_t
# define INT_FAST64_MIN INT64_MIN
# define INT_FAST64_MAX INT64_MAX
#endif
#undef UINT_FAST64_MAX
#ifdef uint64_t
# define UINT_FAST64_MAX UINT64_MAX
#endif
......@@ -345,13 +368,17 @@
#undef INTMAX_MIN
#undef INTMAX_MAX
#undef UINTMAX_MAX
#define INTMAX_MIN (~ INTMAX_MAX)
#ifdef INT64_MAX
# define INTMAX_MAX INT64_MAX
# define UINTMAX_MAX UINT64_MAX
#else
# define INTMAX_MAX INT32_MAX
#endif
#undef UINTMAX_MAX
#ifdef UINT64_MAX
# define UINTMAX_MAX UINT64_MAX
#else
# define UINTMAX_MAX UINT32_MAX
#endif
......@@ -427,27 +454,36 @@
#undef UINT64_C
#if LONG_MAX >> 31 >> 31 == 1
# define INT64_C(x) x##L
# define UINT64_C(x) x##UL
#elif defined _MSC_VER
# define INT64_C(x) x##i64
# define UINT64_C(x) x##ui64
#elif @HAVE_LONG_LONG_INT@
# define INT64_C(x) x##LL
#endif
#if ULONG_MAX >> 31 >> 31 >> 1 == 1
# define UINT64_C(x) x##UL
#elif defined _MSC_VER
# define UINT64_C(x) x##ui64
#elif @HAVE_UNSIGNED_LONG_LONG_INT@
# define UINT64_C(x) x##ULL
#endif
/* 7.18.4.2. Macros for greatest-width integer constants */
#undef INTMAX_C
#undef UINTMAX_C
#if @HAVE_LONG_LONG_INT@ && LONG_MAX >> 30 == 1
# define INTMAX_C(x) x##LL
# define UINTMAX_C(x) x##ULL
#elif defined int64_t
# define INTMAX_C(x) INT64_C(x)
# define UINTMAX_C(x) UINT64_C(x)
#else
# define INTMAX_C(x) x##L
#endif
#undef UINTMAX_C
#if @HAVE_UNSIGNED_LONG_LONG_INT@ && ULONG_MAX >> 31 == 1
# define UINTMAX_C(x) x##ULL
#elif defined uint64_t
# define UINTMAX_C(x) UINT64_C(x)
#else
# define UINTMAX_C(x) x##UL
#endif
......
......@@ -33,7 +33,7 @@
"this configure-time declaration test was not run"
# endif
# if !HAVE_DECL_STRTOULL && HAVE_UNSIGNED_LONG_LONG_INT
unsigned long long strtoull (char const *, char **, int);
unsigned long long int strtoull (char const *, char **, int);
# endif
#else
......@@ -41,33 +41,35 @@ unsigned long long strtoull (char const *, char **, int);
# ifndef HAVE_DECL_STRTOLL
"this configure-time declaration test was not run"
# endif
# if !HAVE_DECL_STRTOLL && HAVE_UNSIGNED_LONG_LONG_INT
long long strtoll (char const *, char **, int);
# if !HAVE_DECL_STRTOLL && HAVE_LONG_LONG_INT
long long int strtoll (char const *, char **, int);
# endif
#endif
#ifdef UNSIGNED
# undef HAVE_LONG_LONG_INT
# define HAVE_LONG_LONG_INT HAVE_UNSIGNED_LONG_LONG_INT
# define INT uintmax_t
# define Have_long_long HAVE_UNSIGNED_LONG_LONG_INT
# define Int uintmax_t
# define Unsigned unsigned
# define strtoimax strtoumax
# define strtol strtoul
# define strtoll strtoull
#else
# define INT intmax_t
# define Have_long_long HAVE_LONG_LONG_INT
# define Int intmax_t
# define Unsigned
#endif
INT
Int
strtoimax (char const *ptr, char **endptr, int base)
{
#if HAVE_LONG_LONG_INT
verify (sizeof (INT) == sizeof (long int)
|| sizeof (INT) == sizeof (long long int));
#if Have_long_long
verify (sizeof (Int) == sizeof (Unsigned long int)
|| sizeof (Int) == sizeof (Unsigned long long int));
if (sizeof (INT) != sizeof (long int))
if (sizeof (Int) != sizeof (Unsigned long int))
return strtoll (ptr, endptr, base);
#else
verify (sizeof (INT) == sizeof (long int));
verify (sizeof (Int) == sizeof (Unsigned long int));
#endif
return strtol (ptr, endptr, base);
......
# stdint.m4 serial 18
# stdint.m4 serial 19
dnl Copyright (C) 2001-2002, 2004-2006 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
......@@ -11,7 +11,7 @@ AC_DEFUN([gl_STDINT_H],
[
AC_PREREQ(2.59)dnl
dnl Check for long long int.
dnl Check for long long int and unsigned long long int.
AC_REQUIRE([AC_TYPE_LONG_LONG_INT])
if test $ac_cv_type_long_long_int = yes; then
HAVE_LONG_LONG_INT=1
......@@ -19,6 +19,13 @@ AC_DEFUN([gl_STDINT_H],
HAVE_LONG_LONG_INT=0
fi
AC_SUBST([HAVE_LONG_LONG_INT])
AC_REQUIRE([AC_TYPE_UNSIGNED_LONG_LONG_INT])
if test $ac_cv_type_unsigned_long_long_int = yes; then
HAVE_UNSIGNED_LONG_LONG_INT=1
else
HAVE_UNSIGNED_LONG_LONG_INT=0
fi
AC_SUBST([HAVE_UNSIGNED_LONG_LONG_INT])
dnl Check for <wchar.h>.
AC_CHECK_HEADERS_ONCE([wchar.h])
......
......@@ -26,6 +26,7 @@ inttypes.h: inttypes_.h
-e 's|@''ABSOLUTE_INTTYPES_H''@|$(ABSOLUTE_INTTYPES_H)|g' \
-e 's/@''PRI_MACROS_BROKEN''@/$(PRI_MACROS_BROKEN)/g' \
-e 's/@''HAVE_LONG_LONG_INT''@/$(HAVE_LONG_LONG_INT)/g' \
-e 's/@''HAVE_UNSIGNED_LONG_LONG_INT''@/$(HAVE_UNSIGNED_LONG_LONG_INT)/g' \
-e 's/@''PRIPTR_PREFIX''@/$(PRIPTR_PREFIX)/g' \
-e 's/@''HAVE_DECL_IMAXABS''@/$(HAVE_DECL_IMAXABS)/g' \
-e 's/@''HAVE_DECL_IMAXDIV''@/$(HAVE_DECL_IMAXDIV)/g' \
......
......@@ -11,6 +11,7 @@ lib/stdint_.h
m4/stdint.m4
m4/absolute-header.m4
m4/longlong.m4
m4/ulonglong.m4
Depends-on:
......@@ -34,6 +35,7 @@ stdint.h: stdint_.h
-e 's/@''HAVE_SYS_INTTYPES_H''@/$(HAVE_SYS_INTTYPES_H)/g' \
-e 's/@''HAVE_SYS_BITYPES_H''@/$(HAVE_SYS_BITYPES_H)/g' \
-e 's/@''HAVE_LONG_LONG_INT''@/$(HAVE_LONG_LONG_INT)/g' \
-e 's/@''HAVE_UNSIGNED_LONG_LONG_INT''@/$(HAVE_UNSIGNED_LONG_LONG_INT)/g' \
-e 's/@''BITSIZEOF_PTRDIFF_T''@/$(BITSIZEOF_PTRDIFF_T)/g' \
-e 's/@''PTRDIFF_T_SUFFIX''@/$(PTRDIFF_T_SUFFIX)/g' \
-e 's/@''BITSIZEOF_SIG_ATOMIC_T''@/$(BITSIZEOF_SIG_ATOMIC_T)/g' \
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment