* sigsegv: Fix compilation error on Android 4.3
@ 2023-01-02 16:03 Bruno Haible
0 siblings, 0 replies; only message in thread
From: Bruno Haible @ 2023-01-02 16:03 UTC (permalink / raw)
To: bug-gnulib
On Android 4.3 (with the 'Terminal IDE' app), I'm seeing a compilation error
in the latest diffutils snapshot:
CC libdiffutils_a-c-stack.o
In file included from ../../lib/c-stack.c:52:
./sigsegv.h:33:23: error: ucontext.h: No such file or directory
And similarly in the latest grep snapshot.
The fix is in Gnulib's sigsegv module.
2023-01-02 Bruno Haible <bruno@clisp.org>
sigsegv: Fix compilation error on Android 4.3.
* lib/sigsegv.in.h: For Android, don't include <ucontext.h> 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/lib/sigsegv.in.h b/lib/sigsegv.in.h
index 097041f1ba..40b453e67b 100644
--- a/lib/sigsegv.in.h
+++ b/lib/sigsegv.in.h
@@ -23,7 +23,7 @@
#include <stddef.h>
/* 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__) \
diff --git a/lib/sigsegv.c b/lib/sigsegv.c
index 14f3a4650b..29c452dbe0 100644
--- a/lib/sigsegv.c
+++ b/lib/sigsegv.c
@@ -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
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2023-01-02 16:04 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-02 16:03 sigsegv: Fix compilation error on Android 4.3 Bruno Haible
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).