HCoop
/
bpt
/
guile.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Avoid undefined behavior regarding signed integers and left shifts.
[bpt/guile.git]
/
libguile
/
vm-i-scheme.c
diff --git
a/libguile/vm-i-scheme.c
b/libguile/vm-i-scheme.c
index
fc32ec5
..
587aa95
100644
(file)
--- a/
libguile/vm-i-scheme.c
+++ b/
libguile/vm-i-scheme.c
@@
-1,4
+1,5
@@
-/* Copyright (C) 2001, 2009, 2010, 2011, 2012, 2013 Free Software Foundation, Inc.
+/* Copyright (C) 2001, 2009, 2010, 2011, 2012, 2013,
+ * 2014 Free Software Foundation, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
@@
-236,10
+237,12
@@
VM_DEFINE_FUNCTION (149, ge, "ge?", 2)
#if SCM_GNUC_PREREQ (4, 5) && (defined __x86_64__ || defined __i386__)
# undef _CX
#if SCM_GNUC_PREREQ (4, 5) && (defined __x86_64__ || defined __i386__)
# undef _CX
-# if
def __x86_64__
+# if
SIZEOF_VOID_P == 8
# define _CX "rcx"
# define _CX "rcx"
-# el
se
+# el
if SIZEOF_VOID_P == 4
# define _CX "ecx"
# define _CX "ecx"
+# else
+# error unsupported word size
# endif
/* The macros below check the CPU's overflow flag to improve fixnum
# endif
/* The macros below check the CPU's overflow flag to improve fixnum
@@
-503,7
+506,9
@@
VM_DEFINE_FUNCTION (159, ash, "ash", 2)
&& ((scm_t_bits)
(SCM_SRS (nn, (SCM_I_FIXNUM_BIT-1 - bits_to_shift)) + 1)
<= 1))
&& ((scm_t_bits)
(SCM_SRS (nn, (SCM_I_FIXNUM_BIT-1 - bits_to_shift)) + 1)
<= 1))
- RETURN (SCM_I_MAKINUM (nn << bits_to_shift));
+ RETURN (SCM_I_MAKINUM (nn < 0
+ ? -(-nn << bits_to_shift)
+ : (nn << bits_to_shift)));
/* fall through */
}
/* fall through */
/* fall through */
}
/* fall through */