ruby-changes:17730
From: nobu <ko1@a...>
Date: Thu, 11 Nov 2010 20:50:03 +0900 (JST)
Subject: [ruby-changes:17730] Ruby:r29741 (trunk): * include/ruby/ruby.h (PRI_LL_PREFIX): format type specifier for
nobu 2010-11-11 20:49:54 +0900 (Thu, 11 Nov 2010) New Revision: 29741 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=29741 Log: * include/ruby/ruby.h (PRI_LL_PREFIX): format type specifier for LONG_LONG may vary on platforms. Modified files: trunk/ChangeLog trunk/configure.in trunk/include/ruby/ruby.h Index: include/ruby/ruby.h =================================================================== --- include/ruby/ruby.h (revision 29740) +++ include/ruby/ruby.h (revision 29741) @@ -101,7 +101,7 @@ # define SIGNED_VALUE LONG_LONG # define LONG_LONG_VALUE 1 # define SIZEOF_VALUE SIZEOF_LONG_LONG -# define PRI_VALUE_PREFIX "ll" +# define PRI_VALUE_PREFIX PRI_LL_PREFIX #else # error ---->> ruby requires sizeof(void*) == sizeof(long) to be compiled. <<---- #endif @@ -113,6 +113,13 @@ #endif typedef char ruby_check_sizeof_voidp[SIZEOF_VOIDP == sizeof(void*) ? 1 : -1]; +#ifndef PRI_INT_PREFIX +#define PRI_INT_PREFIX "" +#endif +#ifndef PRI_LONG_PREFIX +#define PRI_LONG_PREFIX "l" +#endif + #if defined PRIdPTR && !defined PRI_VALUE_PREFIX #define PRIdVALUE PRIdPTR #define PRIiVALUE PRIiPTR @@ -138,19 +145,17 @@ # elif SIZEOF_TIME_T == SIZEOF_LONG # define PRI_TIMET_PREFIX "l" # elif SIZEOF_TIME_T == SIZEOF_LONG_LONG -# define PRI_TIMET_PREFIX "ll" +# define PRI_TIMET_PREFIX PRI_LL_PREFIX # endif #endif #if defined PRI_PTRDIFF_PREFIX -#elif defined PRIdPTR -# define PRI_PTRDIFF_PREFIX "t" #elif SIZEOF_PTRDIFF_T == SIZEOF_INT -# define PRI_PTRDIFF_PREFIX +# define PRI_PTRDIFF_PREFIX "" #elif SIZEOF_PTRDIFF_T == SIZEOF_LONG # define PRI_PTRDIFF_PREFIX "l" #elif SIZEOF_PTRDIFF_T == SIZEOF_LONG_LONG -# define PRI_PTRDIFF_PREFIX "ll" +# define PRI_PTRDIFF_PREFIX PRI_LL_PREFIX #endif #define PRIdPTRDIFF PRI_PTRDIFF_PREFIX"d" #define PRIiPTRDIFF PRI_PTRDIFF_PREFIX"i" @@ -160,14 +165,12 @@ #define PRIXPTRDIFF PRI_PTRDIFF_PREFIX"X" #if defined PRI_SIZE_PREFIX -#elif defined PRIdPTR -# define PRI_SIZE_PREFIX "z" #elif SIZEOF_SIZE_T == SIZEOF_INT -# define PRI_SIZE_PREFIX +# define PRI_SIZE_PREFIX "" #elif SIZEOF_SIZE_T == SIZEOF_LONG # define PRI_SIZE_PREFIX "l" #elif SIZEOF_SIZE_T == SIZEOF_LONG_LONG -# define PRI_SIZE_PREFIX "ll" +# define PRI_SIZE_PREFIX PRI_LL_PREFIX #endif #define PRIdSIZE PRI_SIZE_PREFIX"d" #define PRIiSIZE PRI_SIZE_PREFIX"i" Index: configure.in =================================================================== --- configure.in (revision 29740) +++ configure.in (revision 29741) @@ -582,6 +582,36 @@ RUBY_CHECK_SIZEOF(double) RUBY_CHECK_SIZEOF(time_t, [long "long long"], [], [@%:@include <time.h>]) +AC_DEFUN([RUBY_CHECK_PRINTF_PREFIX], [ +AC_CACHE_CHECK([for printf prefix for $1], [rb_cv_pri_prefix_]AS_TR_SH($1), + [rb_cv_pri_prefix_]AS_TR_SH($1)=[NONE] + for pri in $2; do + RUBY_WERROR_FLAG(AC_TRY_COMPILE( + [@%:@include <stdio.h> + @%:@include <stddef.h> + @%:@ifdef __GNUC__ + @%:@define PRINTF_ARGS(decl, string_index, first_to_check) \ + decl __attribute__((format(printf, string_index, first_to_check))) + @%:@else + @%:@define PRINTF_ARGS(decl, string_index, first_to_check) decl + @%:@endif + PRINTF_ARGS(void test_sprintf(const char*, ...), 1, 2);], + [printf("%]${pri}[d", (]$1[)42); + test_sprintf("%]${pri}[d", (]$1[)42);], + [rb_cv_pri_prefix_]AS_TR_SH($1)[=[$pri]; break])) + done) +if test "[$rb_cv_pri_prefix_]AS_TR_SH($1)" != NONE; then + AC_DEFINE_UNQUOTED([PRI_]m4_ifval($3,$3,AS_TR_CPP(m4_bpatsubst([$1],[_t$])))[_PREFIX], + "[$rb_cv_pri_prefix_]AS_TR_SH($1)") +fi +]) + +if test "x$ac_cv_type_long_long" = xyes; then + RUBY_CHECK_PRINTF_PREFIX(long long, ll I64, LL) +elif test "x$ac_cv_type___int64" = xyes; then + RUBY_CHECK_PRINTF_PREFIX(__int64, ll I64, LL) +fi + dnl RUBY_REPLACE_TYPE [typename] [default type] [macro type] [included] AC_DEFUN([RUBY_REPLACE_TYPE], [dnl AC_CHECK_TYPE([$1], [n=[$1]], [n=[$2]], [$4]) @@ -623,7 +653,7 @@ AC_DEFINE_UNQUOTED([$3]2NUM[(v)], [${rb_cv_[$1]_convertible}2NUM(v)]) AC_DEFINE_UNQUOTED(NUM2[$3][(v)], [NUM2${rb_cv_[$1]_convertible}(v)]) AC_DEFINE_UNQUOTED(PRI_[$3]_PREFIX, - ["`echo ${rb_cv_[$1]_convertible} | sed ['s/^U//;s/[^L].*//;y/L/l/']`"]) + [PRI_`echo ${rb_cv_[$1]_convertible} | sed ['s/^U//']`_PREFIX]) ]) RUBY_REPLACE_TYPE(pid_t, int, PIDT) RUBY_REPLACE_TYPE(uid_t, int, UIDT) @@ -1081,18 +1111,6 @@ #include <stdio.h> ]) -AC_DEFUN([RUBY_CHECK_PRINTF_PREFIX], [ -AC_CACHE_CHECK([printf prefix for $1], rb_cv_pri_prefix_[$1], - RUBY_WERROR_FLAG(AC_TRY_COMPILE( - [@%:@include <stdio.h>], - [printf("%]$2[d", sizeof(long));], - [rb_cv_pri_prefix_[$1]=[$2]], - [rb_cv_pri_prefix_[$1]=[NONE]]))) -if test "$rb_cv_pri_prefix_[$1]" != NONE; then - AC_DEFINE_UNQUOTED([PRI_]AS_TR_CPP(m4_bpatsubst([$1],[_t$]))[_PREFIX], "$rb_cv_pri_prefix_[$1]") -fi -]) - AC_TYPE_SIZE_T RUBY_CHECK_SIZEOF(size_t, [int long void*], [], [@%:@include <sys/types.h>]) RUBY_CHECK_SIZEOF(ptrdiff_t, size_t, [], [@%:@include <stddef.h>]) Index: ChangeLog =================================================================== --- ChangeLog (revision 29740) +++ ChangeLog (revision 29741) @@ -1,3 +1,8 @@ +Thu Nov 11 20:49:48 2010 Nobuyoshi Nakada <nobu@r...> + + * include/ruby/ruby.h (PRI_LL_PREFIX): format type specifier for + LONG_LONG may vary on platforms. + Thu Nov 11 20:45:23 2010 Nobuyoshi Nakada <nobu@r...> * configure.in (SYMBOL_PREFIX): separate from EXPORT_PREFIX. -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/