From: Bruno Haible Date: Mon, 2 Jan 2023 15:57:31 +0000 (+0100) Subject: sigsegv: Fix compilation error on Android 4.3. X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=f430053ec1aa94c3b14a0a5d95bb6f1d31ecbdbf;p=gnulib.git sigsegv: Fix compilation error on Android 4.3. * lib/sigsegv.in.h: For Android, don't include and don't reference ucontext_t. * lib/sigsegv.c (SIGSEGV_FAULT_): For Android, use a plain POSIX fault handler (cf. libsigsegv/src/fault-posix.h). --- diff --git a/ChangeLog b/ChangeLog index 9932cc72a6..015c1d1bb4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2023-01-02 Bruno Haible + + sigsegv: Fix compilation error on Android 4.3. + * lib/sigsegv.in.h: For Android, don't include and don't + reference ucontext_t. + * lib/sigsegv.c (SIGSEGV_FAULT_): For Android, use a plain POSIX fault + handler (cf. libsigsegv/src/fault-posix.h). + 2023-01-01 Paul Eggert dfa: work around Clang 15 bug diff --git a/lib/sigsegv.c b/lib/sigsegv.c index da64d7d0b6..29c452dbe0 100644 --- a/lib/sigsegv.c +++ b/lib/sigsegv.c @@ -1,5 +1,5 @@ /* Page fault handling library. - Copyright (C) 1993-2022 Free Software Foundation, Inc. + Copyright (C) 1993-2023 Free Software Foundation, Inc. Copyright (C) 2018 Nylon Chen This program is free software: you can redistribute it and/or modify @@ -61,7 +61,7 @@ int libsigsegv_version = LIBSIGSEGV_VERSION; occurred. */ -#if defined __linux__ || defined __ANDROID__ /* Linux */ +#if defined __linux__ && !defined __ANDROID__ /* Linux */ # define SIGSEGV_FAULT_HANDLER_ARGLIST int sig, siginfo_t *sip, void *ucp # define SIGSEGV_FAULT_ADDRESS sip->si_addr @@ -348,6 +348,17 @@ int libsigsegv_version = LIBSIGSEGV_VERSION; #endif +#if defined __ANDROID__ /* Android */ +/* A platform that supports the POSIX:2008 (XPG 7) way, without + 'struct sigcontext' nor 'ucontext_t'. */ + +# define SIGSEGV_FAULT_HANDLER_ARGLIST int sig, siginfo_t *sip, void *context +# define SIGSEGV_FAULT_ADDRESS sip->si_addr +# define SIGSEGV_FAULT_CONTEXT context +# define SIGSEGV_FAULT_ADDRESS_FROM_SIGINFO + +#endif + #if defined __GNU__ /* Hurd */ # define SIGSEGV_FAULT_HANDLER_ARGLIST int sig, int code, struct sigcontext *scp diff --git a/lib/sigsegv.in.h b/lib/sigsegv.in.h index ba30c34a31..40b453e67b 100644 --- a/lib/sigsegv.in.h +++ b/lib/sigsegv.in.h @@ -1,5 +1,5 @@ /* Page fault handling library. - Copyright (C) 1998-2022 Free Software Foundation, Inc. + Copyright (C) 1998-2023 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -23,7 +23,7 @@ #include /* Define the fault context structure. */ -#if defined __linux__ || defined __ANDROID__ \ +#if (defined __linux__ && !defined __ANDROID__) \ || (defined __FreeBSD__ && (defined __arm__ || defined __armhf__ || defined __arm64__)) \ || defined __NetBSD__ \ || defined _AIX || defined __sun \ @@ -180,7 +180,7 @@ extern int sigsegv_leave_handler (void (*continuation) (void*, void*, void*), vo * on some platforms it is a 'struct sigcontext *', on others merely an * opaque 'void *'. */ -# if defined __linux__ || defined __ANDROID__ \ +# if (defined __linux__ && !defined __ANDROID__) \ || (defined __FreeBSD__ && (defined __arm__ || defined __armhf__ || defined __arm64__)) \ || defined __NetBSD__ \ || (defined __APPLE__ && defined __MACH__) \