use portable ucontext on linux/amd64

This commit is contained in:
David du Colombier 2014-08-03 19:12:47 +02:00
parent 58868245a2
commit 726fe05c13
3 changed files with 34 additions and 0 deletions

6
asm.S
View File

@ -28,6 +28,12 @@
#endif #endif
#endif #endif
#if defined(__linux__) && defined(__amd64__)
#define NEEDAMD64CONTEXT 1
#define SET setmcontext
#define GET getmcontext
#endif
#if defined(__linux__) && defined(__arm__) #if defined(__linux__) && defined(__arm__)
#define NEEDARMCONTEXT 1 #define NEEDARMCONTEXT 1
#define SET setmcontext #define SET setmcontext

View File

@ -25,6 +25,11 @@
#define NEEDSWAPCONTEXT #define NEEDSWAPCONTEXT
#endif #endif
#if defined(__linux__) && defined(__amd64__)
#define NEEDSWAPCONTEXT
#define NEEDAMD64MAKECONTEXT
#endif
#if defined(__linux__) && defined(__arm__) #if defined(__linux__) && defined(__arm__)
#define NEEDSWAPCONTEXT #define NEEDSWAPCONTEXT
#define NEEDARMMAKECONTEXT #define NEEDARMMAKECONTEXT

View File

@ -18,6 +18,13 @@
#define USE_UCONTEXT 0 #define USE_UCONTEXT 0
#endif #endif
#if defined(__linux__) && defined(__amd64__)
#define _UCONTEXT_H 1
#define _SYS_UCONTEXT_H 1
#undef USE_UCONTEXT
#define USE_UCONTEXT 0
#endif
#if defined(__APPLE__) #if defined(__APPLE__)
#include <AvailabilityMacros.h> #include <AvailabilityMacros.h>
#if defined(MAC_OS_X_VERSION_10_5) #if defined(MAC_OS_X_VERSION_10_5)
@ -97,6 +104,22 @@ extern int swapcontext(ucontext_t*, const ucontext_t*);
extern void makecontext(ucontext_t*, void(*)(), int, ...); extern void makecontext(ucontext_t*, void(*)(), int, ...);
#endif #endif
#if defined(__linux__) && defined(__amd64__)
typedef struct mcontext mcontext_t;
typedef struct ucontext ucontext_t;
extern int getmcontext(mcontext_t*);
extern void setmcontext(const mcontext_t*);
#define setcontext(u) setmcontext(&(u)->uc_mcontext)
#define getcontext(u) getmcontext(&(u)->uc_mcontext)
extern int swapcontext(ucontext_t*, const ucontext_t*);
extern void makecontext(ucontext_t*, void(*)(), int, ...);
# if defined(__i386__)
# include "386-ucontext.h"
# elif defined(__x86_64__)
# include "amd64-ucontext.h"
# endif
#endif
#if defined(__APPLE__) #if defined(__APPLE__)
# define mcontext libthread_mcontext # define mcontext libthread_mcontext
# define mcontext_t libthread_mcontext_t # define mcontext_t libthread_mcontext_t