5 #ifndef __MONO_PUBLIB_H__
6 #define __MONO_PUBLIB_H__
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.
15 #define MONO_BEGIN_DECLS extern "C" {
16 #define MONO_END_DECLS }
18 #define MONO_BEGIN_DECLS /* nothing */
19 #define MONO_END_DECLS /* nothing */
24 /* VS 2010 and later have stdint.h */
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;
44 #define MONO_API_EXPORT __declspec(dllexport)
45 #define MONO_API_IMPORT __declspec(dllimport)
51 #if defined (__clang__) || defined (__GNUC__)
52 #define MONO_API_EXPORT __attribute__ ((__visibility__ ("default")))
54 #define MONO_API_EXPORT
56 #define MONO_API_IMPORT
58 #endif /* end of compiler-specific stuff */
63 #define MONO_EXTERN_C extern "C"
65 #define MONO_EXTERN_C /* nothing */
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
73 #define MONO_API_NO_EXTERN_C /* nothing */
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.
83 #define MONO_API_DATA MONO_API
85 #define MONO_API_DATA extern MONO_API
88 typedef int32_t mono_bool
;
89 typedef uint8_t mono_byte
;
90 typedef mono_byte MonoBoolean
;
94 typedef wchar_t mono_unichar2
;
97 typedef uint16_t mono_unichar2
;
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
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
;
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
127 #ifndef MONO_ZERO_LEN_ARRAY
129 #define MONO_ZERO_LEN_ARRAY 0
131 #define MONO_ZERO_LEN_ARRAY 1
135 #if defined (MONO_INSIDE_RUNTIME)
137 #if defined (__CENTRINEL__)
138 /* Centrinel is an analyzer that warns about raw pointer to managed objects
141 #define MONO_RT_MANAGED_ATTR __CENTRINEL_MANAGED_ATTR
142 #define MONO_RT_CENTRINEL_SUPPRESS __CENTRINEL_SUPPRESS_ATTR(1)
144 #define MONO_RT_MANAGED_ATTR
145 #define MONO_RT_CENTRINEL_SUPPRESS
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
159 #define MONO_RT_EXTERNAL_ONLY __attribute__ ((__deprecated__)) MONO_RT_CENTRINEL_SUPPRESS
161 #define MONO_RT_EXTERNAL_ONLY MONO_RT_CENTRINEL_SUPPRESS
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"
174 #define MONO_RT_EXTERNAL_ONLY MONO_RT_CENTRINEL_SUPPRESS
175 #endif // clang or gcc
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)
187 #define _MONO_DEPRECATED
190 #define MONO_DEPRECATED MONO_API MONO_RT_EXTERNAL_ONLY _MONO_DEPRECATED
194 #endif /* __MONO_PUBLIB_H__ */