[gobject-introspection] Fix Alignment Errors.
- From: Colin Walters <walters src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gobject-introspection] Fix Alignment Errors.
- Date: Thu, 11 Feb 2010 22:28:54 +0000 (UTC)
commit 0fb726196aeed6c4f29aa0dc4d2d6031fae3c985
Author: Kedar Sovani <kedars marvell com>
Date: Wed Oct 21 13:28:12 2009 +0200
Fix Alignment Errors.
Signed-off-by: Kedar Sovani <kedars marvell com>
https://bugzilla.gnome.org/show_bug.cgi?id=606139
girepository/girnode.c | 19 +++++++++++++------
1 files changed, 13 insertions(+), 6 deletions(-)
---
diff --git a/girepository/girnode.c b/girepository/girnode.c
index 2523ee1..ede6d3b 100644
--- a/girepository/girnode.c
+++ b/girepository/girnode.c
@@ -53,6 +53,13 @@ _g_irnode_dump_stats (void)
g_message ("%lu types (%lu before sharing)", unique_types_count, types_count);
}
+#define DO_ALIGNED_COPY(dest_addr, value, type) \
+do { \
+ type tmp_var; \
+ tmp_var = value; \
+ memcpy(dest_addr, &tmp_var, sizeof(type)); \
+} while(0)
+
#define ALIGN_VALUE(this, boundary) \
(( ((unsigned long)(this)) + (((unsigned long)(boundary)) -1)) & (~(((unsigned long)(boundary))-1)))
@@ -2271,11 +2278,11 @@ g_ir_node_build_typelib (GIrNode *node,
break;
case GI_TYPE_TAG_INT64:
blob->size = 8;
- *(gint64*)&data[blob->offset] = (gint64) parse_int_value (constant->value);
+ DO_ALIGNED_COPY(&data[blob->offset], parse_int_value (constant->value), gint64);
break;
case GI_TYPE_TAG_UINT64:
blob->size = 8;
- *(guint64*)&data[blob->offset] = (guint64) parse_uint_value (constant->value);
+ DO_ALIGNED_COPY(&data[blob->offset], parse_uint_value (constant->value), guint64);
break;
case GI_TYPE_TAG_SHORT:
blob->size = sizeof (gshort);
@@ -2296,21 +2303,21 @@ g_ir_node_build_typelib (GIrNode *node,
case GI_TYPE_TAG_SSIZE: /* FIXME */
case GI_TYPE_TAG_LONG:
blob->size = sizeof (glong);
- *(glong*)&data[blob->offset] = (glong) parse_int_value (constant->value);
+ DO_ALIGNED_COPY(&data[blob->offset], parse_int_value (constant->value), glong);
break;
case GI_TYPE_TAG_SIZE: /* FIXME */
case GI_TYPE_TAG_TIME_T:
case GI_TYPE_TAG_ULONG:
blob->size = sizeof (gulong);
- *(gulong*)&data[blob->offset] = (gulong) parse_uint_value (constant->value);
+ DO_ALIGNED_COPY(&data[blob->offset], parse_uint_value (constant->value), gulong);
break;
case GI_TYPE_TAG_FLOAT:
blob->size = sizeof (gfloat);
- *(gfloat*)&data[blob->offset] = (gfloat) parse_float_value (constant->value);
+ DO_ALIGNED_COPY(&data[blob->offset], parse_float_value (constant->value), gfloat);
break;
case GI_TYPE_TAG_DOUBLE:
blob->size = sizeof (gdouble);
- *(gdouble*)&data[blob->offset] = (gdouble) parse_float_value (constant->value);
+ DO_ALIGNED_COPY(&data[blob->offset], parse_float_value (constant->value), gdouble);
break;
case GI_TYPE_TAG_UTF8:
case GI_TYPE_TAG_FILENAME:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]