WordPtr,IntPtr,IntMax,WordMax

Simon Marlow simonmarhaskell at gmail.com
Tue May 9 05:27:02 EDT 2006


John Meacham wrote:
> On Thu, Apr 06, 2006 at 04:28:01PM -0700, John Meacham wrote:
> 
>>I was curious if ghc could support the following basic types, they will
>>likely just be aliases of existing types.
>>
>>WordPtr uintptr_t
>>WordMax uintmax_t
>>IntPtr  intptr_t
>>IntMax  intmax_t
>>
>>all these C types are defined by ISO C so should be available,
>>otherwise, they are easy enough to generate in ghcs autoconf script.
>>
>>jhc provides these under these names in Data.Word and Data.Int.
>>they would be useful for writing jhc/ghc portable low level code, and
>>writing 32/64 bit safe code.
> 
> 
> oh, I forgot the all important conversion routines,
> 
> ptrToWordPtr :: Ptr a -> WordPtr
> wordPtrToPtr :: WordPtr -> Ptr a
> 
> ptrToIntPtr :: Ptr a -> IntPtr
> intPtrToPtr :: IntPtr -> Ptr a
> 
> jhc makes these available in Jhc.Addr, but if ghc decides to provide
> them in a common spot (Foreign.Ptr maybe?)
> 
> then I will have jhc follow suit.
> 
> I'd also propose these be added to the FFI standard.

I've added these to GHC, in Foreign.Ptr.  Also, I added the C types 
(CIntPtr, CUIntPtr, CIntMax, CUIntMax) to Foreign.C.Types.

Cheers,
	Simon


More information about the Glasgow-haskell-users mailing list