;;;; -*- coding: utf-8; -*-
-changes in sbcl-0.9.18 (1.0.beta?) relative to sbcl-0.9.16:
+changes in sbcl-0.9.18 (1.0.beta?) relative to sbcl-0.9.17:
+ * enhancement: SB-POSIX now supports cfsetispeed(3), cfsetospeed(3),
+ cfgetispeed(3), cfgetospeed(3), and related constants. (thanks to
+ Max-Gerd Retzlaff)
* bug fix: two potential GC deadlocks affecting threaded builds.
* bug fix: (TYPEP #\A '(NOT (MEMBER #\" #\{ #\:))) now correctly
returns T (reported by Anton Kazennikov)
collect (ldiff slotd (member :array-length slotd)))
,@options)
(declaim (inline ,to-alien ,to-protocol))
+ (declaim (inline ,to-protocol ,to-alien))
(defun ,to-protocol (alien &optional instance)
(declare (type (sb-alien:alien (* ,alien-type)) alien)
(type (or null ,name) instance))
(export 'tcsetattr :sb-posix)
(declaim (inline tcsetattr))
(defun tcsetattr (fd actions termios)
+ (declare (type termios termios))
(with-alien-termios a-termios ()
(termios-to-alien termios a-termios)
(let ((fd (file-descriptor fd)))
(export 'tcgetattr :sb-posix)
(declaim (inline tcgetattr))
(defun tcgetattr (fd &optional termios)
+ (declare (type (or null termios) termios))
(with-alien-termios a-termios ()
(let ((r (alien-funcall
(extern-alien "tcgetattr"
(when (minusp r)
(syscall-error))
(setf termios (alien-to-termios a-termios termios))))
- termios))
+ termios)
+ (export 'cfsetispeed :sb-posix)
+ (declaim (inline cfsetispeed))
+ (defun cfsetispeed (speed &optional termios)
+ (declare (type (or null termios) termios))
+ (with-alien-termios a-termios ()
+ (let ((r (alien-funcall
+ (extern-alien "cfsetispeed"
+ (function int (* alien-termios) speed-t))
+ a-termios
+ speed)))
+ (when (minusp r)
+ (syscall-error))
+ (setf termios (alien-to-termios a-termios termios))))
+ termios)
+ (export 'cfsetospeed :sb-posix)
+ (declaim (inline cfsetospeed))
+ (defun cfsetospeed (speed &optional termios)
+ (declare (type (or null termios) termios))
+ (with-alien-termios a-termios ()
+ (let ((r (alien-funcall
+ (extern-alien "cfsetospeed"
+ (function int (* alien-termios) speed-t))
+ a-termios
+ speed)))
+ (when (minusp r)
+ (syscall-error))
+ (setf termios (alien-to-termios a-termios termios))))
+ termios)
+ (export 'cfgetispeed :sb-posix)
+ (declaim (inline cfgetispeed))
+ (defun cfgetispeed (termios)
+ (declare (type termios termios))
+ (with-alien-termios a-termios ()
+ (termios-to-alien termios a-termios)
+ (alien-funcall (extern-alien "cfgetispeed"
+ (function speed-t (* alien-termios)))
+ a-termios)))
+ (export 'cfgetospeed :sb-posix)
+ (declaim (inline cfgetospeed))
+ (defun cfgetospeed (termios)
+ (declare (type termios termios))
+ (with-alien-termios a-termios ()
+ (termios-to-alien termios a-termios)
+ (alien-funcall (extern-alien "cfgetospeed"
+ (function speed-t (* alien-termios)))
+ a-termios))))
;;; environment
;; make sure that we found something
(not (sb-posix:getpwnam "root"))
nil)
+
+#+nil
+;; Requires root or special group + plus a sensible thing on the port
+(deftest cfget/setispeed.1
+ (with-open-file (s "/dev/ttyS0")
+ (let* ((termios (sb-posix:tcgetattr s))
+ (old (sb-posix:cfgetispeed termios))
+ (new (if (= old sb-posix:b2400)
+ sb-posix:b9600
+ sb-posix:b2400)))
+ (sb-posix:cfsetispeed new termios)
+ (sb-posix:tcsetattr 0 sb-posix:tcsadrain termios)
+ (setf termios (sb-posix:tcgetattr s))
+ (= new (sb-posix:cfgetispeed termios))))
+ t)
+
+#+nil
+;; Requires root or special group + a sensible thing on the port
+(deftest cfget/setospeed.1
+ (with-open-file (s "/dev/ttyS0" :direction :output :if-exists :append)
+ (let* ((termios (sb-posix:tcgetattr s))
+ (old (sb-posix:cfgetospeed termios))
+ (new (if (= old sb-posix:b2400)
+ sb-posix:b9600
+ sb-posix:b2400)))
+ (sb-posix:cfsetospeed new termios)
+ (sb-posix:tcsetattr 0 sb-posix:tcsadrain termios)
+ (setf termios (sb-posix:tcgetattr 0))
+ (= new (sb-posix:cfgetospeed termios))))
+ t)