summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--configure.ac3
-rw-r--r--libarchive/archive_platform.h22
2 files changed, 25 insertions, 0 deletions
diff --git a/configure.ac b/configure.ac
index cb89c3ee..526f313b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -633,6 +633,9 @@ AC_CHECK_TYPE([wchar_t],
AC_CHECK_SIZEOF([wchar_t])],
[])
+AX_COMPILE_CHECK_SIZEOF(int)
+AX_COMPILE_CHECK_SIZEOF(long)
+
AC_HEADER_TIME
# Checks for library functions.
diff --git a/libarchive/archive_platform.h b/libarchive/archive_platform.h
index 9fef68fa..3426975d 100644
--- a/libarchive/archive_platform.h
+++ b/libarchive/archive_platform.h
@@ -163,6 +163,28 @@
#define INTMAX_MIN ((intmax_t)(~INTMAX_MAX))
#endif
+/* Some platforms lack the standard PRIxN/PRIdN definitions. */
+#if !HAVE_INTTYPES_H || !defined(PRIx32) || !defined(PRId32)
+#ifndef PRIx32
+#if SIZEOF_INT == 4
+#define PRIx32 "x"
+#elif SIZEOF_LONG == 4
+#define PRIx32 "lx"
+#else
+#error No suitable 32-bit unsigned integer type found for this platform
+#endif
+#endif // PRIx32
+#ifndef PRId32
+#if SIZEOF_INT == 4
+#define PRId32 "d"
+#elif SIZEOF_LONG == 4
+#define PRId32 "ld"
+#else
+#error No suitable 32-bit signed integer type found for this platform
+#endif
+#endif // PRId32
+#endif // !HAVE_INTTYPES_H || !defined(PRIx32) || !defined(PRId32)
+
/*
* If we can't restore metadata using a file descriptor, then
* for compatibility's sake, close files before trying to restore metadata.