From: Ben Efrati Date: Tue, 22 Mar 2016 09:05:53 +0000 (+0200) Subject: Support Android 5.1 X-Git-Tag: v4.2.1~824 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=05cc17fcd5b540fbc1210a324bf4a6995278a9b6;p=thirdparty%2Ftvheadend.git Support Android 5.1 Fix some compilation error when compiling with android-21. --- diff --git a/Makefile b/Makefile index 1e12a6084..97f7ae9b4 100644 --- a/Makefile +++ b/Makefile @@ -41,7 +41,7 @@ CFLAGS += -fms-extensions -funsigned-char -fno-strict-aliasing CFLAGS += -D_FILE_OFFSET_BITS=64 CFLAGS += -I${BUILDDIR} -I${ROOTDIR}/src -I${ROOTDIR} ifeq ($(CONFIG_ANDROID),yes) -LDFLAGS += -ldl -lm +LDFLAGS += -ldl -lm -fPIE -pie else LDFLAGS += -ldl -lpthread -lm endif diff --git a/src/compat.h b/src/compat.h index 61027de27..34312207b 100644 --- a/src/compat.h +++ b/src/compat.h @@ -19,22 +19,24 @@ #define COMPAT_H #if ENABLE_ANDROID +#ifndef strdupa +#define strdupa(s) \ + ({ \ + const char *__old = (s); \ + size_t __len = strlen(__old) + 1; \ + char *__new = (char *) alloca(__len); \ + (char *) memcpy(__new, __old, __len); \ + }) +#endif +#ifndef index +#define index(...) strchr(__VA_ARGS__) +#endif #define S_IEXEC S_IXUSR #define epoll_create1(EPOLL_CLOEXEC) epoll_create(n) #define inotify_init1(IN_CLOEXEC) inotify_init() #include // 32-bit Android has only timegm64() and not timegm(). // We replicate the behaviour of timegm() when the result overflows time_t. -static inline time_t timegm(struct tm* const t); -time_t timegm(struct tm* const t) { - // time_t is signed on Android. - static const time_t kTimeMax = ~(1L << (sizeof(time_t) * CHAR_BIT - 1)); - static const time_t kTimeMin = (1L << (sizeof(time_t) * CHAR_BIT - 1)); - time64_t result = timegm64(t); - if (result < kTimeMin || result > kTimeMax) - return -1; - return result; -} #define IPTOS_DSCP_MASK 0xfc #define IPTOS_DSCP(x) ((x) & IPTOS_DSCP_MASK) diff --git a/src/tvheadend.h b/src/tvheadend.h index 8c067ed27..1f3747e98 100644 --- a/src/tvheadend.h +++ b/src/tvheadend.h @@ -34,17 +34,6 @@ #include #if ENABLE_LOCKOWNER || ENABLE_ANDROID #include -#if ENABLE_ANDROID -#ifndef strdupa -#define strdupa(s) \ - ({ \ - const char *__old = (s); \ - size_t __len = strlen(__old) + 1; \ - char *__new = (char *) alloca(__len); \ - (char *) memcpy(__new, __old, __len); \ - }) -#endif -#endif #endif #include "queue.h" #include "hts_strtab.h"