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  #endif
43 
44  #elif defined(__MINGW32__) || defined(__MINGW64__)
45  #if defined(__x86_64__)
46  #define LIBCONTEXT_COMPILER_gcc
47  #define LIBCONTEXT_PLATFORM_windows_x86_64
48  #define LIBCONTEXT_CALL_CONVENTION
49  #endif
50 
51  #if defined(__i386__)
52  #define LIBCONTEXT_COMPILER_gcc
53  #define LIBCONTEXT_PLATFORM_windows_i386
54  #define LIBCONTEXT_CALL_CONVENTION __cdecl
55  #endif
56  #elif defined(__APPLE__) && defined(__MACH__)
57  #if defined(__i386__)
58  #define LIBCONTEXT_PLATFORM_apple_i386
59  #define LIBCONTEXT_CALL_CONVENTION
60  #elif defined(__x86_64__)
61  #define LIBCONTEXT_PLATFORM_apple_x86_64
62  #define LIBCONTEXT_CALL_CONVENTION
63  #endif
64  #endif
65 #endif
66 
67 #ifdef __cplusplus
68 namespace libcontext {
69 #endif
70 
71 #if defined(_WIN32_WCE)
72 typedef int intptr_t;
73 #endif
74 
75 typedef void* fcontext_t;
76 
77 #ifdef __cplusplus
78 extern "C" {
79 #endif
80 
81 
82 intptr_t LIBCONTEXT_CALL_CONVENTION jump_fcontext( fcontext_t* ofc, fcontext_t nfc,
83  intptr_t vp, bool preserve_fpu = true );
84 fcontext_t LIBCONTEXT_CALL_CONVENTION make_fcontext( void* sp, size_t size,
85  void (* fn)( intptr_t ) );
86 
87 #ifdef __cplusplus
88 } // namespace
89 #endif
90 
91 #ifdef __cplusplus
92 } // extern "C"
93 #endif
94 
95 #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:75
fcontext_t LIBCONTEXT_CALL_CONVENTION make_fcontext(void *sp, size_t size, void(*fn)(intptr_t))