* ash rewrite
@ 2005-01-27 22:48 Kevin Ryde
2005-01-27 22:50 ` Kevin Ryde
2005-02-09 21:29 ` Rob Browning
0 siblings, 2 replies; 8+ messages in thread
From: Kevin Ryde @ 2005-01-27 22:48 UTC (permalink / raw)
I checked in my rewrite of ash, it should be much faster than using
integer-expt.
{
long bits_to_shift;
bits_to_shift = scm_to_long (cnt);
if (SCM_I_INUMP (n))
{
long nn = SCM_I_INUM (n);
if (bits_to_shift > 0)
{
/* Left shift of bits_to_shift >= SCM_I_FIXNUM_BIT-1 will always
overflow a non-zero fixnum. For smaller shifts we check the
bits going into positions above SCM_I_FIXNUM_BIT-1. If they're
all 0s for nn>=0, or all 1s for nn<0 then there's no overflow.
Those bits are "nn >> (SCM_I_FIXNUM_BIT-1 -
bits_to_shift)". */
if (nn == 0)
return n;
if (bits_to_shift < SCM_I_FIXNUM_BIT-1
&& ((unsigned long)
(SCM_SRS (nn, (SCM_I_FIXNUM_BIT-1 - bits_to_shift)) + 1)
<= 1))
{
return SCM_I_MAKINUM (nn << bits_to_shift);
}
else
{
SCM result = scm_i_long2big (nn);
mpz_mul_2exp (SCM_I_BIG_MPZ (result), SCM_I_BIG_MPZ (result),
bits_to_shift);
return result;
}
}
else
{
bits_to_shift = -bits_to_shift;
if (bits_to_shift >= SCM_LONG_BIT)
return (nn >= 0 ? SCM_I_MAKINUM (0) : SCM_I_MAKINUM(-1));
else
return SCM_I_MAKINUM (SCM_SRS (nn, bits_to_shift));
}
}
else if (SCM_BIGP (n))
{
SCM result;
if (bits_to_shift == 0)
return n;
result = scm_i_mkbig ();
if (bits_to_shift >= 0)
{
mpz_mul_2exp (SCM_I_BIG_MPZ (result), SCM_I_BIG_MPZ (n),
bits_to_shift);
return result;
}
else
{
/* GMP doesn't have an fdiv_q_2exp variant returning just a long, so
we have to allocate a bignum even if the result is going to be a
fixnum. */
mpz_fdiv_q_2exp (SCM_I_BIG_MPZ (result), SCM_I_BIG_MPZ (n),
-bits_to_shift);
return scm_i_normbig (result);
}
}
else
{
SCM_WRONG_TYPE_ARG (SCM_ARG1, n);
}
}
_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-devel
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: ash rewrite
2005-01-27 22:48 ash rewrite Kevin Ryde
@ 2005-01-27 22:50 ` Kevin Ryde
2005-02-09 21:29 ` Rob Browning
1 sibling, 0 replies; 8+ messages in thread
From: Kevin Ryde @ 2005-01-27 22:50 UTC (permalink / raw)
Forgot to say, inexacts and fractions are no longer supported. They
used to work for left shifts because that was done with a multiply,
but they never worked for right shifts.
I don't think they'll be missed, the other bit-oriented functions in
the same section of the manual only take exact integers.
_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-devel
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: ash rewrite
2005-01-27 22:48 ash rewrite Kevin Ryde
2005-01-27 22:50 ` Kevin Ryde
@ 2005-02-09 21:29 ` Rob Browning
2005-02-09 22:16 ` Kevin Ryde
2005-02-09 22:33 ` primitive-fork hang (was: ash rewrite) Kevin Ryde
1 sibling, 2 replies; 8+ messages in thread
From: Rob Browning @ 2005-02-09 21:29 UTC (permalink / raw)
Kevin Ryde <user42@zip.com.au> writes:
> I checked in my rewrite of ash, it should be much faster than using
> integer-expt.
Hmm I noticed that at least on my machine, make check fails with
current CVS. I don't know if it's related, and haven't had a chance
to investigate further:
Running fractions.test
ERROR: fractions.test: fractions: (eqv? (ash 1/2 0) 1/2) - arguments: ((wrong-type-arg "ash" "Wrong type argument in position ~A: ~S" (1 1/2) (1/2)))
ERROR: fractions.test: fractions: (eqv? (ash 1/2 1) 1) - arguments: ((wrong-type-arg "ash" "Wrong type argument in position ~A: ~S" (1 1/2) (1/2)))
Running gc.test
--
Rob Browning
rlb @defaultvalue.org and @debian.org; previously @cs.utexas.edu
GPG starting 2002-11-03 = 14DD 432F AE39 534D B592 F9A0 25C8 D377 8C7E 73A4
_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-devel
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: ash rewrite
2005-02-09 21:29 ` Rob Browning
@ 2005-02-09 22:16 ` Kevin Ryde
2005-02-09 22:33 ` primitive-fork hang (was: ash rewrite) Kevin Ryde
1 sibling, 0 replies; 8+ messages in thread
From: Kevin Ryde @ 2005-02-09 22:16 UTC (permalink / raw)
Cc: guile-devel
Rob Browning <rlb@defaultvalue.org> writes:
>
> Hmm I noticed that at least on my machine, make check fails with
> current CVS.
Thanks, I'll remove those.
> ERROR: fractions.test: fractions: (eqv? (ash 1/2 0) 1/2) - arguments: ((wrong-type-arg "ash" "Wrong type argument in position ~A: ~S" (1 1/2) (1/2)))
> ERROR: fractions.test: fractions: (eqv? (ash 1/2 1) 1) - arguments: ((wrong-type-arg "ash" "Wrong type argument in position ~A: ~S" (1 1/2) (1/2)))
ash had worked to left shift a fraction, because it was done with a
multiply. It never right shifted a fraction.
My change unified that, by making neither left nor right work :-).
There'd be nothing wrong with having ash support fractions, or
inexacts for that matter. But it seemed to me a bit of a slippery
slope. You might start thinking other of the "Bitwise Operations"
functions should also work on those. Like logbit? or logand. They'd
have sensible definitions on fractions and inexacts, but it'd be a bit
like hard work implementing it.
_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-devel
^ permalink raw reply [flat|nested] 8+ messages in thread
* primitive-fork hang (was: ash rewrite)
2005-02-09 21:29 ` Rob Browning
2005-02-09 22:16 ` Kevin Ryde
@ 2005-02-09 22:33 ` Kevin Ryde
2005-02-28 1:50 ` primitive-fork hang Marius Vollmer
1 sibling, 1 reply; 8+ messages in thread
From: Kevin Ryde @ 2005-02-09 22:33 UTC (permalink / raw)
Cc: guile-devel
Rob Browning <rlb@defaultvalue.org> writes:
>
> Hmm I noticed that at least on my machine, make check fails with
> current CVS.
Speaking of check fails, primitive-fork has stopped working for me,
making popen.test (and any actual use of popen) hang. Eg.
guile -c '(pk (primitive-fork)) (force-output) (sleep 10)'
It should print 0 in the child and some pid in the parent, but only
the parent prints. Dunno why, it had worked up until recently.
_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-devel
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: primitive-fork hang
2005-02-09 22:33 ` primitive-fork hang (was: ash rewrite) Kevin Ryde
@ 2005-02-28 1:50 ` Marius Vollmer
2005-02-28 22:03 ` Kevin Ryde
0 siblings, 1 reply; 8+ messages in thread
From: Marius Vollmer @ 2005-02-28 1:50 UTC (permalink / raw)
Kevin Ryde <user42@zip.com.au> writes:
> Speaking of check fails, primitive-fork has stopped working for me,
> making popen.test (and any actual use of popen) hang. Eg.
>
> guile -c '(pk (primitive-fork)) (force-output) (sleep 10)'
>
> It should print 0 in the child and some pid in the parent, but only
> the parent prints. Dunno why, it had worked up until recently.
What is the status of this? Does it still fail for you?
--
GPG: D5D4E405 - 2F9B BCCC 8527 692A 04E3 331E FAF8 226A D5D4 E405
_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-devel
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: primitive-fork hang
2005-02-28 1:50 ` primitive-fork hang Marius Vollmer
@ 2005-02-28 22:03 ` Kevin Ryde
2005-03-08 17:05 ` Marius Vollmer
0 siblings, 1 reply; 8+ messages in thread
From: Kevin Ryde @ 2005-02-28 22:03 UTC (permalink / raw)
Cc: guile-devel
Marius Vollmer <mvo@zagadka.de> writes:
>
> Does it still fail for you?
Yes. I'm not sure if it's something I've done. I had trouble getting
gdb to show anything.
_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-devel
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: primitive-fork hang
2005-02-28 22:03 ` Kevin Ryde
@ 2005-03-08 17:05 ` Marius Vollmer
0 siblings, 0 replies; 8+ messages in thread
From: Marius Vollmer @ 2005-03-08 17:05 UTC (permalink / raw)
Kevin Ryde <user42@zip.com.au> writes:
> Marius Vollmer <mvo@zagadka.de> writes:
>>
>> Does it still fail for you?
>
> Yes. I'm not sure if it's something I've done. I had trouble getting
> gdb to show anything.
I remember seeing strange blocking as well, and I think it was because
some pipe wasn't being closed properly in the parent or child. That
open pipe prevented one of the parties from seeing EOF, or something
like that.
_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-devel
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2005-03-08 17:05 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-01-27 22:48 ash rewrite Kevin Ryde
2005-01-27 22:50 ` Kevin Ryde
2005-02-09 21:29 ` Rob Browning
2005-02-09 22:16 ` Kevin Ryde
2005-02-09 22:33 ` primitive-fork hang (was: ash rewrite) Kevin Ryde
2005-02-28 1:50 ` primitive-fork hang Marius Vollmer
2005-02-28 22:03 ` Kevin Ryde
2005-03-08 17:05 ` Marius Vollmer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).