0002-Fix-musl-build.patch 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. From fb44386acc2497ac250364bc08cebc26ded816cf Mon Sep 17 00:00:00 2001
  2. From: Carlo Landmeter <clandmeter@gmail.com>
  3. Date: Tue, 16 May 2023 19:57:39 +0200
  4. Subject: [PATCH] Fix musl build
  5. Downloaded from
  6. https://git.alpinelinux.org/aports/tree/community/vdr/musl-compat.patch
  7. Initial commit:
  8. https://git.alpinelinux.org/aports/commit/?id=140248605cee4a0160f80b47ce77a823be2f740a
  9. Upstream: https://www.linuxtv.org/pipermail/vdr/2023-May/029744.html
  10. Signed-off-by: Bernd Kuhls <bernd.kuhls@t-online.de>
  11. ---
  12. i18n.h | 2 +-
  13. osd.c | 2 +-
  14. thread.c | 4 +++-
  15. tools.c | 4 ++--
  16. tools.h | 14 ++++++++++++--
  17. vdr.c | 6 ++++++
  18. 6 files changed, 25 insertions(+), 7 deletions(-)
  19. diff --git a/i18n.h b/i18n.h
  20. index 03deb6f2..85ce4077 100644
  21. --- a/i18n.h
  22. +++ b/i18n.h
  23. @@ -46,7 +46,7 @@ const cStringList *I18nLanguages(void);
  24. ///< have an actual locale installed. The rest are just dummy entries
  25. ///< to allow having three letter language codes for other languages
  26. ///< that have no actual locale on this system.
  27. -const char *I18nTranslate(const char *s, const char *Plugin = NULL) __attribute_format_arg__(1);
  28. +const char *I18nTranslate(const char *s, const char *Plugin = NULL) __attribute__((__format_arg__ (1)));
  29. ///< Translates the given string (with optional Plugin context) into
  30. ///< the current language. If no translation is available, the original
  31. ///< string will be returned.
  32. diff --git a/osd.c b/osd.c
  33. index 47bda686..0d360c81 100644
  34. --- a/osd.c
  35. +++ b/osd.c
  36. @@ -12,7 +12,7 @@
  37. #include <stdlib.h>
  38. #include <sys/ioctl.h>
  39. #include <sys/stat.h>
  40. -#include <sys/unistd.h>
  41. +#include <unistd.h>
  42. #include "device.h"
  43. #include "tools.h"
  44. diff --git a/thread.c b/thread.c
  45. index 93eb8c0d..6e854541 100644
  46. --- a/thread.c
  47. +++ b/thread.c
  48. @@ -160,7 +160,9 @@ cRwLock::cRwLock(bool PreferWriter)
  49. writeLockThreadId = 0;
  50. pthread_rwlockattr_t attr;
  51. pthread_rwlockattr_init(&attr);
  52. +#if defined(__GLIBC__)
  53. pthread_rwlockattr_setkind_np(&attr, PreferWriter ? PTHREAD_RWLOCK_PREFER_WRITER_NP : PTHREAD_RWLOCK_PREFER_READER_NP);
  54. +#endif
  55. pthread_rwlock_init(&rwlock, &attr);
  56. }
  57. @@ -210,7 +212,7 @@ cMutex::cMutex(void)
  58. locked = 0;
  59. pthread_mutexattr_t attr;
  60. pthread_mutexattr_init(&attr);
  61. - pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_ERRORCHECK_NP);
  62. + pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_ERRORCHECK);
  63. pthread_mutex_init(&mutex, &attr);
  64. }
  65. diff --git a/tools.c b/tools.c
  66. index d04033b1..8b161eec 100644
  67. --- a/tools.c
  68. +++ b/tools.c
  69. @@ -672,7 +672,7 @@ char *ReadLink(const char *FileName)
  70. {
  71. if (!FileName)
  72. return NULL;
  73. - char *TargetName = canonicalize_file_name(FileName);
  74. + char *TargetName = realpath(FileName, NULL);
  75. if (!TargetName) {
  76. if (errno == ENOENT) // file doesn't exist
  77. TargetName = strdup(FileName);
  78. @@ -1562,7 +1562,7 @@ cReadDir::~cReadDir()
  79. struct dirent *cReadDir::Next(void)
  80. {
  81. if (directory) {
  82. -#if !__GLIBC_PREREQ(2, 24) // readdir_r() is deprecated as of GLIBC 2.24
  83. +#if __GLIBC__
  84. while (readdir_r(directory, &u.d, &result) == 0 && result) {
  85. #else
  86. while ((result = readdir(directory)) != NULL) {
  87. diff --git a/tools.h b/tools.h
  88. index ff6169ee..60eda179 100644
  89. --- a/tools.h
  90. +++ b/tools.h
  91. @@ -28,6 +28,16 @@
  92. #include <sys/types.h>
  93. #include "thread.h"
  94. +#ifndef ACCESSPERMS
  95. +# define ACCESSPERMS (S_IRWXU|S_IRWXG|S_IRWXO) /* 0777 */
  96. +#endif
  97. +#ifndef ALLPERMS
  98. +# define ALLPERMS (S_ISUID|S_ISGID|S_ISVTX|S_IRWXU|S_IRWXG|S_IRWXO)/* 07777 */
  99. +#endif
  100. +#ifndef DEFFILEMODE
  101. +# define DEFFILEMODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH)/* 0666*/
  102. +#endif
  103. +
  104. typedef unsigned char uchar;
  105. extern int SysLogLevel;
  106. @@ -444,7 +454,7 @@ class cReadDir {
  107. private:
  108. DIR *directory;
  109. struct dirent *result;
  110. -#if !__GLIBC_PREREQ(2, 24) // readdir_r() is deprecated as of GLIBC 2.24
  111. +#if __GLIBC__
  112. union { // according to "The GNU C Library Reference Manual"
  113. struct dirent d;
  114. char b[offsetof(struct dirent, d_name) + NAME_MAX + 1];
  115. @@ -818,7 +828,7 @@ public:
  116. data[i] = T(0);
  117. size = 0;
  118. }
  119. - void Sort(__compar_fn_t Compare)
  120. + void Sort(int (*Compare)(const void *, const void *))
  121. {
  122. qsort(data, size, sizeof(T), Compare);
  123. }
  124. diff --git a/vdr.c b/vdr.c
  125. index 1bdc51ab..0f426e61 100644
  126. --- a/vdr.c
  127. +++ b/vdr.c
  128. @@ -661,12 +661,18 @@ int main(int argc, char *argv[])
  129. }
  130. }
  131. else if (Terminal) {
  132. +#ifdef __GLIBC__
  133. // Claim new controlling terminal
  134. stdin = freopen(Terminal, "r", stdin);
  135. stdout = freopen(Terminal, "w", stdout);
  136. stderr = freopen(Terminal, "w", stderr);
  137. HasStdin = true;
  138. tcgetattr(STDIN_FILENO, &savedTm);
  139. +#else
  140. + // stdin, stdout, stderr are declared FILE const* by musl C library
  141. + fprintf(stderr, "Option '-t' is only supported if VDR has been built against glibc.\n");
  142. + return 2;
  143. +#endif
  144. }
  145. // Set user id in case we were started as root:
  146. --
  147. 2.39.2