summaryrefslogtreecommitdiffstats
path: root/share
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2017-06-02 18:57:48 -0700
committerKaz Kylheku <kaz@kylheku.com>2017-06-02 18:57:48 -0700
commit8d52205b778c41e438192c5bc4187edd679fbdfd (patch)
tree9f082467fa66bac00206adf2fee0d04bb753b284 /share
parentabbc0d00006c3126b9d1cf8150c21f4a8c56089a (diff)
downloadtxr-8d52205b778c41e438192c5bc4187edd679fbdfd.tar.gz
txr-8d52205b778c41e438192c5bc4187edd679fbdfd.tar.bz2
txr-8d52205b778c41e438192c5bc4187edd679fbdfd.zip
ffi: functions and macros for basic type properties.
* ffi.c (ffi_alignof, ffi_offsetof, ffi_arraysize, ffi_elemsize, ffi_elemtype): New functions. (ffi_init): Registered intrinsics ffi-alignof, ffi-offsetof, ffi-arraysize, ffi-elemsize, ffi-elemtype. * ffi.h (ffi_alignof, ffi_offsetof, ffi_arraysize, ffi_elemsize, ffi_elemtype): Declared. * lisplib.c (ffi_set_entries): New autoload entries alignof, offsetof, arraysize, elemsize, elemtype. * share/txr/stdlib/ffi.tl (alignof, offsetof, arraysize, elemsize, elemtype): New macros. * txr.1: Documented new functions and macros.
Diffstat (limited to 'share')
-rw-r--r--share/txr/stdlib/ffi.tl15
1 files changed, 15 insertions, 0 deletions
diff --git a/share/txr/stdlib/ffi.tl b/share/txr/stdlib/ffi.tl
index 69a19a1e..da29c1e5 100644
--- a/share/txr/stdlib/ffi.tl
+++ b/share/txr/stdlib/ffi.tl
@@ -114,6 +114,21 @@
(defmacro sizeof (type)
(ffi-size (ffi-type-compile type)))
+(defmacro alignof (type)
+ (ffi-alignof (ffi-type-compile type)))
+
+(defmacro offsetof (struct memb)
+ (ffi-offsetof (ffi-type-compile struct) memb))
+
+(defmacro arraysize (arr)
+ (ffi-arraysize (ffi-type-compile arr)))
+
+(defmacro elemtype (type)
+ ^(ffi-elemtype (ffi-type-compile ',type)))
+
+(defmacro elemsize (type)
+ (ffi-elemsize (ffi-type-compile type)))
+
(defmacro ffi (type)
^(ffi-type-compile ',type))