Merge pull request #5714 from alexischr/update_bockbuild
[mono.git] / mono / utils / mono-publib.h
1 /**
2  * \file
3  */
4
5 #ifndef __MONO_PUBLIB_H__
6 #define __MONO_PUBLIB_H__
7
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.
12  */
13
14 #ifdef  __cplusplus
15 #define MONO_BEGIN_DECLS  extern "C" {
16 #define MONO_END_DECLS    }
17 #else
18 #define MONO_BEGIN_DECLS
19 #define MONO_END_DECLS
20 #endif
21
22 MONO_BEGIN_DECLS
23
24 /* VS 2010 and later have stdint.h */
25 #if defined(_MSC_VER)
26
27 #if _MSC_VER < 1600
28
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;
37
38 #else
39
40 #include <stdint.h>
41
42 #endif
43
44 #define MONO_API_EXPORT __declspec(dllexport)
45 #define MONO_API_IMPORT __declspec(dllimport)
46
47 #else
48
49 #include <stdint.h>
50
51 #ifdef __GNUC__
52 #define MONO_API_EXPORT __attribute__ ((__visibility__ ("default")))
53 #else
54 #define MONO_API_EXPORT
55 #endif
56 #define MONO_API_IMPORT
57
58 #endif /* end of compiler-specific stuff */
59
60 #include <stdlib.h>
61
62 #if defined(MONO_DLL_EXPORT)
63         #define MONO_API MONO_API_EXPORT
64 #elif defined(MONO_DLL_IMPORT)
65         #define MONO_API MONO_API_IMPORT
66 #else
67         #define MONO_API
68 #endif
69
70 typedef int32_t         mono_bool;
71 typedef uint8_t         mono_byte;
72 typedef uint16_t        mono_unichar2;
73 typedef uint32_t        mono_unichar4;
74
75 typedef void    (*MonoFunc)     (void* data, void* user_data);
76 typedef void    (*MonoHFunc)    (void* key, void* value, void* user_data);
77
78 MONO_API void mono_free (void *);
79
80 #define MONO_ALLOCATOR_VTABLE_VERSION 1
81
82 typedef struct {
83         int version;
84         void *(*malloc)      (size_t size);
85         void *(*realloc)     (void *mem, size_t count);
86         void (*free)        (void *mem);
87         void *(*calloc)      (size_t count, size_t size);
88 } MonoAllocatorVTable;
89
90 MONO_API mono_bool
91 mono_set_allocator_vtable (MonoAllocatorVTable* vtable);
92
93
94 #define MONO_CONST_RETURN const
95
96 /*
97  * When embedding, you have to define MONO_ZERO_LEN_ARRAY before including any
98  * other Mono header file if you use a different compiler from the one used to
99  * build Mono.
100  */
101 #ifndef MONO_ZERO_LEN_ARRAY
102 #ifdef __GNUC__
103 #define MONO_ZERO_LEN_ARRAY 0
104 #else
105 #define MONO_ZERO_LEN_ARRAY 1
106 #endif
107 #endif
108
109 #if defined (MONO_INSIDE_RUNTIME)
110
111 #if defined (__clang__)
112 #define MONO_RT_EXTERNAL_ONLY __attribute__ ((__unavailable__ ("The mono runtime must not call this function")))
113 #elif defined (__GNUC__)
114 #define MONO_RT_EXTERNAL_ONLY __attribute__ ((__error__ ("The mono runtime must not call this function")))
115 #else
116 #define MONO_RT_EXTERNAL_ONLY
117 #endif /* __clang__ */
118
119 #else
120 #define MONO_RT_EXTERNAL_ONLY
121 #endif /* MONO_INSIDE_RUNTIME */
122
123 #ifdef __GNUC__
124 #define _MONO_DEPRECATED __attribute__ ((__deprecated__))
125 #elif defined (_MSC_VER)
126 #define _MONO_DEPRECATED __declspec (deprecated)
127 #else
128 #define _MONO_DEPRECATED
129 #endif
130
131 #define MONO_DEPRECATED MONO_API MONO_RT_EXTERNAL_ONLY _MONO_DEPRECATED
132
133 MONO_END_DECLS
134
135 #endif /* __MONO_PUBLIB_H__ */
136