Mercurial > core / lisp/ffi/uring/macs.lisp
changeset 698: |
96958d3eb5b0 |
parent: |
e5ee74cbc4bd
|
author: |
Richard Westhaver <ellis@rwest.io> |
date: |
Fri, 04 Oct 2024 22:04:59 -0400 |
permissions: |
-rw-r--r-- |
description: |
fixes |
1 ;;; uring/macs.lisp --- Macros 8 (defmacro defalien-int (name &body args) 10 (define-alien-routine ,name int ,@args) 11 (export '(,name) :uring))) 13 (defmacro def-with-ring (name &body args) 14 `(defalien-int ,name (ring (* (struct io-uring))) ,@args)) 16 (defvar *io-opcodes* nil) 18 (defmacro with-io-sqe ((var val) &body body) 19 `(with-alien ((,var io-uring-sqe ,val)) 22 (defmacro with-new-io-sqe (var &body body) 23 `(with-alien ((,var io-uring-sqe)) 26 (defmacro with-io-sqe-op ((var op val) &body body) 27 `(with-io-sqe (,var ,val) 28 (setf (slot ,var 'opcode) ,op) 32 (defmacro with-new-io-sqe-op ((var op) &body body) 33 `(with-new-io-sqe ,var 34 (setf (slot ,var 'opcode) ,op) 38 (defmacro with-io-cqe (var &body body) 39 `(with-alien ((,var io-uring-cqe)) 42 (defmacro with-io-uring ((var &optional val) &body body) 43 `(let ((,var ,(or val (make-alien io-uring)))) 46 (defmacro with-new-io-uring (var &body body) 47 `(with-alien ((,var io-uring)) 51 (defmacro def-io-op (val name slots &body builder) 52 "Define a wrapper for an io-uring opcode. This macro will create a 53 structure class with NAME and SLOTS. BUILDER is the body of the BUILD 54 method for this struct, with CONST bound to VAR." 55 (let ((struct-name (symbolicate "IO-OP-" name)) 56 (const-name (symbolicate "+IO-" name "+")) 57 (alien-name (symbolicate "IORING-OP-" name))) 59 (defconstant ,const-name ,val) 60 (defstruct ,struct-name ,@slots) 61 (defmethod build-from ((self ,struct-name) (from system-area-pointer) &key &allow-other-keys) 62 (with-io-sqe-op (sqe ,const-name (sap-alien from (struct io-uring-sqe))) 64 (pushnew ',alien-name *io-opcodes*) 65 (export '(,struct-name ,(symbolicate "MAKE-" struct-name) ,const-name ,alien-name)))))