-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcontext.h
99 lines (82 loc) · 2.09 KB
/
context.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#ifndef NORLIT_COROUTINE_CONTEXT_H
#define NORLIT_COROUTINE_CONTEXT_H
#include <stdint.h>
#include <stddef.h>
#ifdef __cplusplus
namespace norlit {
namespace coroutine {
extern "C" {
#endif
#define NORLIT_OS_WIN 0
#define NORLIT_OS_NIX 1
#define NORLIT_ARCH_X86 0
#define NORLIT_ARCH_X64 1
#define NORLIT_COMPILER_GCC 0
#define NORLIT_COMPILER_VS 1
#define NORLIT_ABI_CDECL 0
#define NORLIT_ABI_WIN64 1
#define NORLIT_ABI_SYSV 2
#if defined(_WIN32)
# define NORLIT_OS NORLIT_OS_WIN
# if defined(_WIN64)
# define NORLIT_ARCH NORLIT_ARCH_X64
# else
# define NORLIT_ARCH NORLIT_ARCH_X86
# endif
# if defined(__MINGW32__)
# define NORLIT_COMPILER NORLIT_COMPILER_GCC
# else
# define NORLIT_COMPILER NORLIT_COMPILER_VS
# endif
#elif defined(__CYGWIN__)
# define NORLIT_OS NORLIT_OS_WIN
# if defined(__CYGWIN32__)
# define NORLIT_ARCH NORLIT_ARCH_X86
# else
# define NORLIT_ARCH NORLIT_ARCH_X64
# endif
# define NORLIT_COMPILER NORLIT_COMPILER_GCC
#else
# define NORLIT_OS NORLIT_OS_NIX
# if defined(__x86_64__)
# define NORLIT_ARCH NORLIT_ARCH_X64
# else
# define NORLIT_ARCH NORLIT_ARCH_X86
# endif
# define NORLIT_COMPILER NORLIT_COMPILER_GCC
#endif
#if NORLIT_OS == NORLIT_OS_WIN
# define NORLIT_OS_NAME win
#elif NORLIT_OS == NORLIT_OS_NIX
# define NORLIT_OS_NAME nix
#else
# error Unknown OS
#endif
#if NORLIT_ARCH == NORLIT_ARCH_X86
# define NORLIT_ARCH_NAME x86
#elif NORLIT_ARCH == NORLIT_ARCH_X64
# define NORLIT_ARCH_NAME x64
#else
# error Unknown OS
#endif
#if NORLIT_COMPILER == NORLIT_COMPILER_GCC
# define NORLIT_COMPILER_NAME gcc
#elif NORLIT_COMPILER == NORLIT_COMPILER_VS
# define NORLIT_COMPILER_NAME vs
#else
# error Unknown OS
#endif
#define NORLIT_MACRO_STIRNGIFY_N(arg) #arg
#define NORLIT_MACRO_STIRNGIFY(arg) NORLIT_MACRO_STIRNGIFY_N(arg)
#include NORLIT_MACRO_STIRNGIFY(NORLIT_ARCH_NAME/NORLIT_OS_NAME/context.h)
int context_get(context_t*);
void context_set(const context_t*);
void context_swap(context_t* store, const context_t* target);
void context_setstack(context_t* cor, void* ptr, size_t size);
void context_setip(context_t* cor, void(*func)(void));
#ifdef __cplusplus
}
}
}
#endif
#endif