Pass the --clr-memory-model flag on the command line instead of MONO_DEBUG so its...
[mono-project.git] / mono / metadata / abi.c
blob291f9a32019640a19404e8212e5b0af33cfba70b
1 #include <config.h>
3 #include <mono/utils/mono-memory-model.h>
4 #include <mono/metadata/abi-details.h>
7 typedef struct {
8 const char alignment [MONO_ALIGN_COUNT];
9 } AbiDetails;
12 #define DECLARE_ABI_DETAILS(I8, I16, I32, I64, F32, F64, PTR) \
13 const static AbiDetails mono_abi_details = { \
14 { I8, I16, I32, I64, F32, F64, PTR } \
15 }; \
17 #ifdef MONO_CROSS_COMPILE
19 #if TARGET_WASM
21 DECLARE_ABI_DETAILS (1, 2, 4, 8, 4, 8, 4)
23 #else
25 #define DECL_OFFSET(struct,field)
26 #define DECL_OFFSET2(struct,field,offset)
27 #define DECL_ALIGN2(type,size) MONO_ALIGN_value_ ##type = size,
28 #define DECL_SIZE(type)
29 #define DECL_SIZE2(type,size)
31 enum {
32 #include "object-offsets.h"
35 DECLARE_ABI_DETAILS (
36 MONO_ALIGN_value_gint8,
37 MONO_ALIGN_value_gint16,
38 MONO_ALIGN_value_gint32,
39 MONO_ALIGN_value_gint64,
40 MONO_ALIGN_value_float,
41 MONO_ALIGN_value_double,
42 MONO_ALIGN_value_gpointer)
44 #endif
46 #else
48 #define MONO_CURRENT_ABI_ALIGNOF_TYPEDEF(type) typedef struct { char c; type x; } Mono_Align_Struct_ ##type;
49 #define MONO_CURRENT_ABI_ALIGNOF(type) ((int)G_STRUCT_OFFSET(Mono_Align_Struct_ ##type, x))
51 /* Needed by MONO_CURRENT_ABI_ALIGNOF */
52 MONO_CURRENT_ABI_ALIGNOF_TYPEDEF(gint8)
53 MONO_CURRENT_ABI_ALIGNOF_TYPEDEF(gint16)
54 MONO_CURRENT_ABI_ALIGNOF_TYPEDEF(gint32)
55 MONO_CURRENT_ABI_ALIGNOF_TYPEDEF(gint64)
56 MONO_CURRENT_ABI_ALIGNOF_TYPEDEF(float)
57 MONO_CURRENT_ABI_ALIGNOF_TYPEDEF(double)
58 MONO_CURRENT_ABI_ALIGNOF_TYPEDEF(gpointer)
60 DECLARE_ABI_DETAILS (
61 MONO_CURRENT_ABI_ALIGNOF (gint8),
62 MONO_CURRENT_ABI_ALIGNOF (gint16),
63 MONO_CURRENT_ABI_ALIGNOF (gint32),
64 MONO_CURRENT_ABI_ALIGNOF (gint64),
65 MONO_CURRENT_ABI_ALIGNOF (float),
66 MONO_CURRENT_ABI_ALIGNOF (double),
67 MONO_CURRENT_ABI_ALIGNOF (gpointer))
69 #endif
71 int
72 mono_abi_alignment (CoreTypeAlign type)
74 return mono_abi_details.alignment [type];