[GHC] #8299: Add richer data model address arithmetic: AddrDiff and AddrInt (ie d Int_ptr_diff and Int_ptr_size)

GHC ghc-devs at haskell.org
Sun Sep 15 01:59:06 CEST 2013


#8299: Add richer data model address arithmetic: AddrDiff and AddrInt (ie d
Int_ptr_diff and Int_ptr_size)
----------------------------+----------------------------------------------
        Reporter:  carter   |            Owner:
            Type:  feature  |           Status:  new
  request                   |        Milestone:  7.10.1
        Priority:  high     |          Version:  7.6.3
       Component:           |         Keywords:
  Compiler                  |     Architecture:  Unknown/Multiple
      Resolution:           |       Difficulty:  Project (more than a week)
Operating System:           |       Blocked By:
  Unknown/Multiple          |  Related Tickets:
 Type of failure:           |
  None/Unknown              |
       Test Case:           |
        Blocking:  8287     |
----------------------------+----------------------------------------------

Comment (by rwbarton):

 On point 2:

 It seems to me that the current Foreign.Ptr API
 {{{
 plusPtr :: Ptr a -> Int -> Ptr b
 minusPtr :: Ptr a -> Ptr b -> Int
 }}}
 pretty much forces `Int` to be the same size as a C pointer, on any
 architecture. For a real x32 executable, this would mean 32-bit `Int`,
 while for a "fake x32" mode which maintains a heap below 4G and stores
 heap pointers as 4 bytes, but otherwise is a normal x86_64 executable,
 this would mean 64-bit `Int`. There doesn't seem to be a good reason why
 the `Int` used for normal arithmetic, and used to count things in data
 structures like `Map`, should be tied to that C pointer size.

 As a matter of fact, an appropriate replacement for those `Int`s in
 Foreign.Ptr already exists in Foreign.C.Types: `CPtrdiff`, "Haskell type
 representing the C `ptrdiff_t` type".

-- 
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/8299#comment:1>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler



More information about the ghc-tickets mailing list