nullary _ffi's
Stephen Weeks
MLton@sourcelight.com
Thu, 2 Nov 2000 14:17:47 -0800 (PST)
There is a difference between the way the C and native backends are handling
nullary ffi's, and an inconsistency (in my eyes) in how the native backend is
handling them. My understanding is that an SML declaration like
val n = _ffi "FFI_INT": int;
corresponds to a C header declaration like
extern Int FFI_INT;
and a C file containing
Int FFI_INT = 13;
If I compile such an SML program (and print n) with the C backend, it works
fine. On the other hand, with the native backend, it fails. If I look at the
assembler, I see that the C backend is producing the statement
movl FFI_INT,%eax
On the other hand, the native backend is producing the statement
movl $FFI_INT,%eax
Both backends do the same (and correct) thing for nullary FFI's of type real, so
I conclude that something strange is happening in the native backend for nullary
FFI's of type int or pointer.
Any clues?