Remove some unportable integral type size assumptions
authorIain Nicol <iain@thenicols.net>
Mon, 23 Nov 2009 18:52:40 +0000 (18:52 +0000)
committerJohan Dahlin <johan@gnome.org>
Wed, 2 Dec 2009 12:45:20 +0000 (10:45 -0200)
https://bugzilla.gnome.org/show_bug.cgi?id=602762

girepository/gfield.c
girepository/girffi.c

index 94c2fb5..486211f 100644 (file)
@@ -2,6 +2,7 @@
 
 #include "girepository.h"
 #include "girffi.h"
+#include "config.h"
 
 /**
  * g_field_info_get_field:
@@ -92,7 +93,13 @@ g_field_info_get_field (GIFieldInfo *field_info,
            result = TRUE;
            break;
          case GI_TYPE_TAG_TIME_T:
-           value->v_long = G_STRUCT_MEMBER(time_t, mem, offset);
+#if SIZEOF_TIME_T == 4
+           value->v_int32 = G_STRUCT_MEMBER(time_t, mem, offset);
+#elif SIZEOF_TIME_T == 8
+           value->v_int64 = G_STRUCT_MEMBER(time_t, mem, offset);
+#else
+#  error "Unexpected size for time_t: not 4 or 8"
+#endif
            result = TRUE;
            break;
          case GI_TYPE_TAG_UTF8:
@@ -292,7 +299,13 @@ g_field_info_set_field (GIFieldInfo     *field_info,
            result = TRUE;
            break;
          case GI_TYPE_TAG_TIME_T:
-           G_STRUCT_MEMBER(time_t, mem, offset) = value->v_long;
+#if SIZEOF_TIME_T == 4
+            G_STRUCT_MEMBER(time_t, mem, offset) = value->v_int32;
+#elif SIZEOF_TIME_T == 8
+            G_STRUCT_MEMBER(time_t, mem, offset) = value->v_int64;
+#else
+#  error "Unexpected size for time_t: not 4 or 8"
+#endif
            result = TRUE;
            break;
          case GI_TYPE_TAG_UTF8:
index d7c52f6..d67cbf6 100644 (file)
@@ -152,20 +152,28 @@ g_ir_ffi_convert_arguments(GICallableInfo *callable_info, void **args)
           g_args[i].v_uint32 = *(guint32 *) args[i];
           break;
         case GI_TYPE_TAG_LONG:
+          g_args[i].v_long = *(glong *) args[i];
+          break;
         case GI_TYPE_TAG_INT64:
-          g_args[i].v_int64 = *(glong *) args[i];
+          g_args[i].v_int64 = *(gint64 *) args[i];
           break;
         case GI_TYPE_TAG_ULONG:
+          g_args[i].v_ulong = *(gulong *) args[i];
+          break;
         case GI_TYPE_TAG_UINT64:
-          g_args[i].v_uint64 = *(glong *) args[i];
+          g_args[i].v_uint64 = *(guint64 *) args[i];
           break;
         case GI_TYPE_TAG_INT:
+          g_args[i].v_int = *(gint *) args[i];
+          break;
         case GI_TYPE_TAG_SSIZE:
+          g_args[i].v_ssize = *(gssize *) args[i];
+          break;
         case GI_TYPE_TAG_SIZE:
-          g_args[i].v_int32 = *(gint *) args[i];
+          g_args[i].v_size = *(gsize *) args[i];
           break;
         case GI_TYPE_TAG_UINT:
-          g_args[i].v_uint32 = *(guint *) args[i];
+          g_args[i].v_uint = *(guint *) args[i];
           break;
         case GI_TYPE_TAG_FLOAT:
           g_args[i].v_float = *(gfloat *) args[i];