[Haskell-cafe] [Help] Trying to rewrite the NetBSD kernel usingHaskell language.

Donn Cave donn at avvanta.com
Mon Jan 20 16:27:55 UTC 2014

quoth Kiwamu Okabe>,
> static int
> auich_open(void *addr, int flags)
> {
>         struct auich_softc *sc;
>         sc = (struct auich_softc *)addr;
>         mutex_spin_exit(&sc->sc_intr_lock);
>         sc->codec_if->vtbl->lock(sc->codec_if);
> ~~~
> Note the line "sc->codec_if->vtbl->lock(sc->codec_if);".
> It traces pointer tree regionally.
> Haskell's Strorable class is not good for the use case,
> because it copies the entire pointer tree!

That suggests to me that you should change the class, so that
its Storable instance doesn't need to dereference the pointers -
that is, vtbl for example would be a Ptr type.  Though that would
not save you very much trouble in the present case.

Are you using hsc2hs?  Your example has a few things like "plusPtr
p offsetOf_Ac97CodecIf_vtbl" - where do you get that offsetOf_?
hsc2hs has a #peek macro that does this:

p_Ac97CodecIf_vtbl p = (#peek struct ac97codecxzy, vtbl) p
--  creates Haskell code
p_Ac97CodecIf_vtbl p = ((\ hsc_ptr -> peekByteOff hsc_ptr 96) p

Hope that may help a little!


More information about the Haskell-Cafe mailing list