From e2c0f60c10119d10f03701752f568f1df731e85e Mon Sep 17 00:00:00 2001 From: Yang Yu Date: Mon, 16 Sep 2019 11:16:56 +0200 Subject: [PATCH] build: fix build error with __ANDROID_API__ < 21 Fix the following undefined symbols error with __ANDROID_API__ < 21: - epoll_create1 - epoll_pwait - futimens --- src/unix/fs.c | 4 ++++ src/unix/linux-core.c | 10 ++++++++++ 2 files changed, 14 insertions(+) diff --git a/src/unix/fs.c b/src/unix/fs.c index fd3dd4c2..0f68a400 100644 --- a/src/unix/fs.c +++ b/src/unix/fs.c @@ -216,7 +216,11 @@ static ssize_t uv__fs_futime(uv_fs_t* req) { ts[0].tv_nsec = (uint64_t)(req->atime * 1000000) % 1000000 * 1000; ts[1].tv_sec = req->mtime; ts[1].tv_nsec = (uint64_t)(req->mtime * 1000000) % 1000000 * 1000; +#if defined(__ANDROID_API__) && __ANDROID_API__ < 21 + return utimensat(req->file, NULL, ts, 0); +#else return futimens(req->file, ts); +#endif #elif defined(__APPLE__) \ || defined(__DragonFly__) \ || defined(__FreeBSD__) \ diff --git a/src/unix/linux-core.c b/src/unix/linux-core.c index 436a8a95..a155a374 100644 --- a/src/unix/linux-core.c +++ b/src/unix/linux-core.c @@ -90,7 +90,12 @@ int uv__platform_loop_init(uv_loop_t* loop) { * a.k.a. Lollipop. Since EPOLL_CLOEXEC is an alias for O_CLOEXEC on all * architectures, we just use that instead. */ +#if defined(__ANDROID_API__) && __ANDROID_API__ < 21 + fd = -1; + errno = ENOSYS; +#else fd = epoll_create1(O_CLOEXEC); +#endif /* epoll_create1() can fail either because it's not implemented (old kernel) * or because it doesn't understand the O_CLOEXEC flag. @@ -288,11 +293,16 @@ void uv__io_poll(uv_loop_t* loop, int timeout) { abort(); if (no_epoll_wait != 0 || (sigmask != 0 && no_epoll_pwait == 0)) { +#if defined(__ANDROID_API__) && __ANDROID_API__ < 21 + nfds = -1; + errno = ENOSYS; +#else nfds = epoll_pwait(loop->backend_fd, events, ARRAY_SIZE(events), timeout, &sigset); +#endif if (nfds == -1 && errno == ENOSYS) no_epoll_pwait = 1; } else {