Remove some unportable integral type size assumptions

https://bugzilla.gnome.org/show_bug.cgi?id=602762
This commit is contained in:
Iain Nicol 2009-11-23 18:52:40 +00:00 committed by Johan Dahlin
parent a7c04b69de
commit c22f11f1b8
2 changed files with 27 additions and 6 deletions

View 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:

View 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];