mirror of
https://github.com/0intro/libtask
synced 2024-12-22 11:12:35 +03:00
use portable ucontext on linux/amd64
This commit is contained in:
parent
58868245a2
commit
726fe05c13
6
asm.S
6
asm.S
@ -28,6 +28,12 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(__linux__) && defined(__amd64__)
|
||||
#define NEEDAMD64CONTEXT 1
|
||||
#define SET setmcontext
|
||||
#define GET getmcontext
|
||||
#endif
|
||||
|
||||
#if defined(__linux__) && defined(__arm__)
|
||||
#define NEEDARMCONTEXT 1
|
||||
#define SET setmcontext
|
||||
|
@ -25,6 +25,11 @@
|
||||
#define NEEDSWAPCONTEXT
|
||||
#endif
|
||||
|
||||
#if defined(__linux__) && defined(__amd64__)
|
||||
#define NEEDSWAPCONTEXT
|
||||
#define NEEDAMD64MAKECONTEXT
|
||||
#endif
|
||||
|
||||
#if defined(__linux__) && defined(__arm__)
|
||||
#define NEEDSWAPCONTEXT
|
||||
#define NEEDARMMAKECONTEXT
|
||||
|
23
taskimpl.h
23
taskimpl.h
@ -18,6 +18,13 @@
|
||||
#define USE_UCONTEXT 0
|
||||
#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__)
|
||||
#include <AvailabilityMacros.h>
|
||||
#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, ...);
|
||||
#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__)
|
||||
# define mcontext libthread_mcontext
|
||||
# define mcontext_t libthread_mcontext_t
|
||||
|
Loading…
Reference in New Issue
Block a user