diff --git a/ChangeLog b/ChangeLog index 75ea0fbaae..0bf9ae2f20 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +Fri Mar 13 10:42:19 2009 Nobuyoshi Nakada + + * configure.in (AC_HEADER_DIRENT): added. + + * include/ruby/ruby.h (NUM2INT, rb_special_const_p): returns true + and false instead of Qtrue and Qfalse for platforms where VALUE + is bigger than int. + + * gc.c (gc_stress_set), ext/openssl/ossl_asn1.c (decode_bool): go + rid of variables named `bool'. + Fri Mar 13 10:16:36 2009 Nobuyoshi Nakada * configure.in (struct stat.st_size): may be huge. diff --git a/configure.in b/configure.in index 9a66e73641..6cbd8ecbd1 100644 --- a/configure.in +++ b/configure.in @@ -887,6 +887,7 @@ fi dnl Checks for header files. AC_HEADER_DIRENT dnl AC_HEADER_STDC has been checked in AC_USE_SYSTEM_EXTENSIONS +AC_HEADER_STDBOOL AC_HEADER_SYS_WAIT AC_CHECK_HEADERS(limits.h sys/file.h sys/ioctl.h sys/syscall.h\ fcntl.h sys/fcntl.h sys/select.h sys/time.h sys/times.h sys/param.h\ diff --git a/ext/openssl/ossl_asn1.c b/ext/openssl/ossl_asn1.c index e6d09fbca1..6aff2b7e95 100644 --- a/ext/openssl/ossl_asn1.c +++ b/ext/openssl/ossl_asn1.c @@ -306,14 +306,14 @@ obj_to_asn1derstr(VALUE obj) static VALUE decode_bool(unsigned char* der, int length) { - int bool; + int val; const unsigned char *p; p = der; - if((bool = d2i_ASN1_BOOLEAN(NULL, &p, length)) < 0) + if((val = d2i_ASN1_BOOLEAN(NULL, &p, length)) < 0) ossl_raise(eASN1Error, NULL); - return bool ? Qtrue : Qfalse; + return val ? Qtrue : Qfalse; } static VALUE diff --git a/gc.c b/gc.c index 643874ac2d..835ef5d3b2 100644 --- a/gc.c +++ b/gc.c @@ -480,12 +480,12 @@ gc_stress_get(VALUE self) */ static VALUE -gc_stress_set(VALUE self, VALUE bool) +gc_stress_set(VALUE self, VALUE flag) { rb_objspace_t *objspace = &rb_objspace; rb_secure(2); - ruby_gc_stress = RTEST(bool); - return bool; + ruby_gc_stress = RTEST(flag); + return flag; } /* @@ -1636,7 +1636,7 @@ gc_mark_children(rb_objspace_t *objspace, VALUE ptr, int lev) break; default: - rb_bug("rb_gc_mark(): unknown data type 0x%lx(%p) %s", + rb_bug("rb_gc_mark(): unknown data type 0x%x(%p) %s", BUILTIN_TYPE(obj), (void *)obj, is_pointer_to_heap(objspace, obj) ? "corrupted object" : "non object"); } @@ -1934,7 +1934,7 @@ obj_free(rb_objspace_t *objspace, VALUE obj) break; default: - rb_bug("gc_sweep(): unknown data type 0x%lx(%p)", + rb_bug("gc_sweep(): unknown data type 0x%x(%p)", BUILTIN_TYPE(obj), (void*)obj); } diff --git a/include/ruby/ruby.h b/include/ruby/ruby.h index 4f28b9d698..b4a0011682 100644 --- a/include/ruby/ruby.h +++ b/include/ruby/ruby.h @@ -103,6 +103,13 @@ typedef unsigned LONG_LONG ID; # error ---->> ruby requires sizeof(void*) == sizeof(long) to be compiled. <<---- #endif +typedef char ruby_check_sizeof_int[SIZEOF_INT == sizeof(int) ? 1 : -1]; +typedef char ruby_check_sizeof_long[SIZEOF_LONG == sizeof(long) ? 1 : -1]; +#ifdef SIZEOF_LONG_LONG +typedef char ruby_check_sizeof_long_long[SIZEOF_LONG_LONG == sizeof(LONG_LONG) ? 1 : -1]; +#endif +typedef char ruby_check_sizeof_voidp[SIZEOF_VOIDP == sizeof(void*) ? 1 : -1]; + #if defined PRIdPTR && !defined PRI_VALUE_PREFIX #define PRIdVALUE PRIdPTR #define PRIiVALUE PRIiPTR @@ -302,6 +309,28 @@ enum ruby_special_consts { RUBY_SPECIAL_SHIFT = 8 }; +#if defined HAVE_STDBOOL_H +# include +#elif defined __cplusplus +typedef bool _Bool; +#else +# ifndef HAVE__BOOL +# define _Bool signed char +# endif +# ifndef bool +# define bool _Bool +# endif +# ifndef false +# define false 0 +# endif +# ifndef true +# define true 1 +# endif +# ifndef __bool_true_false_are_defined +# define __bool_true_false_are_defined 1 +# endif +#endif + #define Qfalse ((VALUE)RUBY_Qfalse) #define Qtrue ((VALUE)RUBY_Qtrue) #define Qnil ((VALUE)RUBY_Qnil) @@ -375,7 +404,7 @@ enum ruby_value_type { #define T_ZOMBIE RUBY_T_ZOMBIE #define T_MASK RUBY_T_MASK -#define BUILTIN_TYPE(x) (((struct RBasic*)(x))->flags & T_MASK) +#define BUILTIN_TYPE(x) (int)(((struct RBasic*)(x))->flags & T_MASK) #define TYPE(x) rb_type((VALUE)(x)) @@ -439,7 +468,7 @@ long rb_fix2int(VALUE); static inline int NUM2INT(VALUE x) { - return FIXNUM_P(x) ? FIX2INT(x) : rb_num2int(x); + return FIXNUM_P(x) ? FIX2INT(x) : (int)rb_num2int(x); } unsigned long rb_num2uint(VALUE); #define NUM2UINT(x) ((unsigned int)rb_num2uint(x)) @@ -1142,8 +1171,8 @@ rb_type(VALUE obj) static inline int rb_special_const_p(VALUE obj) { - if (SPECIAL_CONST_P(obj)) return Qtrue; - return Qfalse; + if (SPECIAL_CONST_P(obj)) return true; + return false; } #include "ruby/missing.h"