LinuxTV Patchwork Fix building against musl C library

login
register
mail settings
Submitter glenvt18
Date Jan. 31, 2017, 3:20 p.m.
Message ID <1485876044-17422-1-git-send-email-glenvt18@gmail.com>
Download mbox | patch
Permalink /patch/39131/
State New
Headers show

Comments

glenvt18 - Jan. 31, 2017, 3:20 p.m.
This was tested with Alpine Linux 3.5/musl-1.1.15/gcc-6.2.1/vdr-2.3.2.
While building for Alpine, add -lintl to LIBS:

    echo 'LIBS += -lintl' >> Make.config

Some notes:

 1. __attribute__((__format_arg__(n))) is supported since gcc-2.8 (1998).

 2. freopen() can be reworked to work with musl if it really matters.

 3. Musl doesn't define __MUSL__ or whatever. Checking __GLIBC__ is
    definitely not perfect, but VDR build system can't run tests for the
    moment.

---
 i18n.h   |  2 +-
 osd.c    |  2 +-
 thread.c |  4 +++-
 tools.c  |  2 +-
 tools.h  | 12 +++++++++++-
 vdr.c    |  6 ++++++
 6 files changed, 23 insertions(+), 5 deletions(-)
Jouni Karvo - Feb. 19, 2017, 5:37 p.m.
hi,

I just upgraded my RPI raspbian packages, running vdr 2.2.0 and 
vdr-plugin-rpihddevice (latest git).  I did not upgrade the actual VDR 
and its plugins.

For some reason, now MPEG2-encoded channels are not shown properly any 
more; the video is just noise, mostly green, some purple.  Audio is 
fine, subtitling is fine.  It does not matter whether it is a live 
channel or a recording.  The license is still OK (enabled). H264 encoded 
channels are shown properly.  Using kodi on the server side vdr works 
properly (i.e. not on rpi, but on a full-size pc), the problem seems to 
be on the rpi side.

Has anyone seen such thing?  I wonder if I should try to reinstall some 
package/library (which one)?

yours,
         Jouni

Patch

diff --git a/i18n.h b/i18n.h
index f8ad9de..b002bbf 100644
--- 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
index 524700a..ef975f5 100644
--- 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
index 47eb977..58dba43 100644
--- a/thread.c
+++ b/thread.c
@@ -155,7 +155,9 @@  cRwLock::cRwLock(bool PreferWriter)
   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);
 }
 
@@ -205,7 +207,7 @@  cMutex::cMutex(void)
   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
index 754673d..fef9d2d 100644
--- a/tools.c
+++ b/tools.c
@@ -640,7 +640,7 @@  char *ReadLink(const char *FileName)
 {
   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);
diff --git a/tools.h b/tools.h
index 73cca5a..03f5fd1 100644
--- 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;
@@ -738,7 +748,7 @@  public:
         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
index 8a49471..c2a82aa 100644
--- a/vdr.c
+++ b/vdr.c
@@ -670,12 +670,18 @@  int main(int argc, char *argv[])
         }
      }
   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
      }
 
   isyslog("VDR version %s started", VDRVERSION);

Privacy Policy