diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2010-11-11 11:49:54 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2010-11-11 11:49:54 +0000 |
commit | fe9f1e8cf8a1d49c7d4d6baff2f1797ff89e7956 (patch) | |
tree | 81fe28f3a9a4ba55599c1c929e5e0b8d6967f1c2 | |
parent | 8a7d063c1f46fb47d12119e6c2b6dcbfcbc1d909 (diff) | |
download | ruby-fe9f1e8cf8a1d49c7d4d6baff2f1797ff89e7956.tar.gz |
* include/ruby/ruby.h (PRI_LL_PREFIX): format type specifier for
LONG_LONG may vary on platforms.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29741 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | configure.in | 44 | ||||
-rw-r--r-- | include/ruby/ruby.h | 23 |
3 files changed, 49 insertions, 23 deletions
@@ -1,3 +1,8 @@ +Thu Nov 11 20:49:48 2010 Nobuyoshi Nakada <nobu@ruby-lang.org> + + * 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@ruby-lang.org> * configure.in (SYMBOL_PREFIX): separate from EXPORT_PREFIX. diff --git a/configure.in b/configure.in index 3adba3c69e..3346a91194 100644 --- a/configure.in +++ b/configure.in @@ -582,6 +582,36 @@ RUBY_CHECK_SIZEOF(float) 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_DEFUN([RUBY_REPLACE_TYPE], [dnl 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 @@ RUBY_CHECK_SIZEOF(rlim_t, [int long "long long"], [], [ #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>]) diff --git a/include/ruby/ruby.h b/include/ruby/ruby.h index 3dc61e2738..02ff3c5127 100644 --- a/include/ruby/ruby.h +++ b/include/ruby/ruby.h @@ -101,7 +101,7 @@ typedef unsigned LONG_LONG ID; # 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 @@ typedef char ruby_check_sizeof_long_long[SIZEOF_LONG_LONG == sizeof(LONG_LONG) ? #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 @@ typedef char ruby_check_sizeof_voidp[SIZEOF_VOIDP == sizeof(void*) ? 1 : -1]; # 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 @@ typedef char ruby_check_sizeof_voidp[SIZEOF_VOIDP == sizeof(void*) ? 1 : -1]; #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" |