From ba9f2c3ae2969cba8ac9b2ced5ea87ad95694a6c Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Mon, 23 Jan 2017 00:32:51 +0900 Subject: [PATCH] Compile with Android NDK r13b using clang --- android-config | 5 +++-- src/shrpx.cc | 14 +++++++------- src/shrpx.h | 12 +++++++----- src/shrpx_exec.cc | 6 +++--- src/shrpx_worker_process.cc | 4 ++-- 5 files changed, 22 insertions(+), 19 deletions(-) diff --git a/android-config b/android-config index af259636..cc369a67 100755 --- a/android-config +++ b/android-config @@ -39,8 +39,9 @@ PATH="$TOOLCHAIN"/bin:"$PATH" --without-libxml2 \ --disable-python-bindings \ --disable-examples \ - CC="$TOOLCHAIN"/bin/arm-linux-androideabi-gcc \ - CXX="$TOOLCHAIN"/bin/arm-linux-androideabi-g++ \ + --disable-threads \ + CC="$TOOLCHAIN"/bin/arm-linux-androideabi-clang \ + CXX="$TOOLCHAIN"/bin/arm-linux-androideabi-clang++ \ CPPFLAGS="-fPIE -I$PREFIX/include" \ PKG_CONFIG_LIBDIR="$PREFIX/lib/pkgconfig" \ LDFLAGS="-fPIE -pie -L$PREFIX/lib" diff --git a/src/shrpx.cc b/src/shrpx.cc index caa4fb2c..b636cba4 100644 --- a/src/shrpx.cc +++ b/src/shrpx.cc @@ -411,7 +411,7 @@ void exec_binary() { LOG(ERROR) << "Unblocking all signals failed: " << xsi_strerror(error, errbuf.data(), errbuf.size()); - _Exit(EXIT_FAILURE); + nghttp2_Exit(EXIT_FAILURE); } auto exec_path = @@ -419,7 +419,7 @@ void exec_binary() { if (!exec_path) { LOG(ERROR) << "Could not resolve the executable path"; - _Exit(EXIT_FAILURE); + nghttp2_Exit(EXIT_FAILURE); } auto argv = make_unique(suconfig.argc + 1); @@ -492,7 +492,7 @@ void exec_binary() { if (execve(argv[0], argv.get(), envp.get()) == -1) { auto error = errno; LOG(ERROR) << "execve failed: errno=" << error; - _Exit(EXIT_FAILURE); + nghttp2_Exit(EXIT_FAILURE); } } } // namespace @@ -1170,7 +1170,7 @@ pid_t fork_worker_process(int &main_ipc_fd, LOG(FATAL) << "Unblocking all signals failed: " << xsi_strerror(error, errbuf.data(), errbuf.size()); - _Exit(EXIT_FAILURE); + nghttp2_Exit(EXIT_FAILURE); } close(ipc_fd[1]); @@ -1179,13 +1179,13 @@ pid_t fork_worker_process(int &main_ipc_fd, if (rv != 0) { LOG(FATAL) << "Worker process returned error"; - _Exit(EXIT_FAILURE); + nghttp2_Exit(EXIT_FAILURE); } LOG(NOTICE) << "Worker process shutting down momentarily"; - // call exit(...) instead of _Exit to get leak sanitizer report - _Exit(EXIT_SUCCESS); + // call exit(...) instead of nghttp2_Exit to get leak sanitizer report + nghttp2_Exit(EXIT_SUCCESS); } // parent process diff --git a/src/shrpx.h b/src/shrpx.h index 12e17179..15e66551 100644 --- a/src/shrpx.h +++ b/src/shrpx.h @@ -36,13 +36,15 @@ #include +#ifndef HAVE__EXIT +#define nghttp2_Exit(status) _exit(status) +#else // HAVE__EXIT +#define nghttp2_Exit(status) _Exit(status) +#endif // HAVE__EXIT + #include "shrpx_log.h" -#ifndef HAVE__EXIT -#define _Exit(status) _exit(status) -#endif // !HAVE__EXIT - -#define DIE() _Exit(EXIT_FAILURE) +#define DIE() nghttp2_Exit(EXIT_FAILURE) #if defined(HAVE_DECL_INITGROUPS) && !HAVE_DECL_INITGROUPS inline int initgroups(const char *user, gid_t group) { return 0; } diff --git a/src/shrpx_exec.cc b/src/shrpx_exec.cc index a59579bf..0ac1d6ea 100644 --- a/src/shrpx_exec.cc +++ b/src/shrpx_exec.cc @@ -83,7 +83,7 @@ int exec_read_command(Process &proc, char *const argv[]) { auto error = errno; LOG(FATAL) << "Unblocking all signals failed: errno=" << error; - _Exit(EXIT_FAILURE); + nghttp2_Exit(EXIT_FAILURE); } dup2(pfd[1], 1); @@ -94,7 +94,7 @@ int exec_read_command(Process &proc, char *const argv[]) { auto error = errno; LOG(ERROR) << "Could not execute command: " << argv[0] << ", execve() faild, errno=" << error; - _Exit(EXIT_FAILURE); + nghttp2_Exit(EXIT_FAILURE); } // unreachable } @@ -111,7 +111,7 @@ int exec_read_command(Process &proc, char *const argv[]) { auto error = errno; LOG(FATAL) << "Restoring all signals failed: errno=" << error; - _Exit(EXIT_FAILURE); + nghttp2_Exit(EXIT_FAILURE); } if (pid == -1) { diff --git a/src/shrpx_worker_process.cc b/src/shrpx_worker_process.cc index aa1239c7..143efec7 100644 --- a/src/shrpx_worker_process.cc +++ b/src/shrpx_worker_process.cc @@ -161,7 +161,7 @@ void ipc_readcb(struct ev_loop *loop, ev_io *w, int revents) { if (nread == 0) { // IPC socket closed. Perform immediate shutdown. LOG(FATAL) << "IPC socket is closed. Perform immediate shutdown."; - _Exit(EXIT_FAILURE); + nghttp2_Exit(EXIT_FAILURE); } for (ssize_t i = 0; i < nread; ++i) { @@ -384,7 +384,7 @@ void nb_child_cb(struct ev_loop *loop, ev_child *w, int revents) { LOG(FATAL) << "neverbleed process exitted; aborting now"; - _Exit(EXIT_FAILURE); + nghttp2_Exit(EXIT_FAILURE); } } // namespace #endif // HAVE_NEVERBLEED