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