[sdks] Bump Android NDK, build tools and platform tools versions
[mono-project.git] / mono / utils / mono-publib.h
blob1209f5c60db45450051a7f905d066822e2dfffae
1 /**
2 * \file
3 */
5 #ifndef __MONO_PUBLIB_H__
6 #define __MONO_PUBLIB_H__
8 /*
9 * Minimal general purpose header for use in public mono header files.
10 * We can't include config.h, so we use compiler-specific preprocessor
11 * directives where needed.
14 #ifdef __cplusplus
15 #define MONO_BEGIN_DECLS extern "C" {
16 #define MONO_END_DECLS }
17 #else
18 #define MONO_BEGIN_DECLS /* nothing */
19 #define MONO_END_DECLS /* nothing */
20 #endif
22 MONO_BEGIN_DECLS
24 /* VS 2010 and later have stdint.h */
25 #if defined(_MSC_VER)
27 #if _MSC_VER < 1600
29 typedef __int8 int8_t;
30 typedef unsigned __int8 uint8_t;
31 typedef __int16 int16_t;
32 typedef unsigned __int16 uint16_t;
33 typedef __int32 int32_t;
34 typedef unsigned __int32 uint32_t;
35 typedef __int64 int64_t;
36 typedef unsigned __int64 uint64_t;
38 #else
40 #include <stdint.h>
42 #endif
44 #define MONO_API_EXPORT __declspec(dllexport)
45 #define MONO_API_IMPORT __declspec(dllimport)
47 #else
49 #include <stdint.h>
51 #if defined (__clang__) || defined (__GNUC__)
52 #define MONO_API_EXPORT __attribute__ ((__visibility__ ("default")))
53 #else
54 #define MONO_API_EXPORT
55 #endif
56 #define MONO_API_IMPORT
58 #endif /* end of compiler-specific stuff */
60 #include <stdlib.h>
62 #ifdef __cplusplus
63 #define MONO_EXTERN_C extern "C"
64 #else
65 #define MONO_EXTERN_C /* nothing */
66 #endif
68 #if defined(MONO_DLL_EXPORT)
69 #define MONO_API_NO_EXTERN_C MONO_API_EXPORT
70 #elif defined(MONO_DLL_IMPORT)
71 #define MONO_API_NO_EXTERN_C MONO_API_IMPORT
72 #else
73 #define MONO_API_NO_EXTERN_C /* nothing */
74 #endif
76 #define MONO_API MONO_EXTERN_C MONO_API_NO_EXTERN_C
78 // extern "C" extern int c; // warning: duplicate 'extern' declaration specifier [-Wduplicate-decl-specifier]
80 // Therefore, remove extern on functions as always meaningless/redundant,
81 // and provide MONO_API_DATA for data, that always has one and only one extern.
82 #ifdef __cplusplus
83 #define MONO_API_DATA MONO_API
84 #else
85 #define MONO_API_DATA extern MONO_API
86 #endif
88 typedef int32_t mono_bool;
89 typedef uint8_t mono_byte;
90 typedef mono_byte MonoBoolean;
91 #ifdef _WIN32
92 MONO_END_DECLS
93 #include <wchar.h>
94 typedef wchar_t mono_unichar2;
95 MONO_BEGIN_DECLS
96 #else
97 typedef uint16_t mono_unichar2;
98 #endif
99 typedef uint32_t mono_unichar4;
101 typedef void (*MonoFunc) (void* data, void* user_data);
102 typedef void (*MonoHFunc) (void* key, void* value, void* user_data);
104 MONO_API void mono_free (void *);
106 #define MONO_ALLOCATOR_VTABLE_VERSION 1
108 typedef struct {
109 int version;
110 void *(*malloc) (size_t size);
111 void *(*realloc) (void *mem, size_t count);
112 void (*free) (void *mem);
113 void *(*calloc) (size_t count, size_t size);
114 } MonoAllocatorVTable;
116 MONO_API mono_bool
117 mono_set_allocator_vtable (MonoAllocatorVTable* vtable);
120 #define MONO_CONST_RETURN const
123 * When embedding, you have to define MONO_ZERO_LEN_ARRAY before including any
124 * other Mono header file if you use a different compiler from the one used to
125 * build Mono.
127 #ifndef MONO_ZERO_LEN_ARRAY
128 #ifdef __GNUC__
129 #define MONO_ZERO_LEN_ARRAY 0
130 #else
131 #define MONO_ZERO_LEN_ARRAY 1
132 #endif
133 #endif
135 #if defined (MONO_INSIDE_RUNTIME)
137 #if defined (__CENTRINEL__)
138 /* Centrinel is an analyzer that warns about raw pointer to managed objects
139 * inside Mono.
141 #define MONO_RT_MANAGED_ATTR __CENTRINEL_MANAGED_ATTR
142 #define MONO_RT_CENTRINEL_SUPPRESS __CENTRINEL_SUPPRESS_ATTR(1)
143 #else
144 #define MONO_RT_MANAGED_ATTR
145 #define MONO_RT_CENTRINEL_SUPPRESS
146 #endif
148 #if defined (__clang__) || defined (__GNUC__)
149 // attribute(deprecated(message)) was introduced in gcc 4.5.
150 // attribute(deprecated)) was introduced in gcc 4.0.
151 // Compare: https://gcc.gnu.org/onlinedocs/gcc-3.4.6/gcc/Function-Attributes.html
152 // https://gcc.gnu.org/onlinedocs/gcc-4.4.0/gcc/Function-Attributes.html
153 // https://gcc.gnu.org/onlinedocs/gcc-4.5.0/gcc/Function-Attributes.html
154 #if defined (__clang__) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5)
155 #define MONO_RT_EXTERNAL_ONLY \
156 __attribute__ ((__deprecated__ ("The mono runtime must not call this function."))) \
157 MONO_RT_CENTRINEL_SUPPRESS
158 #elif __GNUC__ >= 4
159 #define MONO_RT_EXTERNAL_ONLY __attribute__ ((__deprecated__)) MONO_RT_CENTRINEL_SUPPRESS
160 #else
161 #define MONO_RT_EXTERNAL_ONLY MONO_RT_CENTRINEL_SUPPRESS
162 #endif
164 #if defined (__clang__) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 2)
165 // Pragmas for controlling diagnostics appear to be from gcc 4.2.
166 // This is used in place of configure gcc -Werror=deprecated-declarations:
167 // 1. To be portable across build systems.
168 // 2. configure is very sensitive to compiler flags; they break autoconf's probes.
169 // Though #2 can be mitigated by being late in configure.
170 #pragma GCC diagnostic error "-Wdeprecated-declarations"
171 #endif
173 #else
174 #define MONO_RT_EXTERNAL_ONLY MONO_RT_CENTRINEL_SUPPRESS
175 #endif // clang or gcc
177 #else
178 #define MONO_RT_EXTERNAL_ONLY
179 #define MONO_RT_MANAGED_ATTR
180 #endif /* MONO_INSIDE_RUNTIME */
182 #if defined (__clang__) || defined (__GNUC__)
183 #define _MONO_DEPRECATED __attribute__ ((__deprecated__))
184 #elif defined (_MSC_VER)
185 #define _MONO_DEPRECATED __declspec (deprecated)
186 #else
187 #define _MONO_DEPRECATED
188 #endif
190 #define MONO_DEPRECATED MONO_API MONO_RT_EXTERNAL_ONLY _MONO_DEPRECATED
192 MONO_END_DECLS
194 #endif /* __MONO_PUBLIB_H__ */