0001-Don-t-redefine-uintptr_t.patch 3.0 KB

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