0001-add-includes-defines-for-musl-libc-support.patch 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. From 2efa853ef04c331444c9014af108d17544d5ed1b Mon Sep 17 00:00:00 2001
  2. From: Fabian Groffen <grobian@gentoo.org>
  3. Date: Fri, 21 May 2021 11:25:21 +0200
  4. Subject: [PATCH] add includes/defines for musl libc support
  5. - add some missing includes to get proper definitions for beXXtoh and
  6. PATH_MAX
  7. - guard backtrace() from execinfo.h usage for it is glibc only
  8. Signed-off-by: Fabian Groffen <grobian@gentoo.org>
  9. Reviewed-by: Nathan Lynch <nathanl@linux.ibm.com>
  10. Signed-off-by: Tyrel Datwyler <tyreld@linux.ibm.com>
  11. Upstream: c73206b62d6d827cbc37a10f0195b5d2cf3f2fbb
  12. Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
  13. ---
  14. src/common/cpu_info_helpers.c | 1 +
  15. src/drmgr/common.c | 6 ++++++
  16. src/drmgr/dr.h | 1 +
  17. src/rtas_dbg.c | 1 +
  18. 4 files changed, 9 insertions(+)
  19. diff --git a/src/common/cpu_info_helpers.c b/src/common/cpu_info_helpers.c
  20. index 3d08ff7..925f220 100644
  21. --- a/src/common/cpu_info_helpers.c
  22. +++ b/src/common/cpu_info_helpers.c
  23. @@ -29,6 +29,7 @@
  24. #include <errno.h>
  25. #include <stdbool.h>
  26. #include <dirent.h>
  27. +#include <limits.h>
  28. #include <sys/stat.h>
  29. #include <sys/types.h>
  30. #include "cpu_info_helpers.h"
  31. diff --git a/src/drmgr/common.c b/src/drmgr/common.c
  32. index 5e8135b..32cf805 100644
  33. --- a/src/drmgr/common.c
  34. +++ b/src/drmgr/common.c
  35. @@ -28,7 +28,9 @@
  36. #include <signal.h>
  37. #include <errno.h>
  38. #include <dirent.h>
  39. +#ifdef __GLIBC__
  40. #include <execinfo.h>
  41. +#endif
  42. #include <ctype.h>
  43. #include <sys/wait.h>
  44. #include <endian.h>
  45. @@ -853,6 +855,7 @@ sighandler(int signo)
  46. say(ERROR, "Received signal %d, attempting to cleanup and exit\n",
  47. signo);
  48. +#ifdef __GLIBC__
  49. if (log_fd) {
  50. void *callstack[128];
  51. int sz;
  52. @@ -860,6 +863,7 @@ sighandler(int signo)
  53. sz = backtrace(callstack, 128);
  54. backtrace_symbols_fd(callstack, sz, log_fd);
  55. }
  56. +#endif
  57. dr_fini();
  58. exit(-1);
  59. @@ -925,8 +929,10 @@ sig_setup(void)
  60. if (sigaction(SIGBUS, &sigact, NULL))
  61. return -1;
  62. +#ifdef __GLIBC__
  63. /* dummy call to backtrace to get symbol loaded */
  64. backtrace(callstack, 128);
  65. +#endif
  66. return 0;
  67. }
  68. diff --git a/src/drmgr/dr.h b/src/drmgr/dr.h
  69. index f171bfe..b32d49a 100644
  70. --- a/src/drmgr/dr.h
  71. +++ b/src/drmgr/dr.h
  72. @@ -26,6 +26,7 @@
  73. #include <nl_types.h>
  74. #include <unistd.h>
  75. #include <stdarg.h>
  76. +#include <limits.h>
  77. #include "rtas_calls.h"
  78. #include "drpci.h"
  79. diff --git a/src/rtas_dbg.c b/src/rtas_dbg.c
  80. index 526e78b..ebc7474 100644
  81. --- a/src/rtas_dbg.c
  82. +++ b/src/rtas_dbg.c
  83. @@ -32,6 +32,7 @@
  84. #include <getopt.h>
  85. #include <dirent.h>
  86. #include <string.h>
  87. +#include <endian.h>
  88. #include <sys/syscall.h>
  89. #include <unistd.h>
  90. #include <linux/unistd.h>
  91. --
  92. 2.37.1