KiCad PCB EDA Suite
libcontext.h
Go to the documentation of this file.
1 /*
2  *
3  * libcontext - a slightly more portable version of boost::context
4  *
5  * Copyright Martin Husemann 2013.
6  * Copyright Oliver Kowalke 2009.
7  * Copyright Sergue E. Leontiev 2013.
8  * Copyright Thomas Sailer 2013.
9  * Minor modifications by Tomasz Wlostowski 2016.
10  *
11  * Distributed under the Boost Software License, Version 1.0.
12  * (See accompanying file LICENSE_1_0.txt or copy at
13  * http://www.boost.org/LICENSE_1_0.txt)
14  *
15  */
16 
17 #ifndef __LIBCONTEXT_H
18 #define __LIBCONTEXT_H
19 
20 #include <stdint.h>
21 #include <stdio.h>
22 #include <stddef.h>
23 
24 
25 #if defined(__GNUC__) || defined(__APPLE__) || defined(__FreeBSD__)
26 
27  #undef LIBCONTEXT_HAS_OWN_STACK
28 
29  #define LIBCONTEXT_COMPILER_gcc
30 
31  #if defined(__linux__) || defined(__FreeBSD__)
32  #if defined(__x86_64__) || defined(__amd64__)
33  #define LIBCONTEXT_PLATFORM_linux_x86_64
34  #define LIBCONTEXT_CALL_CONVENTION
35  #elif __i386__
36  #define LIBCONTEXT_PLATFORM_linux_i386
37  #define LIBCONTEXT_CALL_CONVENTION
38  #elif __arm__
39  #define LIBCONTEXT_PLATFORM_linux_arm32
40  #define LIBCONTEXT_CALL_CONVENTION
41  #elif __aarch64__
42  #define LIBCONTEXT_PLATFORM_linux_arm64
43  #define LIBCONTEXT_CALL_CONVENTION
44  #elif (__mips__ && _MIPS_SIM == _ABI64)
45  #define LIBCONTEXT_PLATFORM_linux_mips_n64
46  #define LIBCONTEXT_CALL_CONVENTION
47  #elif __powerpc__
48  #ifdef _ARCH_PPC64
49  #define LIBCONTEXT_PLATFORM_linux_ppc64
50  #define LIBCONTEXT_CALL_CONVENTION
51  #elif defined _ARCH_PPC
52  #define LIBCONTEXT_PLATFORM_linux_ppc32
53  #define LIBCONTEXT_CALL_CONVENTION
54  #endif
55  #endif
56 
57  #elif defined(__MINGW32__) || defined(__MINGW64__)
58  #if defined(__x86_64__)
59  #define LIBCONTEXT_COMPILER_gcc
60  #define LIBCONTEXT_PLATFORM_windows_x86_64
61  #define LIBCONTEXT_CALL_CONVENTION
62  #endif
63 
64  #if defined(__i386__)
65  #define LIBCONTEXT_COMPILER_gcc
66  #define LIBCONTEXT_PLATFORM_windows_i386
67  #define LIBCONTEXT_CALL_CONVENTION __cdecl
68  #endif
69  #elif defined(__APPLE__) && defined(__MACH__)
70  #if defined(__i386__)
71  #define LIBCONTEXT_PLATFORM_apple_i386
72  #define LIBCONTEXT_CALL_CONVENTION
73  #elif defined(__x86_64__)
74  #define LIBCONTEXT_PLATFORM_apple_x86_64
75  #define LIBCONTEXT_CALL_CONVENTION
76  #endif
77  #endif
78 #elif defined (_MSC_VER)
79 
80 #define LIBCONTEXT_HAS_OWN_STACK
81 
82 #define LIBCONTEXT_CALL_CONVENTION __cdecl
83 
84 #if defined(_WIN64)
85  #define LIBCONTEXT_PLATFORM_msvc_x86_64
86 #elif defined(_WIN32)
87  #define LIBCONTEXT_PLATFORM_msvc_i386
88 #endif
89 #endif
90 
91 #ifdef __cplusplus
92 namespace libcontext {
93 #endif
94 
95 #if defined(_WIN32_WCE)
96 typedef int intptr_t;
97 #endif
98 
99 typedef void* fcontext_t;
100 
101 #ifdef __cplusplus
102 extern "C" {
103 #endif
104 
105 
106 intptr_t LIBCONTEXT_CALL_CONVENTION jump_fcontext( fcontext_t* ofc, fcontext_t nfc,
107  intptr_t vp, bool preserve_fpu = true );
108 fcontext_t LIBCONTEXT_CALL_CONVENTION make_fcontext( void* sp, size_t size,
109  void (* fn)( intptr_t ) );
110 
111 #ifdef __cplusplus
112 } // namespace
113 #endif
114 
115 #ifdef __cplusplus
116 } // extern "C"
117 #endif
118 
119 #endif
intptr_t LIBCONTEXT_CALL_CONVENTION jump_fcontext(fcontext_t *ofc, fcontext_t nfc, intptr_t vp, bool preserve_fpu=true)
void * fcontext_t
Definition: libcontext.h:99
fcontext_t LIBCONTEXT_CALL_CONVENTION make_fcontext(void *sp, size_t size, void(*fn)(intptr_t))