darcs patch: Implementation of aton and ntoa outside ... (and 1 more)

Robert Marlow bobstopper at bobturf.org
Sun Oct 1 21:06:57 EDT 2006

On Fri, 2006-09-29 at 13:19 +0100, Simon Marlow wrote:
> inet_ntoa() uses a static buffer, so it isn't threadsafe.  So while the current 
> IO version is already broken, putting unsafePerformIO around it makes the 
> problem more likely to manifest, and harder to avoid.  We really need to do this 
> in Haskell code, I think.

I've attached a new revision of the earlier Data.Byte module I sent to
this list.

I've taken Bulat's suggestion on making flipEndian more efficient and
extended it so it should work with all word sizes as well as signed
types such as Ints.

The file also includes purely functional versions of aton and ntoa,
though a module named Data.Byte is the wrong place for them.

One problem is that aton and ntoa currently only work with ipv4
addresses. There should probably be versions for ipv6 and any others.
This doesn't seem to be a problem the current inet_addr and inet_ntoa
don't suffer from though.

A lot of the functions don't work with Integers due to a use of bitSize.

Robert Marlow <bobstopper at bobturf.org>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Byte.hs
Type: text/x-haskell
Size: 4845 bytes
Desc: not available
Url : http://www.haskell.org/pipermail/libraries/attachments/20061002/c942220a/Byte.bin

More information about the Libraries mailing list