xroche/coffeecatch

API level 21 / GCC 4.9 support?

Closed this issue · 6 comments

There's a problem building with GCC 4.9 and API 21. __BIONIC_HAVE_UCONTEXT_T is defined there, as well as ucontext structure (but some other structures still aren't defined by the system). I've edited coffeecatch.c and could build it, but of course it doesn't work.

I had a problem building with ndk r10c and this patch helped (looks like it might help you too):

--- a/coffeecatch.c Tue Nov 04 15:55:12 2014 -0800
+++ b/coffeecatch.c Tue Nov 04 16:56:47 2014 -0800
@@ -81,7 +81,7 @@
/* Maximum value of a caught signal. */
#define SIG_NUMBER_MAX 32

-#if (defined(ANDROID) && (!defined(BIONIC_HAVE_UCONTEXT_T)))
+#if defined(__ANDROID
)
#ifndef ucontext_h_seen
#define ucontext_h_seen

@@ -91,7 +91,7 @@
#if defined(arm)

/* Taken from richard.quirk's header file. (Android does not have it) */

+#if !defined(__BIONIC_HAVE_UCONTEXT_T)
typedef struct ucontext {
unsigned long uc_flags;
struct ucontext *uc_link;
@@ -99,6 +99,7 @@
struct sigcontext uc_mcontext;
unsigned long uc_sigmask;
} ucontext_t;
+#endif

#elif defined(i386)

@@ -154,12 +155,14 @@
REG_SS,
};

+#if !defined(__BIONIC_HAVE_UCONTEXT_T)
typedef struct ucontext {
uint32_t uc_flags;
struct ucontext* uc_link;
stack_t uc_stack;
mcontext_t uc_mcontext;
} ucontext_t;
+#endif

#elif defined(mips)

@@ -186,12 +189,14 @@
uint32_t lo3;
} mcontext_t;

+#if !defined(__BIONIC_HAVE_UCONTEXT_T)
typedef struct ucontext {
uint32_t uc_flags;
struct ucontext* uc_link;
stack_t uc_stack;
mcontext_t uc_mcontext;
} ucontext_t;
+#endif

#else
#error "Architecture is not supported (unknown ucontext layout)"
@@ -200,6 +205,7 @@
#endif

#ifdef USE_CORKSCREW
+
typedef struct map_info_t map_info_t;
/* Extracted from Android's include/corkscrew/backtrace.h */
typedef struct {

jonricha your variant fails to compile for x86 arch.
It seems that it's enough to include sys/ucontext.h as it is provided in NDK revision 10c.
The following diff works well for me:
https://gist.github.com/VladislavLipskiy/2a5014cfb48c0600df69

@xroche please fix this, I want to use coffeecatch in https://github.com/mapbox/mapbox-gl-native

In the meantime I will use the above patches.

@jonricha: Sorry it took so long. I have merged your diff in a754993 and it should fir the issues you were having!

Please reopen if there are remaining issues.

Thanks.