2023-05-16 21:48:54 +02:00
|
|
|
From fb44386acc2497ac250364bc08cebc26ded816cf Mon Sep 17 00:00:00 2001
|
|
|
|
From: Carlo Landmeter <clandmeter@gmail.com>
|
|
|
|
Date: Tue, 16 May 2023 19:57:39 +0200
|
|
|
|
Subject: [PATCH] Fix musl build
|
2022-01-01 13:09:20 +01:00
|
|
|
|
|
|
|
Downloaded from
|
|
|
|
https://git.alpinelinux.org/aports/tree/community/vdr/musl-compat.patch
|
|
|
|
|
2023-05-16 21:48:54 +02:00
|
|
|
Initial commit:
|
|
|
|
https://git.alpinelinux.org/aports/commit/?id=140248605cee4a0160f80b47ce77a823be2f740a
|
|
|
|
|
|
|
|
Upstream: https://www.linuxtv.org/pipermail/vdr/2023-May/029744.html
|
|
|
|
|
2022-01-01 13:09:20 +01:00
|
|
|
Signed-off-by: Bernd Kuhls <bernd.kuhls@t-online.de>
|
2023-05-16 21:48:54 +02:00
|
|
|
---
|
|
|
|
i18n.h | 2 +-
|
|
|
|
osd.c | 2 +-
|
|
|
|
thread.c | 4 +++-
|
|
|
|
tools.c | 4 ++--
|
|
|
|
tools.h | 14 ++++++++++++--
|
|
|
|
vdr.c | 6 ++++++
|
|
|
|
6 files changed, 25 insertions(+), 7 deletions(-)
|
2022-01-01 13:09:20 +01:00
|
|
|
|
|
|
|
diff --git a/i18n.h b/i18n.h
|
2023-05-16 21:48:54 +02:00
|
|
|
index 03deb6f2..85ce4077 100644
|
2022-01-01 13:09:20 +01:00
|
|
|
--- a/i18n.h
|
|
|
|
+++ b/i18n.h
|
|
|
|
@@ -46,7 +46,7 @@ const cStringList *I18nLanguages(void);
|
|
|
|
///< have an actual locale installed. The rest are just dummy entries
|
|
|
|
///< to allow having three letter language codes for other languages
|
|
|
|
///< that have no actual locale on this system.
|
|
|
|
-const char *I18nTranslate(const char *s, const char *Plugin = NULL) __attribute_format_arg__(1);
|
|
|
|
+const char *I18nTranslate(const char *s, const char *Plugin = NULL) __attribute__((__format_arg__ (1)));
|
|
|
|
///< Translates the given string (with optional Plugin context) into
|
|
|
|
///< the current language. If no translation is available, the original
|
|
|
|
///< string will be returned.
|
|
|
|
diff --git a/osd.c b/osd.c
|
2023-05-16 21:48:54 +02:00
|
|
|
index 47bda686..0d360c81 100644
|
2022-01-01 13:09:20 +01:00
|
|
|
--- a/osd.c
|
|
|
|
+++ b/osd.c
|
|
|
|
@@ -12,7 +12,7 @@
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <sys/ioctl.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
-#include <sys/unistd.h>
|
|
|
|
+#include <unistd.h>
|
|
|
|
#include "device.h"
|
|
|
|
#include "tools.h"
|
|
|
|
|
|
|
|
diff --git a/thread.c b/thread.c
|
2023-05-16 21:48:54 +02:00
|
|
|
index 93eb8c0d..6e854541 100644
|
2022-01-01 13:09:20 +01:00
|
|
|
--- a/thread.c
|
|
|
|
+++ b/thread.c
|
2023-05-16 21:48:54 +02:00
|
|
|
@@ -160,7 +160,9 @@ cRwLock::cRwLock(bool PreferWriter)
|
2022-01-01 13:09:20 +01:00
|
|
|
writeLockThreadId = 0;
|
|
|
|
pthread_rwlockattr_t attr;
|
|
|
|
pthread_rwlockattr_init(&attr);
|
|
|
|
+#if defined(__GLIBC__)
|
|
|
|
pthread_rwlockattr_setkind_np(&attr, PreferWriter ? PTHREAD_RWLOCK_PREFER_WRITER_NP : PTHREAD_RWLOCK_PREFER_READER_NP);
|
|
|
|
+#endif
|
|
|
|
pthread_rwlock_init(&rwlock, &attr);
|
|
|
|
}
|
|
|
|
|
2023-05-16 21:48:54 +02:00
|
|
|
@@ -210,7 +212,7 @@ cMutex::cMutex(void)
|
2022-01-01 13:09:20 +01:00
|
|
|
locked = 0;
|
|
|
|
pthread_mutexattr_t attr;
|
|
|
|
pthread_mutexattr_init(&attr);
|
|
|
|
- pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_ERRORCHECK_NP);
|
|
|
|
+ pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_ERRORCHECK);
|
|
|
|
pthread_mutex_init(&mutex, &attr);
|
|
|
|
}
|
|
|
|
|
|
|
|
diff --git a/tools.c b/tools.c
|
2023-05-16 21:48:54 +02:00
|
|
|
index d04033b1..8b161eec 100644
|
2022-01-01 13:09:20 +01:00
|
|
|
--- a/tools.c
|
|
|
|
+++ b/tools.c
|
2023-05-16 21:48:54 +02:00
|
|
|
@@ -672,7 +672,7 @@ char *ReadLink(const char *FileName)
|
2022-01-01 13:09:20 +01:00
|
|
|
{
|
|
|
|
if (!FileName)
|
|
|
|
return NULL;
|
|
|
|
- char *TargetName = canonicalize_file_name(FileName);
|
|
|
|
+ char *TargetName = realpath(FileName, NULL);
|
|
|
|
if (!TargetName) {
|
|
|
|
if (errno == ENOENT) // file doesn't exist
|
|
|
|
TargetName = strdup(FileName);
|
2023-05-16 21:48:54 +02:00
|
|
|
@@ -1562,7 +1562,7 @@ cReadDir::~cReadDir()
|
2022-01-01 13:09:20 +01:00
|
|
|
struct dirent *cReadDir::Next(void)
|
|
|
|
{
|
|
|
|
if (directory) {
|
|
|
|
-#if !__GLIBC_PREREQ(2, 24) // readdir_r() is deprecated as of GLIBC 2.24
|
|
|
|
+#if __GLIBC__
|
|
|
|
while (readdir_r(directory, &u.d, &result) == 0 && result) {
|
|
|
|
#else
|
|
|
|
while ((result = readdir(directory)) != NULL) {
|
|
|
|
diff --git a/tools.h b/tools.h
|
2023-05-16 21:48:54 +02:00
|
|
|
index ff6169ee..60eda179 100644
|
2022-01-01 13:09:20 +01:00
|
|
|
--- a/tools.h
|
|
|
|
+++ b/tools.h
|
|
|
|
@@ -28,6 +28,16 @@
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include "thread.h"
|
|
|
|
|
|
|
|
+#ifndef ACCESSPERMS
|
|
|
|
+# define ACCESSPERMS (S_IRWXU|S_IRWXG|S_IRWXO) /* 0777 */
|
|
|
|
+#endif
|
|
|
|
+#ifndef ALLPERMS
|
|
|
|
+# define ALLPERMS (S_ISUID|S_ISGID|S_ISVTX|S_IRWXU|S_IRWXG|S_IRWXO)/* 07777 */
|
|
|
|
+#endif
|
|
|
|
+#ifndef DEFFILEMODE
|
|
|
|
+# define DEFFILEMODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH)/* 0666*/
|
|
|
|
+#endif
|
|
|
|
+
|
|
|
|
typedef unsigned char uchar;
|
|
|
|
|
|
|
|
extern int SysLogLevel;
|
2023-05-16 21:48:54 +02:00
|
|
|
@@ -444,7 +454,7 @@ class cReadDir {
|
2022-01-01 13:09:20 +01:00
|
|
|
private:
|
|
|
|
DIR *directory;
|
|
|
|
struct dirent *result;
|
|
|
|
-#if !__GLIBC_PREREQ(2, 24) // readdir_r() is deprecated as of GLIBC 2.24
|
|
|
|
+#if __GLIBC__
|
|
|
|
union { // according to "The GNU C Library Reference Manual"
|
|
|
|
struct dirent d;
|
|
|
|
char b[offsetof(struct dirent, d_name) + NAME_MAX + 1];
|
2023-05-16 21:48:54 +02:00
|
|
|
@@ -818,7 +828,7 @@ public:
|
2022-01-01 13:09:20 +01:00
|
|
|
data[i] = T(0);
|
|
|
|
size = 0;
|
|
|
|
}
|
|
|
|
- void Sort(__compar_fn_t Compare)
|
|
|
|
+ void Sort(int (*Compare)(const void *, const void *))
|
|
|
|
{
|
|
|
|
qsort(data, size, sizeof(T), Compare);
|
|
|
|
}
|
|
|
|
diff --git a/vdr.c b/vdr.c
|
2023-05-16 21:48:54 +02:00
|
|
|
index 1bdc51ab..0f426e61 100644
|
2022-01-01 13:09:20 +01:00
|
|
|
--- a/vdr.c
|
|
|
|
+++ b/vdr.c
|
2023-05-16 21:48:54 +02:00
|
|
|
@@ -661,12 +661,18 @@ int main(int argc, char *argv[])
|
2022-01-01 13:09:20 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (Terminal) {
|
|
|
|
+#ifdef __GLIBC__
|
|
|
|
// Claim new controlling terminal
|
|
|
|
stdin = freopen(Terminal, "r", stdin);
|
|
|
|
stdout = freopen(Terminal, "w", stdout);
|
|
|
|
stderr = freopen(Terminal, "w", stderr);
|
|
|
|
HasStdin = true;
|
|
|
|
tcgetattr(STDIN_FILENO, &savedTm);
|
|
|
|
+#else
|
|
|
|
+ // stdin, stdout, stderr are declared FILE const* by musl C library
|
|
|
|
+ fprintf(stderr, "Option '-t' is only supported if VDR has been built against glibc.\n");
|
|
|
|
+ return 2;
|
|
|
|
+#endif
|
|
|
|
}
|
|
|
|
|
2023-05-16 21:48:54 +02:00
|
|
|
// Set user id in case we were started as root:
|
|
|
|
--
|
|
|
|
2.39.2
|
|
|
|
|