Skip to content

Commit

Permalink
Dedupe _GNU_SOURCE and ucontext.h definition and inclusion, put them …
Browse files Browse the repository at this point in the history
…in sane locations.

Change-Id: Ib61db11ec1a00ca675820da8dc916f7ce03e445e
  • Loading branch information
Chris Sarbora authored and hyperb1iss committed Sep 10, 2014
1 parent 5bcfe2b commit b775add
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions libcorkscrew/arch-x86/backtrace-x86.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@

#ifndef __BIONIC__
// glibc has its own renaming of the Linux kernel's structures.
#define _GNU_SOURCE // For REG_EBP, REG_ESP, and REG_EIP.
#include <ucontext.h>
// define this here, so that it's defined before the first inclusion
// of glibc's features.h
# define _GNU_SOURCE // For REG_EBP, REG_ESP, and REG_EIP.
#endif

#define LOG_TAG "Corkscrew"
Expand All @@ -44,14 +45,14 @@

#if defined(__BIONIC__)

#if defined(__BIONIC_HAVE_UCONTEXT_T)
# if defined(__BIONIC_HAVE_UCONTEXT_T)

// Bionic offers the Linux kernel headers.
#include <asm/sigcontext.h>
#include <asm/ucontext.h>
# include <asm/sigcontext.h>
# include <asm/ucontext.h>
typedef struct ucontext ucontext_t;

#else /* __BIONIC_HAVE_UCONTEXT_T */
# else /* __BIONIC_HAVE_UCONTEXT_T */

/* Old versions of the Android <signal.h> didn't define ucontext_t. */

Expand Down Expand Up @@ -79,18 +80,17 @@ typedef struct ucontext {
uint32_t uc_sigmask;
} ucontext_t;

#endif /* __BIONIC_HAVE_UCONTEXT_T */
# endif /* __BIONIC_HAVE_UCONTEXT_T */

#elif defined(__APPLE__)
#elif defined(__APPLE__) /* ! __BIONIC__ */

#define _XOPEN_SOURCE
#include <ucontext.h>
# define _XOPEN_SOURCE
# include <ucontext.h>

#else
#else /* ! __BIONIC__ && ! __APPLE__ */

// glibc has its own renaming of the Linux kernel's structures.
#define _GNU_SOURCE // For REG_EBP, REG_ESP, and REG_EIP.
#include <ucontext.h>
/* _GNU_SOURCE is already defined above */
# include <ucontext.h>

#endif

Expand Down

0 comments on commit b775add

Please sign in to comment.