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