summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-12-13 09:35:10 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-12-13 09:35:10 +0000
commit34a0df159bd3754b9dbc467cf97dd6ed87f5f5e2 (patch)
treebd7636755f0d6d529fb6305fb9104f4209b818f9
parentd10d5a974d81628605cf4d69b9e1a9b13fd43651 (diff)
conversions.h: PTR2NUM
* ext/fiddle/conversions.h (PTR2NUM): use signed integer to make Fixnum for negative values. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53081 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog5
-rw-r--r--ext/fiddle/conversions.h4
2 files changed, 7 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index fdaf4d2..a4f154e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Sun Dec 13 18:35:11 2015 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * ext/fiddle/conversions.h (PTR2NUM): use signed integer to make
+ Fixnum for negative values.
+
Sun Dec 13 18:33:41 2015 Nobuyoshi Nakada <nobu@ruby-lang.org>
* pack.c (pack_pack): always check index range against the
diff --git a/ext/fiddle/conversions.h b/ext/fiddle/conversions.h
index d0a08d6..cbc610b 100644
--- a/ext/fiddle/conversions.h
+++ b/ext/fiddle/conversions.h
@@ -33,11 +33,11 @@ VALUE generic_to_value(VALUE rettype, fiddle_generic retval);
#define GENERIC2VALUE(_type, _retval) generic_to_value((_type), (_retval))
#if SIZEOF_VOIDP == SIZEOF_LONG
-# define PTR2NUM(x) (ULONG2NUM((unsigned long)(x)))
+# define PTR2NUM(x) (LONG2NUM((long)(x)))
# define NUM2PTR(x) ((void*)(NUM2ULONG(x)))
#else
/* # error --->> Ruby/DL2 requires sizeof(void*) == sizeof(long) to be compiled. <<--- */
-# define PTR2NUM(x) (ULL2NUM((unsigned long long)(x)))
+# define PTR2NUM(x) (LL2NUM((LONG_LONG)(x)))
# define NUM2PTR(x) ((void*)(NUM2ULL(x)))
#endif