mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-05-20 19:50:24 +02:00
* inline.h (scm_double_cell): prevent reordering of statements
with any following code (for GCC 3 strict-aliasing). * numbers.c (scm_make_real), num2float.i.c (FLOAT2NUM): removed the earlier version of the reordering prevention.
This commit is contained in:
parent
c15030bebf
commit
3553e1d1f0
4 changed files with 30 additions and 14 deletions
|
@ -1,3 +1,10 @@
|
||||||
|
2002-09-24 Gary Houston <ghouston@arglist.com>
|
||||||
|
|
||||||
|
* inline.h (scm_double_cell): prevent reordering of statements
|
||||||
|
with any following code (for GCC 3 strict-aliasing).
|
||||||
|
* numbers.c (scm_make_real), num2float.i.c (FLOAT2NUM): removed
|
||||||
|
the earlier version of the reordering prevention.
|
||||||
|
|
||||||
2002-09-19 Han-Wen Nienhuys <hanwen@cs.uu.nl>
|
2002-09-19 Han-Wen Nienhuys <hanwen@cs.uu.nl>
|
||||||
|
|
||||||
* inline.h (scm_double_cell): move SET_GCMARK set out of if body.
|
* inline.h (scm_double_cell): move SET_GCMARK set out of if body.
|
||||||
|
|
|
@ -213,6 +213,26 @@ scm_double_cell (scm_t_bits car, scm_t_bits cbr,
|
||||||
/* see above. */
|
/* see above. */
|
||||||
SCM_SET_GC_MARK (z);
|
SCM_SET_GC_MARK (z);
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* When this function is inlined, it's possible that the last
|
||||||
|
SCM_GC_SET_CELL_WORD above will be adjacent to a following
|
||||||
|
initialization of z. E.g., it occurred in scm_make_real. GCC
|
||||||
|
from around version 3 (e.g., certainly 3.2) began taking
|
||||||
|
advantage of strict C aliasing rules which say that it's OK to
|
||||||
|
interchange the initialization above and the one below when the
|
||||||
|
pointer types appear to differ sufficiently. We don't want that,
|
||||||
|
of course. GCC allows this behaviour to be disabled with the
|
||||||
|
-fno-strict-aliasing option, but would also need to be supplied
|
||||||
|
by Guile users. Instead, the following statements prevent the
|
||||||
|
reordering.
|
||||||
|
*/
|
||||||
|
#ifdef __GNUC__
|
||||||
|
asm volatile ("" : : : "memory");
|
||||||
|
#else
|
||||||
|
/* portable version, just in case any other compiler does the same
|
||||||
|
thing. */
|
||||||
|
scm_remember_upto_here_1 (z);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return z;
|
return z;
|
||||||
|
|
|
@ -31,12 +31,8 @@ NUM2FLOAT (SCM num, unsigned long int pos, const char *s_caller)
|
||||||
SCM
|
SCM
|
||||||
FLOAT2NUM (FTYPE n)
|
FLOAT2NUM (FTYPE n)
|
||||||
{
|
{
|
||||||
SCM z;
|
SCM z = scm_double_cell (scm_tc16_real, 0, 0, 0);
|
||||||
z = scm_double_cell (scm_tc16_real, 0, 0, 0);
|
|
||||||
/*
|
|
||||||
See scm_make_real().
|
|
||||||
*/
|
|
||||||
scm_remember_upto_here_1 (z);
|
|
||||||
SCM_REAL_VALUE (z) = n;
|
SCM_REAL_VALUE (z) = n;
|
||||||
return z;
|
return z;
|
||||||
}
|
}
|
||||||
|
|
|
@ -3013,15 +3013,8 @@ SCM_DEFINE (scm_string_to_number, "string->number", 1, 1, 0,
|
||||||
SCM
|
SCM
|
||||||
scm_make_real (double x)
|
scm_make_real (double x)
|
||||||
{
|
{
|
||||||
SCM z;
|
SCM z = scm_double_cell (scm_tc16_real, 0, 0, 0);
|
||||||
z = scm_double_cell (scm_tc16_real, 0, 0, 0);
|
|
||||||
|
|
||||||
/*
|
|
||||||
scm_double_cell is inlined. strict C aliasing rules say that it's
|
|
||||||
OK to interchange the initialization above and the one below. We
|
|
||||||
don't want that, of course.
|
|
||||||
*/
|
|
||||||
scm_remember_upto_here_1 (z);
|
|
||||||
SCM_REAL_VALUE (z) = x;
|
SCM_REAL_VALUE (z) = x;
|
||||||
return z;
|
return z;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue