Line |
Branch |
Exec |
Source |
1 |
|
|
/* GATE PROJECT LICENSE: |
2 |
|
|
+----------------------------------------------------------------------------+ |
3 |
|
|
| Copyright(c) 2018-2025, Stefan Meislinger <sm@opengate.at> | |
4 |
|
|
| All rights reserved. | |
5 |
|
|
| | |
6 |
|
|
| Redistribution and use in source and binary forms, with or without | |
7 |
|
|
| modification, are permitted provided that the following conditions are met:| |
8 |
|
|
| | |
9 |
|
|
| 1. Redistributions of source code must retain the above copyright notice, | |
10 |
|
|
| this list of conditions and the following disclaimer. | |
11 |
|
|
| 2. Redistributions in binary form must reproduce the above copyright | |
12 |
|
|
| notice, this list of conditions and the following disclaimer in the | |
13 |
|
|
| documentation and/or other materials provided with the distribution. | |
14 |
|
|
| | |
15 |
|
|
| THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"| |
16 |
|
|
| AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
17 |
|
|
| IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
18 |
|
|
| ARE DISCLAIMED.IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE | |
19 |
|
|
| LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
20 |
|
|
| CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
21 |
|
|
| SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
22 |
|
|
| INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
23 |
|
|
| CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
24 |
|
|
| ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF | |
25 |
|
|
| THE POSSIBILITY OF SUCH DAMAGE. | |
26 |
|
|
+----------------------------------------------------------------------------+ |
27 |
|
|
*/ |
28 |
|
|
|
29 |
|
|
/** @file |
30 |
|
|
* @brief Abstraction utilities for system specific component entrypoints |
31 |
|
|
* @ingroup gatecore |
32 |
|
|
*/ |
33 |
|
|
|
34 |
|
|
|
35 |
|
|
|
36 |
|
|
/** @mainpage Introduction |
37 |
|
|
* |
38 |
|
|
* \section section_preamble Preamble |
39 |
|
|
* |
40 |
|
|
* The GATE project is a C based library framework that shall provide |
41 |
|
|
* platform-independent implementations of lower-level auxiliary functions. |
42 |
|
|
* While most C libraries are only targeting Windows and Linux platforms, |
43 |
|
|
* GATE code is designed to run within other operating systems with no or |
44 |
|
|
* limited C standard library implementation. |
45 |
|
|
* |
46 |
|
|
* The GATE C++ libraries are a thin layer of C++ classes around the C based |
47 |
|
|
* implementation to simplify usage of lower-level C functions. Using a C |
48 |
|
|
* API within C++ code allows code sharing of C++ logic between incompatible |
49 |
|
|
* compilers (e.g. MSVC++ and g++). |
50 |
|
|
* |
51 |
|
|
* GATE is also an interface study where I add all kinds of features I was |
52 |
|
|
* missing in Win32 or POSIX like: |
53 |
|
|
* |
54 |
|
|
* - C-based object interfaces |
55 |
|
|
* - unified streaming |
56 |
|
|
* - coroutines |
57 |
|
|
* - delegates |
58 |
|
|
* - data containers, fields and dictionaries |
59 |
|
|
* |
60 |
|
|
* \section section_platforms Supported platforms |
61 |
|
|
* |
62 |
|
|
* - Windows API beginning with NT4 |
63 |
|
|
* - Windows CE (CE 5+) |
64 |
|
|
* - Windows RT (experimental) |
65 |
|
|
* - POSIX |
66 |
|
|
* - Linux (GLIBC, MUSL-LIBC) |
67 |
|
|
* - BSD (NetBSD, FreeBSD, OpenBSD) |
68 |
|
|
* - Android (experimental) |
69 |
|
|
* - FreeRTOS (experimental) |
70 |
|
|
* - UEFI Bootservices (experimental) |
71 |
|
|
* - DOS (experimental) |
72 |
|
|
* - WebAssembly-Emscripten (experimental) |
73 |
|
|
* |
74 |
|
|
* GATE libraries are designed with the concept of mandatory and optional |
75 |
|
|
* features. Mandatory features are available on all platforms and are only |
76 |
|
|
* depending on memory allocation support. Everything else that needs |
77 |
|
|
* operating system support (or a native platform implementation) is only |
78 |
|
|
* provided, if the platform supports it. |
79 |
|
|
* GATE ensures that the entry points are available on all platforms, but |
80 |
|
|
* they will return a NOT_IMPLEMENTED error at runtime when they are used. |
81 |
|
|
* This allows application to compile function calls also on platform where |
82 |
|
|
* they are not completely implemented. |
83 |
|
|
* |
84 |
|
|
* This feature was a main goal to overcome problems I found with other |
85 |
|
|
* libraries that still could not be compiled on a target platform due to |
86 |
|
|
* a single function that I never wanted to invoke. |
87 |
|
|
* |
88 |
|
|
* \section section_compilers Supported compilers |
89 |
|
|
* |
90 |
|
|
* - MSVC |
91 |
|
|
* - GCC |
92 |
|
|
* - CLANG |
93 |
|
|
* - WATCOM |
94 |
|
|
*/ |
95 |
|
|
|
96 |
|
|
#ifndef GATE_MAIN_H_INCLUDED |
97 |
|
|
#define GATE_MAIN_H_INCLUDED |
98 |
|
|
|
99 |
|
|
#include "gate/gate_core_api.h" |
100 |
|
|
#include "gate/gatemaindefs.h" |
101 |
|
|
|
102 |
|
|
|
103 |
|
|
#if defined(__cplusplus) |
104 |
|
|
# define GATE_MAIN_EXTERNC extern "C" |
105 |
|
|
#else |
106 |
|
|
# define GATE_MAIN_EXTERNC |
107 |
|
|
#endif |
108 |
|
|
|
109 |
|
|
GATE_MAIN_EXTERNC GATE_CORE_API int gate_main_stdc_entry(gate_main_func main_func, int argc, char* argv[]); |
110 |
|
|
|
111 |
|
|
#if defined(GATE_MAIN_WINAPI_IMPL) |
112 |
|
|
|
113 |
|
|
GATE_MAIN_EXTERNC GATE_CORE_API int gate_main_wchar_entry(gate_main_func main_func, int argc, wchar_t* argv[], wchar_t* envp[]); |
114 |
|
|
GATE_MAIN_EXTERNC GATE_CORE_API int gate_main_winapi_entry(gate_main_func main_func, void* hInstance, void* hPrevInstance, void* lpCmdLine, int nShowCmd); |
115 |
|
|
|
116 |
|
|
#if defined(GATE_SYS_WIN16) |
117 |
|
|
# define GATE_WINMAIN_API __pascal |
118 |
|
|
#else |
119 |
|
|
# define GATE_WINMAIN_API __stdcall |
120 |
|
|
#endif |
121 |
|
|
|
122 |
|
|
#if defined(GATE_SYS_WINCE) |
123 |
|
|
# define WINMAIN_STR wchar_t* |
124 |
|
|
#else |
125 |
|
|
# define WINMAIN_STR char* |
126 |
|
|
#endif |
127 |
|
|
|
128 |
|
|
#if defined(GATE_MAIN_NATIVE_HEADER_INCLUDED) |
129 |
|
|
int GATE_WINMAIN_API WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, WINMAIN_STR lpCmdLine, int nShowCmd) |
130 |
|
|
#else |
131 |
|
|
int GATE_WINMAIN_API WinMain(void* hInstance, void* hPrevInstance, void* lpCmdLine, int nShowCmd) |
132 |
|
|
#endif |
133 |
|
|
{ |
134 |
|
|
return gate_main_winapi_entry(&gate_main, hInstance, hPrevInstance, lpCmdLine, nShowCmd); |
135 |
|
|
} |
136 |
|
|
|
137 |
|
|
#if !defined(GATE_COMPILER_WATCOM) && !defined(GATE_COMPILER_TCC) |
138 |
|
|
int wmain(int argc, wchar_t* argv[], wchar_t* envp[]) |
139 |
|
|
{ |
140 |
|
|
return gate_main_wchar_entry(&gate_main, argc, argv, envp); |
141 |
|
|
} |
142 |
|
|
#endif /* !GATE_COMPILER_WATCOM */ |
143 |
|
|
|
144 |
|
|
|
145 |
|
|
#endif /* GATE_MAIN_WINAPI_IMPL */ |
146 |
|
|
|
147 |
|
|
#if defined(GATE_MAIN_ANDROID_IMPL) |
148 |
|
|
# include <android/native_activity.h> |
149 |
|
|
|
150 |
|
|
GATE_MAIN_EXTERNC GATE_CORE_API void gate_main_android_entry(gate_main_func main_func, void* activity, void* savedState, size_t savedStateSize); |
151 |
|
|
|
152 |
|
|
void ANativeActivity_onCreate(ANativeActivity* activity, void* savedState, size_t savedStateSize) |
153 |
|
|
{ |
154 |
|
|
gate_main_android_entry(&gate_main, activity, savedState, savedStateSize); |
155 |
|
|
} |
156 |
|
|
#endif /* GATE_MAIN_ANDROID_IMPL */ |
157 |
|
|
|
158 |
|
|
|
159 |
|
|
#if !defined(GATE_MAIN_NO_STDC_IMPL) |
160 |
|
16 |
int main(int argc, char* argv[], char* envp[]) |
161 |
|
|
{ |
162 |
|
|
(void)envp; |
163 |
|
16 |
return gate_main_stdc_entry(&gate_main, argc, argv); |
164 |
|
|
} |
165 |
|
|
|
166 |
|
|
#endif /* GATE_MAIN_NO_STDC */ |
167 |
|
|
|
168 |
|
|
#endif /* GATE_MAIN_H_INCLUDED */ |
169 |
|
|
|