From b699d5c6a93dba96658803432f2adf30467d1bcf Mon Sep 17 00:00:00 2001 From: OBATA Akio Date: Sun, 27 Dec 2015 15:54:20 +0900 Subject: [PATCH] Ensure to declare UINTMAX_MAX, INTMAX_MAX and INTMAX_MIN --- CMakeLists.txt | 3 +++ build/cmake/config.h.in | 14 ++++++++++++-- configure.ac | 1 + libarchive/archive_platform.h | 9 +++++++++ 4 files changed, 25 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5d9e6ee6f..25bceb157 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1281,8 +1281,11 @@ CHECK_SYMBOL_EXISTS(EILSEQ "errno.h" HAVE_EILSEQ) CHECK_SYMBOL_EXISTS(D_MD_ORDER "langinfo.h" HAVE_D_MD_ORDER) CHECK_SYMBOL_EXISTS(INT64_MAX "${headers}" HAVE_DECL_INT64_MAX) CHECK_SYMBOL_EXISTS(INT64_MIN "${headers}" HAVE_DECL_INT64_MIN) +CHECK_SYMBOL_EXISTS(INTMAX_MAX "${headers}" HAVE_DECL_INTMAX_MAX) +CHECK_SYMBOL_EXISTS(INTMAX_MIN "${headers}" HAVE_DECL_INTMAX_MIN) CHECK_SYMBOL_EXISTS(UINT32_MAX "${headers}" HAVE_DECL_UINT32_MAX) CHECK_SYMBOL_EXISTS(UINT64_MAX "${headers}" HAVE_DECL_UINT64_MAX) +CHECK_SYMBOL_EXISTS(UINTMAX_MAX "${headers}" HAVE_DECL_UINTMAX_MAX) CHECK_SYMBOL_EXISTS(SIZE_MAX "${headers}" HAVE_DECL_SIZE_MAX) CHECK_SYMBOL_EXISTS(SSIZE_MAX "limits.h" HAVE_DECL_SSIZE_MAX) diff --git a/build/cmake/config.h.in b/build/cmake/config.h.in index a42a7c59d..31ecf051a 100644 --- a/build/cmake/config.h.in +++ b/build/cmake/config.h.in @@ -170,8 +170,6 @@ typedef unsigned char uint8_t; /* Define intmax_t and uintmax_t if they are not already defined. */ #if !defined(HAVE_INTMAX_T) typedef int64_t intmax_t; -#define INTMAX_MIN INT64_MIN -#define INTMAX_MAX INT64_MAX #endif #if !defined(HAVE_UINTMAX_T) @@ -372,6 +370,14 @@ typedef uint64_t uintmax_t; don't. */ #cmakedefine HAVE_DECL_INT64_MIN 1 +/* Define to 1 if you have the declaration of `INTMAX_MAX', and to 0 if you + don't. */ +#cmakedefine HAVE_DECL_INTMAX_MAX 1 + +/* Define to 1 if you have the declaration of `INTMAX_MIN', and to 0 if you + don't. */ +#cmakedefine HAVE_DECL_INTMAX_MIN 1 + /* Define to 1 if you have the declaration of `SIZE_MAX', and to 0 if you don't. */ #cmakedefine HAVE_DECL_SIZE_MAX 1 @@ -392,6 +398,10 @@ typedef uint64_t uintmax_t; don't. */ #cmakedefine HAVE_DECL_UINT64_MAX 1 +/* Define to 1 if you have the declaration of `UINTMAX_MAX', and to 0 if you + don't. */ +#cmakedefine HAVE_DECL_UINTMAX_MAX 1 + /* Define to 1 if you have the header file. */ #cmakedefine HAVE_DIRECT_H 1 diff --git a/configure.ac b/configure.ac index ea2c5d77a..7a9cb9fec 100644 --- a/configure.ac +++ b/configure.ac @@ -537,6 +537,7 @@ AC_TYPE_UINT16_T AC_TYPE_UINT8_T AC_CHECK_DECLS([SIZE_MAX, INT64_MAX, INT64_MIN, UINT64_MAX, UINT32_MAX]) +AC_CHECK_DECLS([INTMAX_MAX, INTMAX_MIN, UINTMAX_MAX]) AC_CHECK_DECL([SSIZE_MAX], [AC_DEFINE(HAVE_DECL_SSIZE_MAX, 1, [Define to 1 if you have the declaration of `SSIZE_MAX', and to 0 if you don't.])], diff --git a/libarchive/archive_platform.h b/libarchive/archive_platform.h index faeb5efcb..64595aec6 100644 --- a/libarchive/archive_platform.h +++ b/libarchive/archive_platform.h @@ -126,6 +126,15 @@ #if !HAVE_DECL_INT64_MIN #define INT64_MIN ((int64_t)(~INT64_MAX)) #endif +#if !HAVE_DECL_UINTMAX_MAX +#define UINTMAX_MAX (~(uintmax_t)0) +#endif +#if !HAVE_DECL_INTMAX_MAX +#define INTMAX_MAX ((intmax_t)(UINTMAX_MAX >> 1)) +#endif +#if !HAVE_DECL_INTMAX_MIN +#define INTMAX_MIN ((intmax_t)(~INTMAX_MAX)) +#endif /* * If this platform has , acl_create(), acl_init(), -- 2.47.2