mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* ext/dl/dl_conversions.c (rb_dl_type_to_ffi_type): support signed
long long. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26694 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
f953483787
commit
711ed72b79
2 changed files with 30 additions and 25 deletions
|
@ -1,4 +1,7 @@
|
||||||
Wed Feb 17 14:26:30 2010 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
Wed Feb 17 15:34:45 2010 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
|
* ext/dl/dl_conversions.c (rb_dl_type_to_ffi_type): support signed
|
||||||
|
long long.
|
||||||
|
|
||||||
* ext/dl/cfunc.c (rb_dlcfunc_inspect): get rid of overflow.
|
* ext/dl/cfunc.c (rb_dlcfunc_inspect): get rid of overflow.
|
||||||
|
|
||||||
|
|
|
@ -1,38 +1,40 @@
|
||||||
#include <dl_conversions.h>
|
#include <dl_conversions.h>
|
||||||
|
|
||||||
ffi_type * rb_dl_type_to_ffi_type(int dl_type)
|
ffi_type *
|
||||||
|
rb_dl_type_to_ffi_type(int dl_type)
|
||||||
{
|
{
|
||||||
int signed_p = 1;
|
int signed_p = 1;
|
||||||
|
|
||||||
if(dl_type < 0) {
|
if (dl_type < 0) {
|
||||||
dl_type = -1 * dl_type;
|
dl_type = -1 * dl_type;
|
||||||
signed_p = 0;
|
signed_p = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch(dl_type) {
|
#define rb_ffi_type_of(t) (signed_p ? &ffi_type_s##t : &ffi_type_u##t)
|
||||||
case DLTYPE_VOID:
|
|
||||||
return &ffi_type_void;
|
switch (dl_type) {
|
||||||
case DLTYPE_VOIDP:
|
case DLTYPE_VOID:
|
||||||
return &ffi_type_pointer;
|
return &ffi_type_void;
|
||||||
case DLTYPE_CHAR:
|
case DLTYPE_VOIDP:
|
||||||
return signed_p ? &ffi_type_schar : &ffi_type_uchar;
|
return &ffi_type_pointer;
|
||||||
case DLTYPE_SHORT:
|
case DLTYPE_CHAR:
|
||||||
return signed_p ? &ffi_type_sshort : &ffi_type_ushort;
|
return rb_ffi_type_of(char);
|
||||||
case DLTYPE_INT:
|
case DLTYPE_SHORT:
|
||||||
return signed_p ? &ffi_type_sint : &ffi_type_uint;
|
return rb_ffi_type_of(short);
|
||||||
case DLTYPE_LONG:
|
case DLTYPE_INT:
|
||||||
return signed_p ? &ffi_type_slong : &ffi_type_ulong;
|
return rb_ffi_type_of(int);
|
||||||
|
case DLTYPE_LONG:
|
||||||
|
return rb_ffi_type_of(long);
|
||||||
#if HAVE_LONG_LONG
|
#if HAVE_LONG_LONG
|
||||||
case DLTYPE_LONG_LONG:
|
case DLTYPE_LONG_LONG:
|
||||||
return &ffi_type_uint64;
|
return rb_ffi_type_of(int64);
|
||||||
break;
|
|
||||||
#endif
|
#endif
|
||||||
case DLTYPE_FLOAT:
|
case DLTYPE_FLOAT:
|
||||||
return &ffi_type_float;
|
return &ffi_type_float;
|
||||||
case DLTYPE_DOUBLE:
|
case DLTYPE_DOUBLE:
|
||||||
return &ffi_type_double;
|
return &ffi_type_double;
|
||||||
default:
|
default:
|
||||||
rb_raise(rb_eRuntimeError, "unknown type %d", dl_type);
|
rb_raise(rb_eRuntimeError, "unknown type %d", dl_type);
|
||||||
}
|
}
|
||||||
return &ffi_type_pointer;
|
return &ffi_type_pointer;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue