]> www.infradead.org Git - mtd-utils.git/commitdiff
common: Fix PRI{x,d}off definitions for x86_64 platform
authorBoris Brezillon <boris.brezillon@free-electrons.com>
Fri, 25 Nov 2016 17:30:40 +0000 (18:30 +0100)
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>
Tue, 6 Dec 2016 18:37:45 +0000 (19:37 +0100)
Compiling for x86_64 generates a lot of warning because the PRIxoff_t and
PRIdoff_t are not properly defined, which comes from the missing
SIZEOF_LONG definition.

Use the autotools to generate a config.h header, include this header from
common.h and ask autoheader to generate the SIZEOF_LONG and SIZEOF_LOFF_T
definitions.
Use these new definitions to assign the proper descriptors to PRIxoff_t
and PRIdoff_t.

Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
.gitignore
configure.ac
include/common.h

index c11a45ee15758dae137c8be6396de2990c0d7975..a5547d5d45788bb5af9dbf4c36380a872fba3e77 100644 (file)
@@ -124,6 +124,9 @@ tests/ubi-tests/ubi-stress-test.sh
 /missing
 /stamp-h?
 /compile
+/include/config.h
+/include/config.h.in
+/include/stamp-h1
 
 #
 # Top-level generic files
index 2fdf49c9276d0cc082e3ff89f2a7a30f493c1880..a7839909637d16ba271f90246df2a60f553314e0 100644 (file)
@@ -4,6 +4,7 @@ m4_define([RELEASE], 1.5.2)
 
 AC_INIT([mtd-utils], [RELEASE], [linux-mtd@lists.infradead.org], mtd-utils)
 
+AC_CONFIG_HEADERS([include/config.h])
 
 AC_ARG_ENABLE([unit-tests],
        [AS_HELP_STRING([--enable-unit-tests], [Compile unit test programs])],
@@ -109,4 +110,8 @@ AM_COND_IF([WITHOUT_LZO], [], [
        test "${have_lzo}" != "yes" && AC_MSG_ERROR([lzo missing])
 ])
 
+AC_CHECK_SIZEOF([long])
+
+AC_CHECK_SIZEOF([loff_t])
+
 AC_OUTPUT([Makefile])
index 4f0bb9bb8fb6cbec5fc79b2320ce619b3eb4a4b8..93ef7f347ffb06d498ada0ba57eef886fdb197d6 100644 (file)
@@ -30,6 +30,8 @@
 #include <inttypes.h>
 #include <sys/sysmacros.h>
 
+#include "config.h"
+
 #ifndef PROGRAM_NAME
 # error "You must define PROGRAM_NAME before including this header"
 #endif
@@ -71,7 +73,7 @@ extern "C" {
 #define PRIxoff_t PRIx64
 #define PRIdoff_t PRId64
 #else
-#if (SIZEOF_LONG >= 8)
+#if (SIZEOF_LONG == SIZEOF_LOFF_T)
 #define PRIxoff_t "l"PRIx32
 #define PRIdoff_t "l"PRId32
 #else