#include <config.h>
#include <glib.h>
+/*
+ * This file defines macros to compute sizes/alignments/field offsets which depend on
+ * the ABI. It is needed during cross compiling since the generated code needs to
+ * contain offsets which correspond to the ABI of the target, not the host.
+ * It defines the following macros:
+ * - MONO_ABI_SIZEOF(type) for every basic type
+ * - MONO_ABI_ALIGNOF(type) for every basic type
+ * - MONO_STRUCT_OFFSET(struct, field) for various runtime structures
+ * When not cross compiling, these correspond to the host ABI (i.e. sizeof/offsetof).
+ * When cross compiling, these are defined in a generated header file which is
+ * generated by the offsets tool in tools/offsets-tool. The name of the file
+ * is given by the --with-cross-offsets= configure argument.
+ */
+
#define MONO_ABI_ALIGNOF(type) MONO_ALIGN_ ## type
#define MONO_CURRENT_ABI_ALIGNOF_TYPEDEF(type) typedef struct { char c; type x; } Mono_Align_Struct_ ##type;
#define MONO_CURRENT_ABI_ALIGNOF(type) ((int)G_STRUCT_OFFSET(Mono_Align_Struct_ ##type, x))
void
mono_metadata_cross_helpers_run (void);
+/*
+ * mono_metadata_cross_helpers_run:
+ *
+ * Check that the offsets given by object-offsets.h match the offsets
+ * on the host. This only checks the metadata offsets.
+ */
void
mono_metadata_cross_helpers_run (void)
{
+
/*
This is a parameterized header. It's supposed/ok to be included multiple times.
Optional:
USE_CROSS_COMPILE_OFFSETS - if defined, force the cross compiler offsets to be used, otherwise
they will only be used if MONO_CROSS_COMPILE is defined
+DISABLE_METADATA_OFFSETS - Disable the definition of offsets for structures defined in metadata/.
+DISABLE_JIT_OFFSETS - Disable the definition of offsets for structures defined in mini/.
+
+The last two are needed because metadata shouldn't include JIT offsets since the structures
+are not defined, while the JIT shouldn't include metadata offsets, since some of them
+are GC specific, and the JIT needs to remain GC agnostic.
Output defines:
DECL_SIZE(double)
DECL_SIZE(gpointer)
+// Offsets for structures defined in metadata/
#ifndef DISABLE_METADATA_OFFSETS
-//object offsets
DECL_OFFSET(MonoObject, vtable)
DECL_OFFSET(MonoObject, synchronisation)
#endif //DISABLE METADATA OFFSETS
+// Offsets for structures defined in mini/
#ifndef DISABLE_JIT_OFFSETS
DECL_OFFSET(MonoLMF, previous_lmf)
#endif
}
+/*
+ * mono_cross_helpers_run:
+ *
+ * Check that the offsets given by object-offsets.h match the offsets
+ * on the host.
+ */
void
mono_cross_helpers_run (void)
{
#if defined (HAS_CROSS_COMPILER_OFFSETS) && !defined (MONO_CROSS_COMPILE)
mono_metadata_cross_helpers_run ();
+ /* The metadata offsets are already checked above */
#define DISABLE_METADATA_OFFSETS
#define USE_CROSS_COMPILE_OFFSETS
#define DECL_OFFSET(struct,field) this_should_not_happen_for_cross_fields