0003-Define-_GNU_SOURCE-when-needed.patch 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. From 94c7b765202fe50894425364834beca79e52b255 Mon Sep 17 00:00:00 2001
  2. From: Fabrice Fontaine <fontaine.fabrice@gmail.com>
  3. Date: Mon, 28 Oct 2019 17:09:43 +0100
  4. Subject: [PATCH] Define _GNU_SOURCE when needed
  5. Define _GNU_SOURCE to fix build with musl otherwise we'll got the
  6. following build failures due to localtime_r, strnlen, gmtime_r and
  7. asctime_r being undefined:
  8. os/localtime_s.c:124:12: error: implicit declaration of function 'localtime_r'; did you mean 'localtime_s'? [-Werror=implicit-function-declaration]
  9. dest = localtime_r(timer, dest);
  10. ^~~~~~~~~~~
  11. io/gets_s.c:144:32: error: implicit declaration of function 'strnlen'; did you mean 'strlen'? [-Werror=implicit-function-declaration]
  12. rsize_t len = (rsize_t)strnlen(dest, dmax);
  13. ^~~~~~~
  14. strlen
  15. An other option would be to define AC_GNU_SOURCE in the configure.ac but
  16. it seems that there is some handling of _GNU_SOURCE in
  17. safeclib_private.h
  18. Fixes:
  19. - http://autobuild.buildroot.net/results/31a4b647ec0dcd9f517f313ec6c7c8f56da1ee47
  20. Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
  21. [Retrieved from:
  22. https://github.com/rurban/safeclib/commit/94c7b765202fe50894425364834beca79e52b255]
  23. ---
  24. src/extmem/memzero_s.c | 2 ++
  25. src/io/gets_s.c | 2 ++
  26. src/os/asctime_s.c | 2 ++
  27. src/os/ctime_s.c | 2 ++
  28. src/os/gmtime_s.c | 2 ++
  29. src/os/localtime_s.c | 2 ++
  30. 6 files changed, 12 insertions(+)
  31. diff --git a/src/extmem/memzero_s.c b/src/extmem/memzero_s.c
  32. index 75107215..20cb2784 100644
  33. --- a/src/extmem/memzero_s.c
  34. +++ b/src/extmem/memzero_s.c
  35. @@ -31,6 +31,8 @@
  36. *------------------------------------------------------------------
  37. */
  38. +#define _GNU_SOURCE
  39. +
  40. #ifdef FOR_DOXYGEN
  41. #include "safe_mem_lib.h"
  42. #else
  43. diff --git a/src/io/gets_s.c b/src/io/gets_s.c
  44. index 09350b3d..be875a1c 100644
  45. --- a/src/io/gets_s.c
  46. +++ b/src/io/gets_s.c
  47. @@ -29,6 +29,8 @@
  48. *------------------------------------------------------------------
  49. */
  50. +#define _GNU_SOURCE
  51. +
  52. #ifdef FOR_DOXYGEN
  53. #include "safe_lib.h"
  54. #else
  55. diff --git a/src/os/asctime_s.c b/src/os/asctime_s.c
  56. index 42669844..01cefd8f 100644
  57. --- a/src/os/asctime_s.c
  58. +++ b/src/os/asctime_s.c
  59. @@ -29,6 +29,8 @@
  60. *------------------------------------------------------------------
  61. */
  62. +#define _GNU_SOURCE
  63. +
  64. #ifdef FOR_DOXYGEN
  65. #include "safe_lib.h"
  66. #else
  67. diff --git a/src/os/ctime_s.c b/src/os/ctime_s.c
  68. index 01b31f63..7a1a138c 100644
  69. --- a/src/os/ctime_s.c
  70. +++ b/src/os/ctime_s.c
  71. @@ -29,6 +29,8 @@
  72. *------------------------------------------------------------------
  73. */
  74. +#define _GNU_SOURCE
  75. +
  76. #ifdef FOR_DOXYGEN
  77. #include "safe_lib.h"
  78. #else
  79. diff --git a/src/os/gmtime_s.c b/src/os/gmtime_s.c
  80. index ff9a0e24..cd8f064f 100644
  81. --- a/src/os/gmtime_s.c
  82. +++ b/src/os/gmtime_s.c
  83. @@ -29,6 +29,8 @@
  84. *------------------------------------------------------------------
  85. */
  86. +#define _GNU_SOURCE
  87. +
  88. #ifdef FOR_DOXYGEN
  89. #include "safe_lib.h"
  90. #else
  91. diff --git a/src/os/localtime_s.c b/src/os/localtime_s.c
  92. index 0ce3324b..92ea21b9 100644
  93. --- a/src/os/localtime_s.c
  94. +++ b/src/os/localtime_s.c
  95. @@ -29,6 +29,8 @@
  96. *------------------------------------------------------------------
  97. */
  98. +#define _GNU_SOURCE
  99. +
  100. #ifdef FOR_DOXYGEN
  101. #include "safe_lib.h"
  102. #else