Fix a bug introduced by the last change to mono_marshal_get_virtual_stelemref ()...
[mono.git] / mono / metadata / mono-endian.c
index bfaddefb453c63298398993c62c0a9bbe8fca4a1..23b6fe7b3caffab9839fab0fd6ef704492a24b4f 100644 (file)
@@ -1,18 +1,28 @@
+/*
+ * mono-endian.c:
+ *
+ * Author:
+ *     Mono Project (http://www.mono-project.com)
+ *
+ * Copyright 2001-2003 Ximian, Inc (http://www.ximian.com)
+ * Copyright 2004-2009 Novell, Inc (http://www.novell.com)
+ */
+#include <config.h>
 #include "mono-endian.h"
 
 #if NO_UNALIGNED_ACCESS
 
-typedef struct {
+typedef union {
        char c [2];
        guint16 i;
 } mono_rint16;
 
-typedef struct {
+typedef union {
        char c [4];
        guint32 i;
 } mono_rint32;
 
-typedef struct {
+typedef union {
        char c [8];
        guint64 i;
 } mono_rint64;
@@ -21,7 +31,7 @@ guint16
 mono_read16 (const unsigned char *x)
 {
        mono_rint16 r;
-#if G_BYTE_ORDER != G_LITTLE_ENDIAN
+#if G_BYTE_ORDER == G_LITTLE_ENDIAN
        r.c [0] = x [0];
        r.c [1] = x [1];
 #else
@@ -35,7 +45,7 @@ guint32
 mono_read32 (const unsigned char *x)
 {
        mono_rint32 r;
-#if G_BYTE_ORDER != G_LITTLE_ENDIAN
+#if G_BYTE_ORDER == G_LITTLE_ENDIAN
        r.c [0] = x [0];
        r.c [1] = x [1];
        r.c [2] = x [2];
@@ -53,7 +63,7 @@ guint64
 mono_read64 (const unsigned char *x)
 {
        mono_rint64 r;
-#if G_BYTE_ORDER != G_LITTLE_ENDIAN
+#if G_BYTE_ORDER == G_LITTLE_ENDIAN
        r.c [0] = x [0];
        r.c [1] = x [1];
        r.c [2] = x [2];