[gobject-introspection] [girepository] Support strict align platforms
- From: Johan Dahlin <johan src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gobject-introspection] [girepository] Support strict align platforms
- Date: Tue, 7 Sep 2010 14:45:04 +0000 (UTC)
commit 065f446de2c40b50ab103976cf2c2f10f5fb38f6
Author: Joe Marcus Clarke <marcus freebsd org>
Date: Tue Sep 7 11:42:49 2010 -0300
[girepository] Support strict align platforms
Such as Sparc64.
https://bugzilla.gnome.org/show_bug.cgi?id=620769
girepository/giconstantinfo.c | 11 +++++++----
1 files changed, 7 insertions(+), 4 deletions(-)
---
diff --git a/girepository/giconstantinfo.c b/girepository/giconstantinfo.c
index b6b67d1..0c40d8a 100644
--- a/girepository/giconstantinfo.c
+++ b/girepository/giconstantinfo.c
@@ -64,6 +64,9 @@ g_constant_info_get_type (GIConstantInfo *info)
return _g_type_info_new ((GIBaseInfo*)info, rinfo->typelib, rinfo->offset + 8);
}
+#define DO_ALIGNED_COPY(dest_addr, src_addr, type) \
+ memcpy((dest_addr), (src_addr), sizeof(type))
+
/**
* g_constant_info_get_value: (skip)
* @info: a #GIConstantInfo
@@ -118,16 +121,16 @@ g_constant_info_get_value (GIConstantInfo *info,
value->v_uint32 = *(guint32*)&rinfo->typelib->data[blob->offset];
break;
case GI_TYPE_TAG_INT64:
- value->v_int64 = *(gint64*)&rinfo->typelib->data[blob->offset];
+ DO_ALIGNED_COPY(&value->v_int64, &rinfo->typelib->data[blob->offset], gint64);
break;
case GI_TYPE_TAG_UINT64:
- value->v_uint64 = *(guint64*)&rinfo->typelib->data[blob->offset];
+ DO_ALIGNED_COPY(&value->v_uint64, &rinfo->typelib->data[blob->offset], guint64);
break;
case GI_TYPE_TAG_FLOAT:
- value->v_float = *(gfloat*)&rinfo->typelib->data[blob->offset];
+ DO_ALIGNED_COPY(&value->v_float, &rinfo->typelib->data[blob->offset], gfloat);
break;
case GI_TYPE_TAG_DOUBLE:
- value->v_double = *(gdouble*)&rinfo->typelib->data[blob->offset];
+ DO_ALIGNED_COPY(&value->v_double, &rinfo->typelib->data[blob->offset], gdouble);
break;
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]