Hi!
I have been planning to work on GMP-issue [1] for a while, and
I finally got started :-) Before I continue committing
myself to certain choices, I'd like some optinions how I should
have done it ;-) Any feedback is appreciated.
My current modifications (darcs patches) are available over
http [2]. I managed to get stage 2 ghc compiled with them,
but it didn't work for anything much, probably because of
serialisation issues.
Which bignum library should be used?
* Choices I know of: OpenSSL [3] bignum and libtommath [4].
(I used libtommath up to now, but just because it is easier
to read and modify) Either license works for me, and
both are probably manageable.
Plan and action
* Configuration time option. (Rts-way seems overkill and is hard
to do because base lib needs modifications.)
* Add autotools/Makefile machinery for --enable-tommath
Causes UseTomMath to have value YES in Makefiles and
WANT_TOMMATH defined to 1 in headers.
* Primops and rts functionality
- Simple primops haven been replaced, but haven't been tested.
I am not familiar with C--, so all of my code is just copying
from other places in ghc sources.
Wierd:
* ghc/rts/linker.c has symbol tables for some (direct) GMP
symbols, wierd, are they for something important?
Compatibility notes (libtommath vs GMP):
* In GHC heap, tommath has similar presentation as before,
int with digits and sign bit, and bytearray containing digits.
* There's a lot of boring sign converting going as tommath's
mp_int keeps sign in separate int, no big deal tho.
* Tommath doesn't use all of one digit to present value, for
speed or simplicity reasons it leaves 4 bits space around, and
this breaks just about all existing binary conversions.
Not done:
* I didn't convert double and float stuff yet as I couldn't
understand it quick. (StgPrimFloat.c)
* Most of Int/Word <-> Integer conversions aren't working yet,
but they are probably mostly trivial.
* Memory handling is a bit ad-hoc right now, I modified both
rts and tommath.
* If it seems a good idea, all function names in bignum library
could be changed to something less clashy.
* libraries/base
- Given that all of primops are correct, numerical typeclasses work
as-is. But it would be much better to provide only
library-provided primops, and change definitions in base.
- Show etc serialisation (probably) needs to be done.
License comments are my layman interpretations, so you should consult
real lawyer etc :-)
[1] http://hackage.haskell.org/trac/ghc/ticket/601 - Replace GMP
[2] http://tamelambda.net/1-tommath.tar.gz (212 kb)
[3] http://www.openssl.org/ as part of ssl distribution comes bignum
library. License is BSD-style, requires acknowledgement.
[4] http://math.libtomcrypt.org/ License is public domain, which might
not be perfect in all countries.
Best regards,
-Esa
_______________________________________________
Cvs-ghc mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/cvs-ghc