uwsgi: Use libandroid-sysv-semaphore

This commit is contained in:
Tee KOBAYASHI 2022-03-28 08:00:01 +09:00 committed by xtkoba
parent 2c329c8bfd
commit 9a3c44f747
4 changed files with 19 additions and 101 deletions

View File

@ -3,19 +3,29 @@ TERMUX_PKG_DESCRIPTION="uWSGI application server container"
TERMUX_PKG_LICENSE="GPL-2.0"
TERMUX_PKG_MAINTAINER="@termux"
TERMUX_PKG_VERSION=2.0.19.1
TERMUX_PKG_REVISION=4
TERMUX_PKG_REVISION=5
TERMUX_PKG_SRCURL=https://github.com/unbit/uwsgi/archive/${TERMUX_PKG_VERSION}.tar.gz
TERMUX_PKG_SHA256=bf17cdbb9bd8bcb7c1633e34d9d7308cb4cc19eb0ff2d61057f840c1ba1fc41b
TERMUX_PKG_DEPENDS="libandroid-glob, libcap, libcrypt, libjansson, libuuid, libxml2, openssl, pcre, python"
TERMUX_PKG_DEPENDS="libandroid-glob, libandroid-sysv-semaphore, libcap, libcrypt, libjansson, libuuid, libxml2, openssl, pcre, python"
TERMUX_PKG_BUILD_IN_SRC=true
termux_step_configure() {
cp $TERMUX_PKG_BUILDER_DIR/sys_sem.c $TERMUX_PKG_SRCDIR/core/
cp $TERMUX_PKG_BUILDER_DIR/sys_time.c $TERMUX_PKG_SRCDIR/core/
termux_step_post_get_source() {
cp $TERMUX_PKG_BUILDER_DIR/sys_time.c ./core/
}
termux_step_pre_configure() {
_PYTHON_VERSION=$(. $TERMUX_SCRIPTDIR/packages/python/build.sh; echo $_MAJOR_VERSION)
export UWSGI_PYTHON_NOLIB=true
export UWSGI_INCLUDES="$TERMUX_PREFIX/include"
export APPEND_CFLAGS="$CPPFLAGS -I$TERMUX_PREFIX/include/python3.10 -DOBSOLETE_LINUX_KERNEL"
LDFLAGS+=" -lpython3.10 -landroid-glob"
export APPEND_CFLAGS="$CPPFLAGS
-I$TERMUX_PREFIX/include/python${_PYTHON_VERSION}
-DOBSOLETE_LINUX_KERNEL
"
LDFLAGS+="
-lpython${_PYTHON_VERSION}
-landroid-glob
-landroid-sysv-semaphore
"
}
termux_step_make_install() {

View File

@ -1,79 +0,0 @@
/*
* Copyright (C) 2016 The Android Open Source Project
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include <linux/sem.h>
#include <stdarg.h>
#include <sys/syscall.h>
#include <unistd.h>
#pragma GCC visibility push(hidden)
int semtimedop(int id, struct sembuf* ops, size_t op_count, const struct timespec* ts) {
#if defined(SYS_semtimedop)
return syscall(SYS_semtimedop, id, ops, op_count, ts);
#else
return syscall(SYS_ipc, SEMTIMEDOP, id, op_count, 0, ops, ts);
#endif
}
union semun {
int val;
struct semid_ds *buf;
unsigned short *array;
} semu;
int semctl(int id, int num, int cmd, ...) {
#if !defined(__LP64__)
// Annoyingly, the kernel requires this for 32-bit but rejects it for 64-bit.
cmd |= IPC_64;
#endif
va_list ap;
va_start(ap, cmd);
union semun arg = va_arg(ap, union semun);
va_end(ap);
#if defined(SYS_semctl)
return syscall(SYS_semctl, id, num, cmd, arg);
#else
return syscall(SYS_ipc, SEMCTL, id, num, cmd, &arg, 0);
#endif
}
int semget(key_t key, int n, int flags) {
#if defined(SYS_semget)
return syscall(SYS_semget, key, n, flags);
#else
return syscall(SYS_ipc, SEMGET, key, n, flags, 0, 0);
#endif
}
int semop(int id, struct sembuf* ops, size_t op_count) {
return semtimedop(id, ops, op_count, NULL);
}
#pragma GCC visibility pop

View File

@ -1,15 +1,6 @@
--- a/uwsgi.h
+++ b/uwsgi.h
@@ -209,7 +209,7 @@
#endif
#include <sys/ipc.h>
-#include <sys/sem.h>
+#include <linux/sem.h>
#include <stdarg.h>
#include <errno.h>
@@ -4967,6 +4967,19 @@
@@ -4967,6 +4967,15 @@
int uwsgi_wait_for_mountpoint(char *);
int uwsgi_wait_for_socket(char *);
@ -20,10 +11,6 @@
+#if __ANDROID_API__ < 26
+int futimes(int, const struct timeval[2]);
+#endif
+#define semid_ds semid64_ds
+int semctl(int, int, int, ...);
+int semget(key_t, int, int);
+int semop(int, struct sembuf *, size_t);
+#endif
+
#ifdef __cplusplus

View File

@ -5,7 +5,7 @@
'core/plugins', 'core/lock', 'core/cache', 'core/daemons', 'core/errors', 'core/hash', 'core/master_events', 'core/chunked',
'core/queue', 'core/event', 'core/signal', 'core/strings', 'core/progress', 'core/timebomb', 'core/ini', 'core/fsmon', 'core/mount',
- 'core/metrics', 'core/plugins_builder', 'core/sharedarea',
+ 'core/metrics', 'core/plugins_builder', 'core/sharedarea', 'core/sys_sem', 'core/sys_time',
+ 'core/metrics', 'core/plugins_builder', 'core/sharedarea', 'core/sys_time',
'core/rpc', 'core/gateway', 'core/loop', 'core/cookie', 'core/querystring', 'core/rb_timers', 'core/transformations', 'core/uwsgi']
# add protocols
self.gcc_list.append('proto/base')