| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
#pragma once |
| 22 |
|
| 23 |
#include "config.h" |
| 24 |
|
| 25 |
#include <signal.h> |
| 26 |
#include <stdarg.h> |
| 27 |
#include <string.h> |
| 28 |
#include <unistd.h> |
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
#if defined(__sun__) |
| 38 |
# define __EXTENSIONS__ 1 |
| 39 |
# if defined(__SunOS5_6__) || defined(__SunOS5_7__) || defined(__SunOS5_8__) |
| 40 |
|
| 41 |
# else |
| 42 |
# define __MAKECONTEXT_V2_SOURCE 1 |
| 43 |
# endif |
| 44 |
#endif |
| 45 |
|
| 46 |
#define USE_UCONTEXT 1 |
| 47 |
|
| 48 |
#if defined(__linux__) && defined(__x86_64__) |
| 49 |
# undef USE_UCONTEXT |
| 50 |
# define USE_UCONTEXT 0 |
| 51 |
#endif |
| 52 |
|
| 53 |
#if defined(__OpenBSD__) || defined(__mips__) |
| 54 |
#include <stdint.h> |
| 55 |
# undef USE_UCONTEXT |
| 56 |
# define USE_UCONTEXT 0 |
| 57 |
#endif |
| 58 |
|
| 59 |
#if defined(__APPLE__) |
| 60 |
# ifndef _XOPEN_SOURCE |
| 61 |
# define _XOPEN_SOURCE |
| 62 |
# endif |
| 63 |
#endif |
| 64 |
|
| 65 |
#if USE_UCONTEXT |
| 66 |
# include <ucontext.h> |
| 67 |
#endif |
| 68 |
|
| 69 |
#if defined(__FreeBSD__) && __FreeBSD__ < 5 |
| 70 |
extern int getmcontext(mcontext_t*); |
| 71 |
extern void setmcontext(const mcontext_t*); |
| 72 |
# define setcontext(u) setmcontext(&(u)->uc_mcontext) |
| 73 |
# define getcontext(u) getmcontext(&(u)->uc_mcontext) |
| 74 |
extern int swapcontext(ucontext_t*, const ucontext_t*); |
| 75 |
extern void makecontext(ucontext_t*, void(*)(void), int, ...); |
| 76 |
#endif |
| 77 |
|
| 78 |
#if defined(__OpenBSD__) |
| 79 |
# define mcontext libthread_mcontext |
| 80 |
# define mcontext_t libthread_mcontext_t |
| 81 |
# define ucontext libthread_ucontext |
| 82 |
# define ucontext_t libthread_ucontext_t |
| 83 |
# if defined __amd64__ |
| 84 |
# include "amd64-ucontext.h" |
| 85 |
# elif defined __i386__ |
| 86 |
# include "386-ucontext.h" |
| 87 |
# else |
| 88 |
# include "power-ucontext.h" |
| 89 |
# endif |
| 90 |
#endif |
| 91 |
|
| 92 |
#if defined(__linux__) && defined(__x86_64__) |
| 93 |
# define mcontext libthread_mcontext |
| 94 |
# define mcontext_t libthread_mcontext_t |
| 95 |
# define ucontext libthread_ucontext |
| 96 |
# define ucontext_t libthread_ucontext_t |
| 97 |
# include "amd64-ucontext.h" |
| 98 |
#endif |
| 99 |
|
| 100 |
#if defined(__linux__) && defined(__mips__) |
| 101 |
# if !defined(HAVE_UCONTEXT_H) |
| 102 |
# include "mips-ucontext.h" |
| 103 |
# endif |
| 104 |
extern int getcontext (ucontext_t *ucp); |
| 105 |
extern int setcontext(const ucontext_t *ucp); |
| 106 |
extern int swapcontext(ucontext_t *oucp, const ucontext_t *ucp); |
| 107 |
|
| 108 |
extern void makecontext(ucontext_t *ucp, void(*)(void), int, ...); |
| 109 |
#endif |