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  #endif
52  #ifdef _ARCH_PPC
53  #define LIBCONTEXT_PLATFORM_linux_ppc32
54  #define LIBCONTEXT_CALL_CONVENTION
55  #endif
56  #endif
57 
58  #elif defined(__MINGW32__) || defined(__MINGW64__)
59  #if defined(__x86_64__)
60  #define LIBCONTEXT_COMPILER_gcc
61  #define LIBCONTEXT_PLATFORM_windows_x86_64
62  #define LIBCONTEXT_CALL_CONVENTION
63  #endif
64 
65  #if defined(__i386__)
66  #define LIBCONTEXT_COMPILER_gcc
67  #define LIBCONTEXT_PLATFORM_windows_i386
68  #define LIBCONTEXT_CALL_CONVENTION __cdecl
69  #endif
70  #elif defined(__APPLE__) && defined(__MACH__)
71  #if defined(__i386__)
72  #define LIBCONTEXT_PLATFORM_apple_i386
73  #define LIBCONTEXT_CALL_CONVENTION
74  #elif defined(__x86_64__)
75  #define LIBCONTEXT_PLATFORM_apple_x86_64
76  #define LIBCONTEXT_CALL_CONVENTION
77  #endif
78  #endif
79 #elif defined (_MSC_VER)
80 
81 #define LIBCONTEXT_HAS_OWN_STACK
82 
83 #define LIBCONTEXT_CALL_CONVENTION __cdecl
84 
85 #if defined(_WIN64)
86  #define LIBCONTEXT_PLATFORM_msvc_x86_64
87 #elif defined(_WIN32)
88  #define LIBCONTEXT_PLATFORM_msvc_i386
89 #endif
90 #endif
91 
92 #ifdef __cplusplus
93 namespace libcontext {
94 #endif
95 
96 #if defined(_WIN32_WCE)
97 typedef int intptr_t;
98 #endif
99 
100 typedef void* fcontext_t;
101 
102 #ifdef __cplusplus
103 extern "C" {
104 #endif
105 
106 
107 intptr_t LIBCONTEXT_CALL_CONVENTION jump_fcontext( fcontext_t* ofc, fcontext_t nfc,
108  intptr_t vp, bool preserve_fpu = true );
109 fcontext_t LIBCONTEXT_CALL_CONVENTION make_fcontext( void* sp, size_t size,
110  void (* fn)( intptr_t ) );
111 
112 #ifdef __cplusplus
113 } // namespace
114 #endif
115 
116 #ifdef __cplusplus
117 } // extern "C"
118 #endif
119 
120 #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:100
fcontext_t LIBCONTEXT_CALL_CONVENTION make_fcontext(void *sp, size_t size, void(*fn)(intptr_t))