Skip to content

Commit 941050c

Browse files
committed
ossl.h: add NUM2UINT64T() macro
As a wrapper of NUM2ULONG() or NUM2ULL(). Converts a Ruby object to uint64_t, raising an exception if the conversion fails.
1 parent 36cf2f0 commit 941050c

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

ext/openssl/ossl.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,19 @@ extern VALUE eOSSLError;
6969
}\
7070
} while (0)
7171

72+
/*
73+
* Type conversions
74+
*/
75+
#if !defined(NUM2UINT64T) /* in case Ruby starts to provide */
76+
# if SIZEOF_LONG == 8
77+
# define NUM2UINT64T(x) ((uint64_t)NUM2ULONG(x))
78+
# elif defined(HAVE_LONG_LONG) && SIZEOF_LONG_LONG == 8
79+
# define NUM2UINT64T(x) ((uint64_t)NUM2ULL(x))
80+
# else
81+
# error "unknown platform; no 64-bit width integer"
82+
# endif
83+
#endif
84+
7285
/*
7386
* Data Conversion
7487
*/

0 commit comments

Comments
 (0)