3 ms·
TXR Lisp: (defvarl TIOCGWINSZ #x5413) (typedef winsize (struct winsize (ws-row ushort) (ws-col ushort)
by kazinator 4y ago
TXR Lisp:
(defvarl TIOCGWINSZ #x5413)
(typedef winsize (struct winsize
(ws-row ushort)
(ws-col ushort)
(ws-xpixel ushort)
(ws-ypixel ushort)))
(with-dyn-lib nil
(deffi ioctl-winsz "ioctl" int (int ulong : (ptr-out winsize))))
Then:
$ txr -i winsz.tl
TXR doesn't really whip the llama's ass so much as the lambda's.
1> (let ((ws (new winsize)))
(ioctl-winsz 0 TIOCGWINSZ ws)
ws)
#S(winsize ws-row 37 ws-col 80 ws-xpixel 0 ws-ypixel 0)
- matheusmoreira 4y agoThat's amazing! I'll definifely look at it for inspiration. Am I correct in assuming that it depends on the C library for its system call support? The code seems to be a Lisp equivalent of: self = dlopen(NULL, flags); ioctl = dlsym(self, "ioctl"): I'd like to have system call support as a feature built right into eval. Maybe a JIT compiler that emits code with Linux system call calling conventions whenever eval encounters a (system-call ...) form. Do you know more low level Lisp systems?
- lispm 4y agoBasically all/most Common Lisp implementations have a foreign function interface. Those who run on some UNIX or Linux need support for low level access. See for example the SBCL sources for mmap and ioctl.