summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2002-03-15 08:51:31 +0000
committerusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2002-03-15 08:51:31 +0000
commit6ba0d31e8ffe03c6372ab41cae24770d71a54017 (patch)
tree37f3cc389dc8c449e81dc137d28552aee1a4c1bf
parent23beb1a9dd6654262d17d9dde4f8566d8c4277cc (diff)
* bignum.c, intern.h (rb_ull2big, rb_ll2big, rb_ull2inum, rb_ll2inum,
big2ull, rb_big2ull, rb_big2ll): use LONG_LONG macro instead of long long. * numeric.c, intern.h, ruby.h (rb_num2ll, rb_num2ull): ditto. * ruby.h: use _I64_MAX and _I64_MIN if they are defined (for VC++). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2207 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog10
-rw-r--r--bignum.c30
-rw-r--r--intern.h8
-rw-r--r--numeric.c10
-rw-r--r--ruby.h20
5 files changed, 48 insertions, 30 deletions
diff --git a/ChangeLog b/ChangeLog
index 8eadfc9d29d..070bdadb5b2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+Fri Mar 15 17:44:08 2002 Usaku Nakamura <usa@ruby-lang.org>
+
+ * bignum.c, intern.h (rb_ull2big, rb_ll2big, rb_ull2inum, rb_ll2inum,
+ big2ull, rb_big2ull, rb_big2ll): use LONG_LONG macro instead of
+ long long.
+
+ * numeric.c, intern.h, ruby.h (rb_num2ll, rb_num2ull): ditto.
+
+ * ruby.h: use _I64_MAX and _I64_MIN if they are defined (for VC++).
+
Fri Mar 15 14:02:43 2002 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
* ext/iconv/iconv.c: fixed document, Iconv#new is no longer an
diff --git a/bignum.c b/bignum.c
index 8aa242bc246..e090f9b0dc6 100644
--- a/bignum.c
+++ b/bignum.c
@@ -27,7 +27,7 @@ typedef LONG_LONG BDIGIT_DBL_SIGNED;
#elif SIZEOF_INT*2 <= SIZEOF_LONG
typedef unsigned int BDIGIT;
typedef unsigned long BDIGIT_DBL;
-typedef long long BDIGIT_DBL_SIGNED;
+typedef LONG_LONG BDIGIT_DBL_SIGNED;
#else
typedef unsigned short BDIGIT;
typedef unsigned long BDIGIT_DBL;
@@ -39,7 +39,7 @@ typedef long BDIGIT_DBL_SIGNED;
#define BIGRAD ((BDIGIT_DBL)1 << BITSPERDIG)
#define DIGSPERLONG ((unsigned int)(sizeof(long)/sizeof(BDIGIT)))
#if HAVE_LONG_LONG
-# define DIGSPERLL ((unsigned int)(sizeof(long long)/sizeof(BDIGIT)))
+# define DIGSPERLL ((unsigned int)(sizeof(LONG_LONG)/sizeof(BDIGIT)))
#endif
#define BIGUP(x) ((BDIGIT_DBL)(x) << BITSPERDIG)
#define BIGDN(x) RSHIFT(x,BITSPERDIG)
@@ -514,7 +514,7 @@ rb_str_to_inum(str, base, badcheck)
VALUE
rb_ull2big(n)
- unsigned long long n;
+ unsigned LONG_LONG n;
{
BDIGIT_DBL num = n;
long i = 0;
@@ -537,7 +537,7 @@ rb_ull2big(n)
VALUE
rb_ll2big(n)
- long long n;
+ LONG_LONG n;
{
long neg = 0;
VALUE big;
@@ -555,7 +555,7 @@ rb_ll2big(n)
VALUE
rb_ull2inum(n)
- unsigned long long n;
+ unsigned LONG_LONG n;
{
if (POSFIXABLE(n)) return INT2FIX(n);
return rb_ull2big(n);
@@ -563,7 +563,7 @@ rb_ull2inum(n)
VALUE
rb_ll2inum(n)
- long long n;
+ LONG_LONG n;
{
if (FIXABLE(n)) return INT2FIX(n);
return rb_ll2big(n);
@@ -716,7 +716,7 @@ rb_big2long(x)
#if HAVE_LONG_LONG
-static unsigned long long
+static unsigned LONG_LONG
big2ull(x, type)
VALUE x;
char *type;
@@ -725,7 +725,7 @@ big2ull(x, type)
BDIGIT_DBL num;
BDIGIT *ds;
- if (len > sizeof(long long)/sizeof(BDIGIT))
+ if (len > sizeof(LONG_LONG)/sizeof(BDIGIT))
rb_raise(rb_eRangeError, "bignum too big to convert into `%s'", type);
ds = BDIGITS(x);
num = 0;
@@ -736,27 +736,27 @@ big2ull(x, type)
return num;
}
-unsigned long long
+unsigned LONG_LONG
rb_big2ull(x)
VALUE x;
{
- unsigned long long num = big2ull(x, "unsigned long long");
+ unsigned LONG_LONG num = big2ull(x, "unsigned long long");
if (!RBIGNUM(x)->sign) return -num;
return num;
}
-long long
+LONG_LONG
rb_big2ll(x)
VALUE x;
{
- unsigned long long num = big2ull(x, "long long");
+ unsigned LONG_LONG num = big2ull(x, "long long");
- if ((long long)num < 0 && (RBIGNUM(x)->sign
- || (long long)num != LLONG_MIN)) {
+ if ((LONG_LONG)num < 0 && (RBIGNUM(x)->sign
+ || (LONG_LONG)num != LLONG_MIN)) {
rb_raise(rb_eRangeError, "bignum too big to convert into `long long'");
}
- if (!RBIGNUM(x)->sign) return -(long long)num;
+ if (!RBIGNUM(x)->sign) return -(LONG_LONG)num;
return num;
}
diff --git a/intern.h b/intern.h
index d05c3af9459..0eed0ddda6c 100644
--- a/intern.h
+++ b/intern.h
@@ -71,10 +71,10 @@ long rb_big2long _((VALUE));
unsigned long rb_big2ulong _((VALUE));
#define rb_big2uint(x) rb_big2ulong(x)
#if HAVE_LONG_LONG
-VALUE rb_ll2inum _((long long));
-VALUE rb_ull2inum _((unsigned long long));
-long long rb_big2ll _((VALUE));
-unsigned long long rb_big2ull _((VALUE));
+VALUE rb_ll2inum _((LONG_LONG));
+VALUE rb_ull2inum _((unsigned LONG_LONG));
+LONG_LONG rb_big2ll _((VALUE));
+unsigned LONG_LONG rb_big2ull _((VALUE));
#endif /* HAVE_LONG_LONG */
void rb_quad_pack _((char*,VALUE));
VALUE rb_quad_unpack _((const char*,int));
diff --git a/numeric.c b/numeric.c
index 5cd476bccb3..80fa1052f92 100644
--- a/numeric.c
+++ b/numeric.c
@@ -871,7 +871,7 @@ rb_num2fix(val)
#if HAVE_LONG_LONG
-long long
+LONG_LONG
rb_num2ll(val)
VALUE val;
{
@@ -879,13 +879,13 @@ rb_num2ll(val)
rb_raise(rb_eTypeError, "no implicit conversion from nil");
}
- if (FIXNUM_P(val)) return (long long)FIX2LONG(val);
+ if (FIXNUM_P(val)) return (LONG_LONG)FIX2LONG(val);
switch (TYPE(val)) {
case T_FLOAT:
if (RFLOAT(val)->value <= (double)LLONG_MAX
&& RFLOAT(val)->value >= (double)LLONG_MIN) {
- return (long long)(RFLOAT(val)->value);
+ return (LONG_LONG)(RFLOAT(val)->value);
}
else {
char buf[24];
@@ -914,14 +914,14 @@ rb_num2ll(val)
}
}
-unsigned long long
+unsigned LONG_LONG
rb_num2ull(val)
VALUE val;
{
if (TYPE(val) == T_BIGNUM) {
return rb_big2ull(val);
}
- return (unsigned long long)rb_num2ll(val);
+ return (unsigned LONG_LONG)rb_num2ll(val);
}
#endif /* HAVE_LONG_LONG */
diff --git a/ruby.h b/ruby.h
index a399511f59b..12b373948b9 100644
--- a/ruby.h
+++ b/ruby.h
@@ -90,15 +90,23 @@ typedef unsigned long ID;
# ifdef LONG_LONG_MAX
# define LLONG_MAX LONG_LONG_MAX
# else
+# ifdef _I64_MAX
+# define LLONG_MAX _I64_MAX
+# else
/* assuming 64bit(2's complement) long long */
-# define LLONG_MAX 9223372036854775807LL
+# define LLONG_MAX 9223372036854775807LL
+# endif
# endif
# endif
# ifndef LLONG_MIN
# ifdef LONG_LONG_MIN
# define LLONG_MIN LONG_LONG_MIN
# else
-# define LLONG_MIN (-LLONG_MAX-1)
+# ifdef _I64_MIN
+# define LLONG_MIN _I64_MAX
+# else
+# define LLONG_MIN (-LLONG_MAX-1)
+# endif
# endif
# endif
#endif
@@ -120,9 +128,9 @@ VALUE rb_uint2inum _((unsigned long));
#define rb_uint_new(v) rb_uint2inum(v)
#if HAVE_LONG_LONG
-VALUE rb_ll2inum _((long long));
+VALUE rb_ll2inum _((LONG_LONG));
#define LL2NUM(v) rb_ll2inum(v)
-VALUE rb_ull2inum _((unsigned long long));
+VALUE rb_ull2inum _((unsigned LONG_LONG));
#define ULL2NUM(v) rb_ull2inum(v)
#endif
@@ -233,8 +241,8 @@ int rb_fix2int _((VALUE));
#endif
#if HAVE_LONG_LONG
-long long rb_num2ll _((VALUE));
-unsigned long long rb_num2ull _((VALUE));
+LONG_LONG rb_num2ll _((VALUE));
+unsigned LONG_LONG rb_num2ull _((VALUE));
# define NUM2LL(x) (FIXNUM_P(x)?FIX2LONG(x):rb_num2ll((VALUE)x))
#endif