mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-05-20 11:40:18 +02:00
* numbers.h: Removed old comment about using SCM_CAR to access
non-pair cells. (SCM_MOST_POSITIVE_FIXNUM, SCM_MOST_NEGATIVE_FIXNUM): Make sure the return value is signed. Thanks to Brian Crowder for the bug report. (SCM_SRS): Avoid unnecessary casting and don't unpack input values. With this patch, SCM_SRS can be safely used for other types than scm_t_signed_bits. However, it should still better be an internal macro and thus be renamed to SCM_I_SRS. (SCM_MAKINUM, SCM_INUM): Use proper casting.
This commit is contained in:
parent
74e0de864b
commit
14282d0f5c
3 changed files with 30 additions and 16 deletions
1
THANKS
1
THANKS
|
@ -11,5 +11,6 @@ For fixes or providing information which led to a fix:
|
|||
|
||||
Martin Baulig
|
||||
Rob Browning
|
||||
Brian Crowder
|
||||
Christopher Cramer
|
||||
John Goerzen
|
||||
|
|
|
@ -1,3 +1,19 @@
|
|||
2001-10-05 Dirk Herrmann <D.Herrmann@tu-bs.de>
|
||||
|
||||
* numbers.h: Removed old comment about using SCM_CAR to access
|
||||
non-pair cells.
|
||||
|
||||
(SCM_MOST_POSITIVE_FIXNUM, SCM_MOST_NEGATIVE_FIXNUM): Make sure
|
||||
the return value is signed. Thanks to Brian Crowder for the bug
|
||||
report.
|
||||
|
||||
(SCM_SRS): Avoid unnecessary casting and don't unpack input
|
||||
values. With this patch, SCM_SRS can be safely used for other
|
||||
types than scm_t_signed_bits. However, it should still better be
|
||||
an internal macro and thus be renamed to SCM_I_SRS.
|
||||
|
||||
(SCM_MAKINUM, SCM_INUM): Use proper casting.
|
||||
|
||||
2001-10-03 Gary Houston <ghouston@arglist.com>
|
||||
|
||||
* continuations.h, unif.h: in the descriptions of the bit patterns
|
||||
|
|
|
@ -51,39 +51,36 @@
|
|||
|
||||
|
||||
|
||||
/* Immediate Numbers
|
||||
/* Immediate Numbers, also known as fixnums
|
||||
*
|
||||
* Inums are exact integer data that fits within an SCM word.
|
||||
*
|
||||
* SCM_INUMP applies only to values known to be Scheme objects.
|
||||
* In particular, SCM_INUMP (SCM_CAR (x)) is valid only if x is known
|
||||
* to be a SCM_CONSP. If x is only known to be a non-immediate,
|
||||
* SCM_INUMP (SCM_CAR (x)) can give wrong answers.
|
||||
*/
|
||||
* Inums are exact integer data that fits within an SCM word. */
|
||||
|
||||
#define SCM_I_FIXNUM_BIT (SCM_LONG_BIT - 2)
|
||||
#define SCM_MOST_POSITIVE_FIXNUM ((1L << (SCM_I_FIXNUM_BIT - 1)) - 1)
|
||||
#define SCM_MOST_NEGATIVE_FIXNUM (-SCM_MOST_POSITIVE_FIXNUM - 1)
|
||||
#define SCM_I_FIXNUM_BIT \
|
||||
(SCM_LONG_BIT - 2)
|
||||
#define SCM_MOST_POSITIVE_FIXNUM \
|
||||
((((scm_t_signed_bits) 1) << (SCM_I_FIXNUM_BIT - 1)) - 1)
|
||||
#define SCM_MOST_NEGATIVE_FIXNUM \
|
||||
(-((scm_t_signed_bits) SCM_MOST_POSITIVE_FIXNUM) - 1)
|
||||
|
||||
|
||||
/* SCM_SRS is signed right shift */
|
||||
#if (-1 == (((-1) << 2) + 2) >> 2)
|
||||
# define SCM_SRS(x, y) ((scm_t_signed_bits)(x) >> (y))
|
||||
# define SCM_SRS(x, y) ((x) >> (y))
|
||||
#else
|
||||
# define SCM_SRS(x, y) ((SCM_UNPACK (x) < 0) ? ~((~SCM_UNPACK (x)) >> (y)) : (SCM_UNPACK (x) >> (y)))
|
||||
# define SCM_SRS(x, y) ((x) < 0 ? ~((~(x)) >> (y)) : ((x) >> (y)))
|
||||
#endif /* (-1 == (((-1) << 2) + 2) >> 2) */
|
||||
|
||||
|
||||
#define SCM_INUMP(x) (2 & SCM_UNPACK (x))
|
||||
#define SCM_NINUMP(x) (!SCM_INUMP (x))
|
||||
#define SCM_MAKINUM(x) (SCM_PACK (((x) << 2) + 2L))
|
||||
#define SCM_INUM(x) ((scm_t_signed_bits)(SCM_SRS (SCM_UNPACK (x), 2)))
|
||||
#define SCM_MAKINUM(x) (SCM_PACK ((((scm_t_signed_bits) (x)) << 2) + 2))
|
||||
#define SCM_INUM(x) (SCM_SRS ((scm_t_signed_bits) SCM_UNPACK (x), 2))
|
||||
|
||||
|
||||
/* SCM_FIXABLE is true if its long argument can be encoded in an SCM_INUM. */
|
||||
#define SCM_POSFIXABLE(n) ((n) <= SCM_MOST_POSITIVE_FIXNUM)
|
||||
#define SCM_NEGFIXABLE(n) ((n) >= SCM_MOST_NEGATIVE_FIXNUM)
|
||||
#define SCM_FIXABLE(n) (SCM_POSFIXABLE(n) && SCM_NEGFIXABLE(n))
|
||||
#define SCM_FIXABLE(n) (SCM_POSFIXABLE (n) && SCM_NEGFIXABLE (n))
|
||||
|
||||
|
||||
/* A name for 0. */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue