Plan 9 from Bell Labs’s /usr/web/sources/contrib/fernan/nhc98/src/runtime/Builtin/cFFI.c

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


/* basic read/write from real memory locations, for primitive FFI */

#include "HsFFI.h"

#define ffi_write(T)	\
void	write##T##AtAddr (void* a, Hs##T d)	{ *(Hs##T*)a = d; }
#define ffi_read(T)	\
Hs##T	read##T##AtAddr  (void* a)		{ return *(Hs##T*)a; }

ffi_write(Char)
ffi_write(Int)
ffi_write(Float)
ffi_write(Double)
ffi_write(Addr)

ffi_read(Char)
ffi_read(Int)
ffi_read(Float)
ffi_read(Double)
ffi_read(Addr)

ffi_write(Int8)
ffi_write(Int16)
ffi_write(Int32)
ffi_write(Int64)
ffi_write(Word8)
ffi_write(Word16)
ffi_write(Word32)
ffi_write(Word64)

ffi_read(Int8)
ffi_read(Int16)
ffi_read(Int32)
ffi_read(Int64)
ffi_read(Word8)
ffi_read(Word16)
ffi_read(Word32)
ffi_read(Word64)


Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to webmaster@9p.io.