summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortenderlove <tenderlove@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-06-28 16:25:33 +0000
committertenderlove <tenderlove@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-06-28 16:25:33 +0000
commitac3a9a62fecd97e73cdfde0ca278e0e4b074bacc (patch)
treea318c10641d002d3f8e5f5fd02156bbd3ede3df4
parente3e94249a9ff028f1a344e789fca52c1a7bd4727 (diff)
* ext/fiddle/fiddle.h: added FFI type detection to avoid bug in ffi
header files. Thanks Yugui! [ruby-core:30917] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_2@28463 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog5
-rw-r--r--ext/fiddle/fiddle.h49
2 files changed, 54 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index 8bd355f8eb..16fc0050a8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Tue Jun 29 01:22:08 2010 Aaron Patterson <aaron@tenderlovemaking.com>
+
+ * ext/fiddle/fiddle.h: added FFI type detection to avoid bug in ffi
+ header files. Thanks Yugui! [ruby-core:30917]
+
Sun Jun 27 23:31:17 2010 Nobuyoshi Nakada <nobu@ruby-lang.org>
* include/ruby/io.h, io.c: reverted r21709.
diff --git a/ext/fiddle/fiddle.h b/ext/fiddle/fiddle.h
index 0c573871dc..a73e560593 100644
--- a/ext/fiddle/fiddle.h
+++ b/ext/fiddle/fiddle.h
@@ -18,6 +18,55 @@
#include <ffi.h>
#endif
+#undef ffi_type_uchar
+#undef ffi_type_schar
+#undef ffi_type_ushort
+#undef ffi_type_sshort
+#undef ffi_type_uint
+#undef ffi_type_sint
+#undef ffi_type_ulong
+#undef ffi_type_slong
+
+#ifdef CHAR_BIT == 8
+# define ffi_type_uchar ffi_type_uint8
+# define ffi_type_schar ffi_type_sint8
+#else
+# error "CHAR_BIT not supported"
+#endif
+
+# ifdef SIZEOF_SHORT == 2
+# define ffi_type_ushort ffi_type_uint16
+# define ffi_type_sshort ffi_type_sint16
+# elif SIZEOF_SHORT == 4
+# define ffi_type_ushort ffi_type_uint32
+# define ffi_type_sshort ffi_type_sint32
+# else
+# error "short size not supported"
+# endif
+
+# if SIZEOF_INT == 2
+# define ffi_type_uint ffi_type_uint16
+# define ffi_type_sint ffi_type_sint16
+# elif SIZEOF_INT == 4
+# define ffi_type_uint ffi_type_uint32
+# define ffi_type_sint ffi_type_sint32
+# elif SIZEOF_INT == 8
+# define ffi_type_uint ffi_type_uint64
+# define ffi_type_sint ffi_type_sint64
+# else
+# error "int size not supported"
+# endif
+
+# if SIZEOF_LONG == 4
+# define ffi_type_ulong ffi_type_uint32
+# define ffi_type_slong ffi_type_sint32
+# elif SIZEOF_LONG == 8
+# define ffi_type_ulong ffi_type_uint64
+# define ffi_type_slong ffi_type_sint64
+# else
+# error "long size not supported"
+# endif
+
#include <closure.h>
#include <conversions.h>
#include <function.h>