Project

General

Profile

Bug #5991 ยป fiddle.diff

nobu (Nobuyoshi Nakada), 02/10/2012 12:38 AM

View differences:

w/ext/fiddle/conversions.c
27 27
	return rb_ffi_type_of(long);
28 28
#if HAVE_LONG_LONG
29 29
      case TYPE_LONG_LONG:
30
	return rb_ffi_type_of(int64);
30
	return rb_ffi_type_of(long_long);
31 31
#endif
32 32
      case TYPE_FLOAT:
33 33
	return &ffi_type_float;
......
56 56
	dst->pointer = NUM2PTR(rb_Integer(src));
57 57
	break;
58 58
      case TYPE_CHAR:
59
	dst->schar = NUM2INT(src);
59
	if (signed_p)
60
	    dst->schar = NUM2INT(src);
61
	else
62
	    dst->uchar = NUM2UINT(src);
60 63
	break;
61 64
      case TYPE_SHORT:
62
	dst->sshort = NUM2INT(src);
65
	if (signed_p)
66
	    dst->sshort = NUM2INT(src);
67
	else
68
	    dst->ushort = NUM2UINT(src);
63 69
	break;
64 70
      case TYPE_INT:
65
	dst->sint = NUM2INT(src);
71
	if (signed_p)
72
	    dst->sint = NUM2INT(src);
73
	else
74
	    dst->uint = NUM2UINT(src);
66 75
	break;
67 76
      case TYPE_LONG:
68 77
	if (signed_p)
69 78
	    dst->slong = NUM2LONG(src);
70 79
	else
71
	    dst->ulong = NUM2LONG(src);
80
	    dst->ulong = NUM2ULONG(src);
72 81
	break;
73 82
#if HAVE_LONG_LONG
74 83
      case TYPE_LONG_LONG:
75
	dst->long_long = NUM2ULL(src);
84
	if (signed_p)
85
	    dst->slong_long = NUM2LL(src);
86
	else
87
	    dst->ulong_long = NUM2ULL(src);
76 88
	break;
77 89
#endif
78 90
      case TYPE_FLOAT:
......
120 132
	return ULONG2NUM(retval.ulong);
121 133
#if HAVE_LONG_LONG
122 134
      case TYPE_LONG_LONG:
123
	return rb_ll2inum(retval.long_long);
135
	if (signed_p) return LL2NUM(retval.slong_long);
136
	return ULL2NUM(retval.ulong_long);
124 137
	break;
125 138
#endif
126 139
      case TYPE_FLOAT:
w/ext/fiddle/conversions.h
18 18
    float ffloat;          /* ffi_type_float */
19 19
    double ddouble;        /* ffi_type_double */
20 20
#if HAVE_LONG_LONG
21
    unsigned LONG_LONG long_long; /* ffi_type_uint64 */
21
    unsigned LONG_LONG ulong_long; /* ffi_type_ulong_long */
22
    signed LONG_LONG slong_long; /* ffi_type_ulong_long */
22 23
#endif
23 24
    void * pointer;        /* ffi_type_pointer */
24 25
} fiddle_generic;
w/ext/fiddle/fiddle.h
67 67
#  error "long size not supported"
68 68
# endif
69 69

  
70
#if HAVE_LONG_LONG
71
# if SIZEOF_LONG_LONG == 8
72
#   define ffi_type_slong_long ffi_type_sint64
73
#   define ffi_type_ulong_long ffi_type_uint64
74
# else
75
#  error "long long size not supported"
76
# endif
77
#endif
78

  
70 79
#include <closure.h>
71 80
#include <conversions.h>
72 81
#include <function.h>