From: "Nobuyoshi.Nakada" Date: 2000-11-02T14:15:41+09:00 Subject: [ruby-dev:11367] Re: [PATCH] an analogue of `long long' なかだです。 At Thu, 2 Nov 2000 02:46:50 +0900 Jun-ichiro itojun Hagino wrote: > >> gcc 以外でも long long 相当が使えるようにしてみました。VC では __int64 > >> らしいです。そのまんまな名前ですが。 > >`int64_t' とかで sys/types.h とかその周辺に定義されてるのもあるかも. > >新しい標準だとあるならこの名前であるはずなんじゃなかったかな. > ># int8_t とか,int16_t とか,int32_t とか. > > ANSI C 99だかで定義されているのは/usr/include/inttypes.h (int32_tとか > uint32_t)です。 > /usr/include/sys/types.hはBSD由来(?)、非標準です。 > (int32_tとかu_int32_t - uの次のunderscoreに注意) > > inttypes.hはまだまだ一般的でないです。configure.inで頑張って逃げる > 必要があるでしょう。 がんばってもらいました。configure.in に。 --disable-long-dbl で long long は使わなくなります。 diff -pruPX ./.excludes current/bignum.c devel/bignum.c --- current/bignum.c Wed Nov 1 17:49:39 2000 +++ devel/bignum.c Thu Nov 2 12:15:42 2000 @@ -20,14 +20,14 @@ VALUE rb_cBignum; #define USHORT _USHORT #endif -#if SIZEOF_LONG*2 <= SIZEOF_LONG_LONG +#if SIZEOF_LONG*2 <= SIZEOF_LONG_DBL typedef unsigned long BDIGIT; -typedef unsigned long long BDIGIT_DBL; -typedef long long BDIGIT_DBL_SIGNED; -#elif SIZEOF_INT*2 <= SIZEOF_LONG_LONG +typedef u_long_dbl BDIGIT_DBL; +typedef long_dbl BDIGIT_DBL_SIGNED; +#elif SIZEOF_INT*2 <= SIZEOF_LONG_DBL typedef unsigned int BDIGIT; -typedef unsigned long long BDIGIT_DBL; -typedef long long BDIGIT_DBL_SIGNED; +typedef u_long_dbl BDIGIT_DBL; +typedef long_dbl BDIGIT_DBL_SIGNED; #else typedef unsigned short BDIGIT; typedef unsigned long BDIGIT_DBL; diff -pruPX ./.excludes current/configure.in devel/configure.in --- current/configure.in Tue Oct 31 17:37:38 2000 +++ devel/configure.in Thu Nov 2 12:44:41 2000 @@ -29,6 +29,12 @@ AC_CANONICAL_HOST AC_CANONICAL_TARGET AC_CANONICAL_BUILD +dnl checks for long_dbl +long_dbl=yes +AC_ARG_ENABLE(long-dbl, + [--disable-long-dbl don't use double size long int. ], + [long_dbl=$enableval]) + dnl checks for fat-binary fat_binary=no AC_ARG_ENABLE(fat-binary, @@ -112,7 +118,6 @@ AC_PROG_MAKE_SET AC_CHECK_SIZEOF(int, 4) AC_CHECK_SIZEOF(short, 2) AC_CHECK_SIZEOF(long, 4) -AC_CHECK_SIZEOF(long long, 0) AC_CHECK_SIZEOF(void*, 4) AC_CHECK_SIZEOF(float, 4) AC_CHECK_SIZEOF(double, 8) @@ -212,7 +217,37 @@ AC_HEADER_STDC AC_HEADER_SYS_WAIT AC_CHECK_HEADERS(stdlib.h string.h unistd.h limits.h sys/file.h sys/ioctl.h\ fcntl.h sys/fcntl.h sys/select.h sys/time.h sys/times.h sys/param.h\ - syscall.h pwd.h a.out.h utime.h memory.h direct.h sys/resource.h) + syscall.h pwd.h a.out.h utime.h memory.h direct.h sys/resource.h\ + inttypes.h sys/types.h) + +dnl Checks for long_dbl type. +if test "${long_dbl}" = yes; then + AC_CHECK_SIZEOF(int64_t, 0) + if test $ac_cv_sizeof_int64_t -gt 0; then + long_dbl=int64_t + AC_DEFINE(long_dbl, int64_t) + AC_DEFINE(u_long_dbl, u_int64_t) + AC_DEFINE(SIZEOF_LONG_DBL, SIZEOF_INT64_T) + fi +fi +if test "${long_dbl}" = yes; then + AC_CHECK_SIZEOF(long long, 0) + if test $ac_cv_sizeof_long_long -gt 0; then + long_dbl='long long' + AC_DEFINE(long_dbl, long long) + AC_DEFINE(u_long_dbl, unsigned long long) + AC_DEFINE(SIZEOF_LONG_DBL, SIZEOF_LONG_LONG) + fi +fi +if test "${long_dbl}" = yes; then + AC_CHECK_SIZEOF(__int64, 0) + if test $ac_cv_sizeof___int64 -gt 0; then + long_dbl=__int64 + AC_DEFINE(long_dbl, __int64) + AC_DEFINE(u_long_dbl, unsigned __int64) + AC_DEFINE(SIZEOF_LONG_DBL, SIZEOF___INT64) + fi +fi dnl Checks for typedefs, structures, and compiler characteristics. AC_TYPE_UID_T diff -pruPX ./.excludes current/marshal.c devel/marshal.c --- current/marshal.c Tue Oct 31 17:37:39 2000 +++ devel/marshal.c Wed Nov 1 21:30:51 2000 @@ -18,10 +18,10 @@ double strtod(); #endif -#if SIZEOF_LONG*2 <= SIZEOF_LONG_LONG +#if SIZEOF_LONG*2 <= SIZEOF_LONG_DBL typedef unsigned long BDIGIT; #define SIZEOF_BDIGITS SIZEOF_LONG -#elif SIZEOF_INT*2 <= SIZEOF_LONG_LONG +#elif SIZEOF_INT*2 <= SIZEOF_LONG_DBL typedef unsigned int BDIGIT; #define SIZEOF_BDIGITS SIZEOF_INT #else -- --- 僕の前にBugはない。 --- 僕の後ろにBugはできる。 中田 伸悦