1From 28ce16b29911e5adc60140b572dee177adc7a178 Mon Sep 17 00:00:00 2001 2From: Fabrice Fontaine <fontaine.fabrice@gmail.com> 3Date: Mon, 18 Nov 2019 18:56:46 +0100 4Subject: [PATCH] Don't redefine uintptr_t 5 6Add a call to check_type_size in ConfigureChecks.cmake and use it in 7include/cmocka.h to avoid the following redefinition error on riscv64: 8 9In file included from /data/buildroot/buildroot-test/instance-0/output/build/cmocka-1.1.5/src/cmocka.c:62: 10/data/buildroot/buildroot-test/instance-0/output/build/cmocka-1.1.5/include/cmocka.h:132:28: error: conflicting types for 'uintptr_t' 11 typedef unsigned int uintptr_t; 12 ^~~~~~~~~ 13In file included from /data/buildroot/buildroot-test/instance-0/output/host/riscv64-buildroot-linux-musl/sysroot/usr/include/stdint.h:20, 14 from /data/buildroot/buildroot-test/instance-0/output/host/riscv64-buildroot-linux-musl/sysroot/usr/include/inttypes.h:9, 15 from /data/buildroot/buildroot-test/instance-0/output/build/cmocka-1.1.5/src/cmocka.c:27: 16/data/buildroot/buildroot-test/instance-0/output/host/riscv64-buildroot-linux-musl/sysroot/usr/include/bits/alltypes.h:104:24: note: previous declaration of 'uintptr_t' was here 17 typedef unsigned _Addr uintptr_t; 18 ^~~~~~~~~ 19 20Fixes: 21 - http://autobuild.buildroot.org/results/30922c18150ea62aefe123d1b7cd1444efab963f 22 23Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com> 24Reviewed-by: Andreas Schneider <asn@cryptomilk.org> 25[Retrieved from: 26https://gitlab.com/cmocka/cmocka/commit/28ce16b29911e5adc60140b572dee177adc7a178] 27--- 28 ConfigureChecks.cmake | 3 +++ 29 config.h.cmake | 4 ++++ 30 include/cmocka.h | 2 +- 31 3 files changed, 8 insertions(+), 1 deletion(-) 32 33diff --git a/ConfigureChecks.cmake b/ConfigureChecks.cmake 34index fe8da35..028774f 100644 35--- a/ConfigureChecks.cmake 36+++ b/ConfigureChecks.cmake 37@@ -70,6 +70,9 @@ if (HAVE_TIME_H) 38 check_struct_has_member("struct timespec" tv_sec "time.h" HAVE_STRUCT_TIMESPEC) 39 endif (HAVE_TIME_H) 40 41+# TYPES 42+check_type_size(uintptr_t UINTPTR_T) 43+ 44 # FUNCTIONS 45 check_function_exists(calloc HAVE_CALLOC) 46 check_function_exists(exit HAVE_EXIT) 47diff --git a/config.h.cmake b/config.h.cmake 48index f8d79da..55fc69f 100644 49--- a/config.h.cmake 50+++ b/config.h.cmake 51@@ -75,6 +75,10 @@ 52 53 #cmakedefine HAVE_STRUCT_TIMESPEC 1 54 55+/***************************** TYPES *****************************/ 56+ 57+#cmakedefine HAVE_UINTPTR_T 1 58+ 59 /*************************** FUNCTIONS ***************************/ 60 61 /* Define to 1 if you have the `calloc' function. */ 62diff --git a/include/cmocka.h b/include/cmocka.h 63index 3e923dd..0aa557e 100644 64--- a/include/cmocka.h 65+++ b/include/cmocka.h 66@@ -120,7 +120,7 @@ typedef uintmax_t LargestIntegralType; 67 ((LargestIntegralType)(value)) 68 69 /* Smallest integral type capable of holding a pointer. */ 70-#if !defined(_UINTPTR_T) && !defined(_UINTPTR_T_DEFINED) 71+#if !defined(_UINTPTR_T) && !defined(_UINTPTR_T_DEFINED) && !defined(HAVE_UINTPTR_T) 72 # if defined(_WIN32) 73 /* WIN32 is an ILP32 platform */ 74 typedef unsigned int uintptr_t; 75-- 762.22.0 77 78