mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* include/ruby/ruby.h ({RSTRING,RSTRUCT,RBIGNUM}_LENINT): check long
to cast to int. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27528 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
5e7101d348
commit
790d6071c6
2 changed files with 26 additions and 18 deletions
|
@ -1,3 +1,8 @@
|
|||
Wed Apr 28 16:44:58 2010 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* include/ruby/ruby.h ({RSTRING,RSTRUCT,RBIGNUM}_LENINT): check long
|
||||
to cast to int.
|
||||
|
||||
Wed Apr 28 16:28:51 2010 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* ext/socket/unixsocket.c (sendmsg_blocking, recvmsg_blocking):
|
||||
|
|
|
@ -272,6 +272,24 @@ VALUE rb_ull2inum(unsigned LONG_LONG);
|
|||
# endif
|
||||
#endif
|
||||
|
||||
#if SIZEOF_INT < SIZEOF_VALUE
|
||||
NORETURN(void rb_out_of_int(SIGNED_VALUE num));
|
||||
#endif
|
||||
|
||||
#if SIZEOF_INT < SIZEOF_LONG
|
||||
#define rb_long2int_internal(n, i) \
|
||||
int i = (int)(n); \
|
||||
if ((long)i != (n)) rb_out_of_int(n)
|
||||
#ifdef __GNUC__
|
||||
#define rb_long2int(n) __extension__ ({long i2l_n = (n); rb_long2int_internal(i2l_n, i2l_i); i2l_i;})
|
||||
#else
|
||||
static inline int
|
||||
rb_long2int(long n) {rb_long2int_internal(n, i); return i;}
|
||||
#endif
|
||||
#else
|
||||
#define rb_long2int(n) ((int)(n))
|
||||
#endif
|
||||
|
||||
#ifndef PIDT2NUM
|
||||
#define PIDT2NUM(v) LONG2NUM(v)
|
||||
#endif
|
||||
|
@ -637,6 +655,7 @@ struct RString {
|
|||
((RBASIC(str)->flags >> RSTRING_EMBED_LEN_SHIFT) & \
|
||||
(RSTRING_EMBED_LEN_MASK >> RSTRING_EMBED_LEN_SHIFT))) : \
|
||||
(RSTRING(str)->as.heap.ptr + RSTRING(str)->as.heap.len))
|
||||
#define RSTRING_LENINT(str) rb_long2int(RSTRING_LEN(str))
|
||||
|
||||
#define RARRAY_EMBED_LEN_MAX 3
|
||||
struct RArray {
|
||||
|
@ -666,24 +685,6 @@ struct RArray {
|
|||
((RBASIC(a)->flags & RARRAY_EMBED_FLAG) ? \
|
||||
RARRAY(a)->as.ary : \
|
||||
RARRAY(a)->as.heap.ptr)
|
||||
|
||||
#if SIZEOF_INT < SIZEOF_VALUE
|
||||
NORETURN(void rb_out_of_int(SIGNED_VALUE num));
|
||||
#endif
|
||||
|
||||
#if SIZEOF_INT < SIZEOF_LONG
|
||||
#define rb_long2int_internal(n, i) \
|
||||
int i = (int)(n); \
|
||||
if ((long)i != (n)) rb_out_of_int(n)
|
||||
#ifdef __GNUC__
|
||||
#define rb_long2int(n) __extension__ ({long i2l_n = (n); rb_long2int_internal(i2l_n, i2l_i); i2l_i;})
|
||||
#else
|
||||
static inline int
|
||||
rb_long2int(long n) {rb_long2int_internal(n, i); return i;}
|
||||
#endif
|
||||
#else
|
||||
#define rb_long2int(n) ((int)(n))
|
||||
#endif
|
||||
#define RARRAY_LENINT(ary) rb_long2int(RARRAY_LEN(ary))
|
||||
|
||||
struct RRegexp {
|
||||
|
@ -822,6 +823,7 @@ struct RStruct {
|
|||
((RBASIC(st)->flags & RSTRUCT_EMBED_LEN_MASK) ? \
|
||||
RSTRUCT(st)->as.ary : \
|
||||
RSTRUCT(st)->as.heap.ptr)
|
||||
#define RSTRUCT_LENINT(st) rb_long2int(RSTRUCT_LEN(st))
|
||||
|
||||
#define RBIGNUM_EMBED_LEN_MAX ((int)((sizeof(VALUE)*3)/sizeof(BDIGIT)))
|
||||
struct RBignum {
|
||||
|
@ -856,6 +858,7 @@ struct RBignum {
|
|||
((RBASIC(b)->flags & RBIGNUM_EMBED_FLAG) ? \
|
||||
RBIGNUM(b)->as.ary : \
|
||||
RBIGNUM(b)->as.heap.digits)
|
||||
#define RBIGNUM_LENINT(b) rb_long2int(RBIGNUM_LEN(b))
|
||||
|
||||
#define R_CAST(st) (struct st*)
|
||||
#define RBASIC(obj) (R_CAST(RBasic)(obj))
|
||||
|
|
Loading…
Reference in a new issue