Pass the --clr-memory-model flag on the command line instead of MONO_DEBUG so its...
[mono-project.git] / mono / metadata / mono-endian.h
blob8704dc5959d768ec585df4cd4a2ce9596505d978
1 /**
2 * \file
3 */
5 #ifndef _MONO_METADATA_ENDIAN_H_
6 #define _MONO_METADATA_ENDIAN_H_ 1
8 #include <glib.h>
10 typedef union {
11 guint32 ival;
12 float fval;
13 } mono_rfloat;
15 typedef union {
16 guint64 ival;
17 double fval;
18 unsigned char cval [8];
19 } mono_rdouble;
21 #if defined(__s390x__)
23 #define read16(x) s390x_read16(*(guint16 *)(x))
24 #define read32(x) s390x_read32(*(guint32 *)(x))
25 #define read64(x) s390x_read64(*(guint64 *)(x))
27 static __inline__ guint16
28 s390x_read16(guint16 x)
30 guint16 ret;
32 __asm__ (" lrvr %0,%1\n"
33 " sra %0,16\n"
34 : "=r" (ret) : "r" (x));
36 return(ret);
39 static __inline__ guint32
40 s390x_read32(guint32 x)
42 guint32 ret;
44 __asm__ (" lrvr %0,%1\n"
45 : "=r" (ret) : "r" (x));
47 return(ret);
50 static __inline__ guint64
51 s390x_read64(guint64 x)
53 guint64 ret;
55 __asm__ (" lrvgr %0,%1\n"
56 : "=r" (ret) : "r" (x));
58 return(ret);
61 #else
63 # if NO_UNALIGNED_ACCESS
65 guint16 mono_read16 (const unsigned char *x);
66 guint32 mono_read32 (const unsigned char *x);
67 guint64 mono_read64 (const unsigned char *x);
69 #define read16(x) (mono_read16 ((const unsigned char *)(x)))
70 #define read32(x) (mono_read32 ((const unsigned char *)(x)))
71 #define read64(x) (mono_read64 ((const unsigned char *)(x)))
73 # else
75 #define read16(x) GUINT16_FROM_LE (*((const guint16 *) (x)))
76 #define read32(x) GUINT32_FROM_LE (*((const guint32 *) (x)))
77 #define read64(x) GUINT64_FROM_LE (*((const guint64 *) (x)))
79 # endif
81 #endif
83 #define readr4(x,dest) \
84 do { \
85 mono_rfloat mf; \
86 mf.ival = read32 ((x)); \
87 *(dest) = mf.fval; \
88 } while (0)
90 #define readr8(x,dest) \
91 do { \
92 mono_rdouble mf; \
93 mf.ival = read64 ((x)); \
94 *(dest) = mf.fval; \
95 } while (0)
97 #endif /* _MONO_METADATA_ENDIAN_H_ */