ruby-changes:29535
From: akr <ko1@a...>
Date: Sun, 23 Jun 2013 23:11:22 +0900 (JST)
Subject: [ruby-changes:29535] akr:r41587 (trunk): * include/ruby/defines.h (BDIGIT): Define it only if it is not defined
akr 2013-06-23 23:10:07 +0900 (Sun, 23 Jun 2013) New Revision: 41587 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=41587 Log: * include/ruby/defines.h (BDIGIT): Define it only if it is not defined yet. This eases tests and debug. (SIZEOF_BDIGITS): Ditto. (BDIGIT_DBL): Ditto. (BDIGIT_DBL_SIGNED): Ditto. (PRI_BDIGIT_PREFIX): Ditto. (PRI_BDIGIT_DBL_PREFIX): Ditto. (PRIdBDIGIT): Define it only if PRI_BDIGIT_PREFIX is defined. (PRIiBDIGIT): Ditto. (PRIoBDIGIT): Ditto. (PRIuBDIGIT): Ditto. (PRIxBDIGIT): Ditto. (PRIXBDIGIT): Ditto. (PRIdBDIGIT_DBL): Ditto. (PRIiBDIGIT_DBL): Ditto. (PRIoBDIGIT_DBL): Ditto. (PRIuBDIGIT_DBL): Ditto. (PRIxBDIGIT_DBL): Ditto. (PRIXBDIGIT_DBL): Ditto. * include/ruby/ruby.h (RBIGNUM_EMBED_LEN_MAX): Define it only if it is not defined yet. Modified files: trunk/ChangeLog trunk/include/ruby/defines.h trunk/include/ruby/ruby.h Index: include/ruby/defines.h =================================================================== --- include/ruby/defines.h (revision 41586) +++ include/ruby/defines.h (revision 41587) @@ -141,55 +141,61 @@ void xfree(void*); https://github.com/ruby/ruby/blob/trunk/include/ruby/defines.h#L141 # define SIZEOF_LONG_LONG SIZEOF___INT64 #endif -#if defined(HAVE_INT64_T) && defined(HAVE_INT128_T) -# define BDIGIT uint64_t -# define SIZEOF_BDIGITS SIZEOF_INT64_T -# define BDIGIT_DBL uint128_t -# define BDIGIT_DBL_SIGNED int128_t -# define PRI_BDIGIT_PREFIX PRI_64_PREFIX -#elif SIZEOF_INT*2 <= SIZEOF_LONG_LONG -# define BDIGIT unsigned int -# define SIZEOF_BDIGITS SIZEOF_INT -# define BDIGIT_DBL unsigned LONG_LONG -# define BDIGIT_DBL_SIGNED LONG_LONG -# define PRI_BDIGIT_PREFIX "" -# define PRI_BDIGIT_DBL_PREFIX PRI_LL_PREFIX -#elif SIZEOF_INT*2 <= SIZEOF_LONG -# define BDIGIT unsigned int -# define SIZEOF_BDIGITS SIZEOF_INT -# define BDIGIT_DBL unsigned long -# define BDIGIT_DBL_SIGNED long -# define PRI_BDIGIT_PREFIX "" -# define PRI_BDIGIT_DBL_PREFIX "l" -#elif SIZEOF_SHORT*2 <= SIZEOF_LONG -# define BDIGIT unsigned short -# define SIZEOF_BDIGITS SIZEOF_SHORT -# define BDIGIT_DBL unsigned long -# define BDIGIT_DBL_SIGNED long -# define PRI_BDIGIT_PREFIX "h" -# define PRI_BDIGIT_DBL_PREFIX "l" -#else -# define BDIGIT unsigned short -# define SIZEOF_BDIGITS (SIZEOF_LONG/2) -# define BDIGIT_DBL unsigned long -# define BDIGIT_DBL_SIGNED long -# define PRI_BDIGIT_PREFIX "h" -# define PRI_BDIGIT_DBL_PREFIX "l" +#ifndef BDIGIT +# if defined(HAVE_INT64_T) && defined(HAVE_INT128_T) +# define BDIGIT uint64_t +# define SIZEOF_BDIGITS SIZEOF_INT64_T +# define BDIGIT_DBL uint128_t +# define BDIGIT_DBL_SIGNED int128_t +# define PRI_BDIGIT_PREFIX PRI_64_PREFIX +# elif SIZEOF_INT*2 <= SIZEOF_LONG_LONG +# define BDIGIT unsigned int +# define SIZEOF_BDIGITS SIZEOF_INT +# define BDIGIT_DBL unsigned LONG_LONG +# define BDIGIT_DBL_SIGNED LONG_LONG +# define PRI_BDIGIT_PREFIX "" +# define PRI_BDIGIT_DBL_PREFIX PRI_LL_PREFIX +# elif SIZEOF_INT*2 <= SIZEOF_LONG +# define BDIGIT unsigned int +# define SIZEOF_BDIGITS SIZEOF_INT +# define BDIGIT_DBL unsigned long +# define BDIGIT_DBL_SIGNED long +# define PRI_BDIGIT_PREFIX "" +# define PRI_BDIGIT_DBL_PREFIX "l" +# elif SIZEOF_SHORT*2 <= SIZEOF_LONG +# define BDIGIT unsigned short +# define SIZEOF_BDIGITS SIZEOF_SHORT +# define BDIGIT_DBL unsigned long +# define BDIGIT_DBL_SIGNED long +# define PRI_BDIGIT_PREFIX "h" +# define PRI_BDIGIT_DBL_PREFIX "l" +# else +# define BDIGIT unsigned short +# define SIZEOF_BDIGITS (SIZEOF_LONG/2) +# define BDIGIT_DBL unsigned long +# define BDIGIT_DBL_SIGNED long +# define PRI_BDIGIT_PREFIX "h" +# define PRI_BDIGIT_DBL_PREFIX "l" +# endif #endif -#define PRIdBDIGIT PRI_BDIGIT_PREFIX"d" -#define PRIiBDIGIT PRI_BDIGIT_PREFIX"i" -#define PRIoBDIGIT PRI_BDIGIT_PREFIX"o" -#define PRIuBDIGIT PRI_BDIGIT_PREFIX"u" -#define PRIxBDIGIT PRI_BDIGIT_PREFIX"x" -#define PRIXBDIGIT PRI_BDIGIT_PREFIX"X" +#ifdef PRI_BDIGIT_PREFIX +# define PRIdBDIGIT PRI_BDIGIT_PREFIX"d" +# define PRIiBDIGIT PRI_BDIGIT_PREFIX"i" +# define PRIoBDIGIT PRI_BDIGIT_PREFIX"o" +# define PRIuBDIGIT PRI_BDIGIT_PREFIX"u" +# define PRIxBDIGIT PRI_BDIGIT_PREFIX"x" +# define PRIXBDIGIT PRI_BDIGIT_PREFIX"X" +#endif -#define PRIdBDIGIT_DBL PRI_BDIGIT_DBL_PREFIX"d" -#define PRIiBDIGIT_DBL PRI_BDIGIT_DBL_PREFIX"i" -#define PRIoBDIGIT_DBL PRI_BDIGIT_DBL_PREFIX"o" -#define PRIuBDIGIT_DBL PRI_BDIGIT_DBL_PREFIX"u" -#define PRIxBDIGIT_DBL PRI_BDIGIT_DBL_PREFIX"x" -#define PRIXBDIGIT_DBL PRI_BDIGIT_DBL_PREFIX"X" +#ifdef PRI_BDIGIT_DBL_PREFIX +# define PRIdBDIGIT_DBL PRI_BDIGIT_DBL_PREFIX"d" +# define PRIiBDIGIT_DBL PRI_BDIGIT_DBL_PREFIX"i" +# define PRIoBDIGIT_DBL PRI_BDIGIT_DBL_PREFIX"o" +# define PRIuBDIGIT_DBL PRI_BDIGIT_DBL_PREFIX"u" +# define PRIxBDIGIT_DBL PRI_BDIGIT_DBL_PREFIX"x" +# define PRIXBDIGIT_DBL PRI_BDIGIT_DBL_PREFIX"X" +#endif #ifdef __CYGWIN__ #undef _WIN32 Index: include/ruby/ruby.h =================================================================== --- include/ruby/ruby.h (revision 41586) +++ include/ruby/ruby.h (revision 41587) @@ -1134,7 +1134,9 @@ struct RStruct { https://github.com/ruby/ruby/blob/trunk/include/ruby/ruby.h#L1134 #define RSTRUCT_SET(st, idx, v) OBJ_WRITE(st, &RSTRUCT_RAWPTR(st)[idx], (v)) #define RSTRUCT_GET(st, idx) (RSTRUCT_RAWPTR(st)[idx]) -#define RBIGNUM_EMBED_LEN_MAX ((int)((sizeof(VALUE)*3)/sizeof(BDIGIT))) +#ifndef RBIGNUM_EMBED_LEN_MAX +# define RBIGNUM_EMBED_LEN_MAX ((int)((sizeof(VALUE)*3)/sizeof(BDIGIT))) +#endif struct RBignum { struct RBasic basic; union { Index: ChangeLog =================================================================== --- ChangeLog (revision 41586) +++ ChangeLog (revision 41587) @@ -1,3 +1,28 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Sun Jun 23 23:05:58 2013 Tanaka Akira <akr@f...> + + * include/ruby/defines.h (BDIGIT): Define it only if it is not defined + yet. This eases tests and debug. + (SIZEOF_BDIGITS): Ditto. + (BDIGIT_DBL): Ditto. + (BDIGIT_DBL_SIGNED): Ditto. + (PRI_BDIGIT_PREFIX): Ditto. + (PRI_BDIGIT_DBL_PREFIX): Ditto. + (PRIdBDIGIT): Define it only if PRI_BDIGIT_PREFIX is defined. + (PRIiBDIGIT): Ditto. + (PRIoBDIGIT): Ditto. + (PRIuBDIGIT): Ditto. + (PRIxBDIGIT): Ditto. + (PRIXBDIGIT): Ditto. + (PRIdBDIGIT_DBL): Ditto. + (PRIiBDIGIT_DBL): Ditto. + (PRIoBDIGIT_DBL): Ditto. + (PRIuBDIGIT_DBL): Ditto. + (PRIxBDIGIT_DBL): Ditto. + (PRIXBDIGIT_DBL): Ditto. + + * include/ruby/ruby.h (RBIGNUM_EMBED_LEN_MAX): Define it only if it is + not defined yet. + Sun Jun 23 17:29:51 2013 Tanaka Akira <akr@f...> * bignum.c (integer_unpack_single_bdigit): Use a cast. -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/