What do you mean by raw memory? I don't think the volatile should be
needed in general for C allocated variables, but perhaps you are
writing to hardware registers?
John
On Fri, Feb 22, 2013 at 5:11 AM, Kiwamu Okabe
Hi.
I think poke function should use volatile on C language side. If not, the code created with jhc cannot write raw memory.
diff --git a/src/C/FromGrin2.hs b/src/C/FromGrin2.hs index 46e1a08..d4508bd 100644 --- a/src/C/FromGrin2.hs +++ b/src/C/FromGrin2.hs @@ -712,7 +712,7 @@ convertPrim p vs ty | (Poke t) <- p, [v,x] <- vs = do v' <- convertVal v x' <- convertVal x - return $ expressionRaw ("*((" <> (opTyToC' t) <+> "*)" <> (parens $ renderG v') <> text ") = " <> renderG x') + return $ expressionRaw ("*((volatile " <> (opTyToC' t) <+> "*)" <> (parens $ renderG v') <> text ") = " <> renderG x') | (AddrOf _ t) <- p, [] <- vs = do rt <- convertTypes ty return . cast rt $ expressionRaw ('&':unpackPS t)
I found it when use jhc to program Cortex-M3.
https://gitorious.org/metasepi/demo-cortex-m3
Regards, -- Kiwamu Okabe
_______________________________________________ jhc mailing list jhc@haskell.org http://www.haskell.org/mailman/listinfo/jhc