diff --git ports/unix/include/arch/cc.h ports/unix/include/arch/cc.h index 52f508c..d064f50 100644 --- ports/unix/include/arch/cc.h +++ ports/unix/include/arch/cc.h @@ -33,7 +33,7 @@ #define LWIP_ARCH_CC_H /* see https://sourceforge.net/p/predef/wiki/OperatingSystems/ */ -#if defined __linux__ +#if defined __linux__ && !defined __ANDROID__ #define LWIP_UNIX_LINUX #elif defined __APPLE__ #define LWIP_UNIX_MACH @@ -41,6 +41,10 @@ #define LWIP_UNIX_OPENBSD #elif defined __CYGWIN__ #define LWIP_UNIX_CYGWIN +#elif defined __ANDROID__ +#define LWIP_UNIX_ANDROID +/* the next include defines __ANDROID_API__ */ +#include #endif /* Include some files for defining library routines */ @@ -103,6 +107,10 @@ typedef unsigned long mem_ptr_t; #define LWIP_RAND() ((u32_t)rand()) +#if defined(LWIP_UNIX_ANDROID) && defined(FD_SET) + typedef __kernel_fd_set fd_set; +#endif + struct sio_status_s; typedef struct sio_status_s sio_status_t; #define sio_fd_t sio_status_t* diff --git ports/unix/sys_arch.c ports/unix/sys_arch.c index fa773b5..4bb7df8 100644 --- ports/unix/sys_arch.c +++ ports/unix/sys_arch.c @@ -377,7 +377,7 @@ sys_sem_new_internal(u8_t count) if (sem != NULL) { sem->c = count; pthread_condattr_init(&(sem->condattr)); -#ifndef LWIP_UNIX_MACH +#if !(defined(LWIP_UNIX_MACH) || (defined(LWIP_UNIX_ANDROID) && __ANDROID_API__ < 21)) pthread_condattr_setclock(&(sem->condattr), CLOCK_MONOTONIC); #endif pthread_cond_init(&(sem->cond), &(sem->condattr)); @@ -410,7 +410,7 @@ cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex, u32_t timeout) /* Get a timestamp and add the timeout value. */ get_monotonic_time(&rtime1); -#ifdef LWIP_UNIX_MACH +#if defined(LWIP_UNIX_MACH) || (defined(LWIP_UNIX_ANDROID) && __ANDROID_API__ < 21) ts.tv_sec = timeout / 1000L; ts.tv_nsec = (timeout % 1000L) * 1000000L; ret = pthread_cond_timedwait_relative_np(cond, mutex, &ts);