On Mon, May 18, 2015 at 12:49:09PM +0200, Peter Bex wrote:
> On Mon, May 18, 2015 at 12:39:36PM +0200, felix.winkelm...@bevuta.com wrote:
> > Another question: should "C_num_to_long" and "C_num_to_unsigned_long"
> > handle bignums? The same goes for "C_i_foreign_integer..." and
> > friends?
> 
> hm, they probably should.  I suppose I overlooked them.  I though
> only C_num_to_int was used.

I just pushed this, along with some tests, which exposed a few more bugs
which I also fixed:  I had forgotten to update the size calculations for
bignums after switching the representation to the new style where
bignums are strings wrapped inside records.  Also, the handling of
foreign return values of type int64 was incorrect on 32 bits.

Finally, while writing the tests, I noticed that the foreign argument
type stub converter functions only performed range checking for flonums,
but never for fixnums.  This can either be an oversight (assuming that if
it fits a fixnum, it will always fit an integer), or for performance.

If it's an oversight; it's wrong because a) unsigned types should not
allow negative values and b) "int" is smaller than C_word on 64-bit
machines, I think, so a fixnum can be larger than will fit an int.

If you agree, I can add this range checking and uncomment some of the
tests that I added.  I'm unsure about the CHICKEN 4 branch; do we want
to add this extra checking there as well?

Cheers,
Peter

Attachment: signature.asc
Description: Digital signature

_______________________________________________
Chicken-hackers mailing list
Chicken-hackers@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-hackers

Reply via email to