Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Support Android 5.1
Fix some compilation error when compiling with android-21.
  • Loading branch information
BenEfrati authored and perexg committed Mar 23, 2016
1 parent 0b84f01 commit 05cc17f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 22 deletions.
2 changes: 1 addition & 1 deletion Makefile
Expand Up @@ -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
Expand Down
22 changes: 12 additions & 10 deletions src/compat.h
Expand Up @@ -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 <time64.h>
// 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)
Expand Down
11 changes: 0 additions & 11 deletions src/tvheadend.h
Expand Up @@ -34,17 +34,6 @@
#include <limits.h>
#if ENABLE_LOCKOWNER || ENABLE_ANDROID
#include <sys/syscall.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
#endif
#endif
#include "queue.h"
#include "hts_strtab.h"
Expand Down

0 comments on commit 05cc17f

Please sign in to comment.