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  #define LIBCONTEXT_COMPILER_gcc
28 
29  #if defined(__linux__) || defined(__FreeBSD__)
30  #if defined(__x86_64__) || defined(__amd64__)
31  #define LIBCONTEXT_PLATFORM_linux_x86_64
32  #define LIBCONTEXT_CALL_CONVENTION
33  #elif __i386__
34  #define LIBCONTEXT_PLATFORM_linux_i386
35  #define LIBCONTEXT_CALL_CONVENTION
36  #elif __arm__
37  #define LIBCONTEXT_PLATFORM_linux_arm32
38  #define LIBCONTEXT_CALL_CONVENTION
39  #elif __aarch64__
40  #define LIBCONTEXT_PLATFORM_linux_arm64
41  #define LIBCONTEXT_CALL_CONVENTION
42  #elif (__mips__ && _MIPS_SIM == _ABI64)
43  #define LIBCONTEXT_PLATFORM_linux_mips_n64
44  #define LIBCONTEXT_CALL_CONVENTION
45  #elif __powerpc__
46  #ifdef _ARCH_PPC64
47  #define LIBCONTEXT_PLATFORM_linux_ppc64
48  #define LIBCONTEXT_CALL_CONVENTION
49  #elif defined _ARCH_PPC
50  #define LIBCONTEXT_PLATFORM_linux_ppc32
51  #define LIBCONTEXT_CALL_CONVENTION
52  #endif
53  #endif
54 
55  #elif defined(__MINGW32__) || defined(__MINGW64__)
56  #if defined(__x86_64__)
57  #define LIBCONTEXT_COMPILER_gcc
58  #define LIBCONTEXT_PLATFORM_windows_x86_64
59  #define LIBCONTEXT_CALL_CONVENTION
60  #endif
61 
62  #if defined(__i386__)
63  #define LIBCONTEXT_COMPILER_gcc
64  #define LIBCONTEXT_PLATFORM_windows_i386
65  #define LIBCONTEXT_CALL_CONVENTION __cdecl
66  #endif
67  #elif defined(__APPLE__) && defined(__MACH__)
68  #if defined(__i386__)
69  #define LIBCONTEXT_PLATFORM_apple_i386
70  #define LIBCONTEXT_CALL_CONVENTION
71  #elif defined(__x86_64__)
72  #define LIBCONTEXT_PLATFORM_apple_x86_64
73  #define LIBCONTEXT_CALL_CONVENTION
74  #endif
75  #endif
76 #endif
77 
78 #ifdef __cplusplus
79 namespace libcontext {
80 #endif
81 
82 #if defined(_WIN32_WCE)
83 typedef int intptr_t;
84 #endif
85 
86 typedef void* fcontext_t;
87 
88 #ifdef __cplusplus
89 extern "C" {
90 #endif
91 
92 
93 intptr_t LIBCONTEXT_CALL_CONVENTION jump_fcontext( fcontext_t* ofc, fcontext_t nfc,
94  intptr_t vp, bool preserve_fpu = true );
95 fcontext_t LIBCONTEXT_CALL_CONVENTION make_fcontext( void* sp, size_t size,
96  void (* fn)( intptr_t ) );
97 
98 #ifdef __cplusplus
99 } // namespace
100 #endif
101 
102 #ifdef __cplusplus
103 } // extern "C"
104 #endif
105 
106 #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:86
fcontext_t LIBCONTEXT_CALL_CONVENTION make_fcontext(void *sp, size_t size, void(*fn)(intptr_t))