[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: macro FIXNUM_OVERFLOW_P in lisp.h is valid ?
From: |
Toru TSUNEYOSHI |
Subject: |
Re: macro FIXNUM_OVERFLOW_P in lisp.h is valid ? |
Date: |
Sun, 25 Oct 2009 20:30:12 +0900 |
I revised the macro.
(My former macro may be problematic on 64-bit platforms.)
Probably, the following is no problems in 64-bit platforms, I think.
/* citation from mktime.c ---> */
#ifndef CHAR_BIT
# define CHAR_BIT 8
#endif
/* The extra casts work around common compiler bugs. */
#define TYPE_SIGNED(t) (! ((t) 0 < (t) -1))
/* The outer cast is needed to work around a bug in Cray C 5.0.3.0.
It is necessary at least when t == time_t. */
#define TYPE_MINIMUM(t) ((t) (TYPE_SIGNED (t) \
? ~ (t) 0 << (sizeof (t) * CHAR_BIT - 1) : (t) 0))
#define TYPE_MAXIMUM(t) ((t) (~ (t) 0 - TYPE_MINIMUM (t)))
/* <--- citation from mktime.c */
#ifndef EMACS_INT_MIN
# define EMACS_INT_MIN TYPE_MINIMUM (EMACS_INT)
#endif
#ifndef EMACS_INT_MAX
# define EMACS_INT_MAX TYPE_MAXIMUM (EMACS_INT)
#endif
#define FIXNUM_OVERFLOW_P(i) \
((i) < 0 \
? (i) < EMACS_INT_MIN || (EMACS_INT)(i) < MOST_NEGATIVE_FIXNUM \
: (i) > EMACS_INT_MAX || (EMACS_INT)(i) > MOST_POSITIVE_FIXNUM)
- Re: macro FIXNUM_OVERFLOW_P in lisp.h is valid ?, (continued)
Re: macro FIXNUM_OVERFLOW_P in lisp.h is valid ?, Stefan Monnier, 2009/10/23