summaryrefslogtreecommitdiffstats
path: root/ffi.h
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2021-08-22 20:39:25 -0700
committerKaz Kylheku <kaz@kylheku.com>2021-08-22 20:39:25 -0700
commita37665e615c504415d5425f71ce5af7b7175b3f2 (patch)
treea78c05024c377578245e9b7d5b7d2f399091f45f /ffi.h
parentf88ab97c627291952ca39a6cdada6c923caed0a4 (diff)
downloadtxr-a37665e615c504415d5425f71ce5af7b7175b3f2.tar.gz
txr-a37665e615c504415d5425f71ce5af7b7175b3f2.tar.bz2
txr-a37665e615c504415d5425f71ce5af7b7175b3f2.zip
ffi: provide mmap through carray.
* configure: configure test for mmap depositing HAVE_MMAP into config.h. * ffi.c (struct carray): Subject to HAVE_MMAP, new mm_len member which keeps track of the size of an underlying mapping so that we can unmap it, as well as peform operations like msync on it. (make_carray): Initialize mm_len to 0. (MAP_GROWSDOWN, MAP_LOCKED, MAP_NORESERVE, MAP_POPULATE, MAP_NONBLOCK, MAP_STACK, MAP_HUGETLB, MAP_SHARED, MAP_PRIVATE, MAP_FIXED, MAP_ANON, MAP_HUGE_SHIFT, MAP_HUGE_MASK, PROT_READ, PROT_WRITE, PROT_EXEC, PROT_NONE, PROT_GROWSDOWN, PROT_GROWSUP, MADV_NORMAL, MADV_RANDOM, MADV_SEQUENTIAL, MADV_WILLNEED, MADV_DONTNEED, MADV_FREE, MADV_REMOVE, MADV_DONTFORK, MADV_DOFORK, MADV_MERGEABLE, MADV_UNMERGEABLE, MADV_HUGEPAGE, MADV_NOHUGEPAGE, MADV_DONTDUMP, MADV_DODUMP, MADV_WIPEONFORK, MADV_KEEPONFORK, MADV_HWPOISON, MS_ASYNC, MS_SYNC, MS_INVALIDATE): #define as 0 if missing. (carray_munmap_op): New static function. (carray_mmap_ops): New static structure. (mmap_wrap, munmap_wrap): New functions. (mmap_op): New static function. (mprotect_wrap, madvise_wrap, msync_wrap): New functions. (ffi_init): Register mmap, munmap, mprotect, madvise and msync as well as numerous integer variables: map-growsdown, map-locked, map-noreserve, map-populate, map-nonblock, map-stack, map-hugetlb, map-shared, map-private, map-fixed, map-anon, map-huge-shift, map-huge-mask, prot-read, prot-write, prot-exec, prot-none, prot-growsdown, prot-growsup, madv-normal, madv-random, madv-sequential, madv-willneed, madv-dontneed, madv-free, madv-remove, madv-dontfork, madv-dofork, madv-mergeable, madv-unmergeable, madv-hugepage, madv-nohugepage, madv-dontdump, madv-dodump, madv-wipeonfork, madv-keeponfork, madv-hwpoison, ms-async, ms-sync, ms-invalidate, page-size. * ffi.h (mmap_wrap, munmap_wrap, mprotect_wrap madvise_wrap, msync_wrap): Declared. * tests/017/mmap.tl: New file. * txr.1: Documented. * stdlib/doc-syms.tl: Updated.
Diffstat (limited to 'ffi.h')
-rw-r--r--ffi.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/ffi.h b/ffi.h
index a0adb0e0..fbc9faad 100644
--- a/ffi.h
+++ b/ffi.h
@@ -129,6 +129,14 @@ val uint_carray(val carray);
val int_carray(val carray);
val put_carray(val carray, val offs, val stream);
val fill_carray(val carray, val offs, val stream);
+#if HAVE_MMAP
+val mmap_wrap(val type, val len, val prot, val flags,
+ val source_opt, val offset_opt, val addr_opt);
+val munmap_wrap(val carray);
+val mprotect_wrap(val carray, val prot, val offset, val size);
+val madvise_wrap(val carray, val advice, val offset, val size);
+val msync_wrap(val carray, val flags, val offset, val size);
+#endif
mem_t *union_get_ptr(val self, val uni);
val make_union(val type, val init, val memb);
val union_members(val uni);