1 ;;;; -*- Mode: Lisp; Syntax: ANSI-Common-Lisp; indent-tabs-mode: nil -*-
3 ;;; --- Miscellaneous utilities.
6 (in-package :io.multiplex
)
8 (defun timeout->timeval
(timeout tv
)
9 (with-foreign-slots ((sec usec
) tv timeval
)
10 (multiple-value-bind (%sec %usec
) (decode-timeout timeout
)
14 (defun timeout->timespec
(timeout ts
)
15 (with-foreign-slots ((sec nsec
) ts timespec
)
16 (multiple-value-bind (%sec %usec
) (decode-timeout timeout
)
18 nsec
(* 1000 %usec
)))))
20 (defun timeout->milisec
(timeout)
22 (multiple-value-bind (sec usec
) (decode-timeout timeout
)
24 (truncate usec
1000)))
27 (defmacro ignore-and-print-errors
(&body body
)
28 `(handler-case (locally ,@body
)
30 (warn "Caught a ~A: ~A, ignoring it."
31 (type-of error
) error
))))