diff --git a/io-multiplex/common.lisp b/io-multiplex/common.lisp index 508bf76f..a2305122 100644 --- a/io-multiplex/common.lisp +++ b/io-multiplex/common.lisp @@ -205,7 +205,7 @@ (call-next-method event-base :only-once only-once)) (defun recalculate-timeouts (timeouts) - (let ((now (get-monotonic-time))) + (let ((now (nix:get-monotonic-time))) (dolist (ev (queue-head timeouts)) (event-recalc-abs-timeout ev now)))) @@ -233,7 +233,7 @@ (and only-once (setf exit-p t))) (setf (values deletion-list dispatch-list) (filter-expired-events (expired-events timeouts - (get-monotonic-time)))) + (nix:get-monotonic-time)))) (dispatch-timeouts dispatch-list) (remove-events event-base deletion-list) (queue-sort timeouts #'< #'event-abs-timeout))))) @@ -284,7 +284,7 @@ have been received, NIL otherwise." (values deletion-list dispatch-list))) (defun events-calc-min-rel-timeout (timeouts) - (let* ((now (get-monotonic-time)) + (let* ((now (nix:get-monotonic-time)) (first-valid-event (find-if #'(lambda (to) (or (null to) (< now to))) (queue-head timeouts) diff --git a/io-multiplex/time.lisp b/io-multiplex/time.lisp index e132df65..45d91505 100644 --- a/io-multiplex/time.lisp +++ b/io-multiplex/time.lisp @@ -23,67 +23,6 @@ (in-package :io.multiplex) -;;;; Monotonic Time - -#-(or darwin windows) -(defun get-monotonic-time () - (multiple-value-bind (sec nsec) - (nix:clock-gettime nix:clock-monotonic) - (+ sec (/ nsec 1d9)))) - -;;; No sure if GetTickCount() has all of the desired properties. -;;; Also, it'd be better to use GetTickCount64() but that's -;;; Vista-only. So, FIXME: need to check for overflow. -#+windows -(progn - (load-foreign-library "Kernel32.dll") - - (defctype bool (:boolean :int)) - (defctype large-integer :int64) - - (defcfun ("QueryPerformanceCounter" query-perf-counter :cconv :stdcall) - bool - (count :pointer)) - - (defun get-monotonic-time () - (with-foreign-object (ptr 'large-integer) - (assert (query-perf-counter ptr)) - (mem-ref ptr 'large-integer)))) - -#+darwin -(progn - (defctype mach-kern-return :int) - (defctype mach-clock-res :int) - (defctype mach-clock-id :int) - (defctype mach-port :unsigned-int) ; not sure - (defctype mach-clock-serv mach-port) - - (defconstant +mach-kern-success+ 0) - (defconstant +mach-system-clock+ 0) - - (defcstruct mach-timespec - (tv-sec :unsigned-int) - (tv-nsec mach-clock-res)) - - (defcfun "mach_host_self" mach-port) - - (defcfun "host_get_clock_service" mach-kern-return - (host mach-port) - (id mach-clock-id) - (clock-name (:pointer mach-clock-serv))) - - (defcfun "clock_get_time" mach-kern-return - (clock-serv mach-clock-serv) - (cur-time mach-timespec)) - - (defun get-monotonic-time () - (with-foreign-object (clock 'mach-clock-serv) - (host-get-clock-service (mach-host-self) +mach-system-clock+ clock) - (with-foreign-object (time 'mach-timespec) - (clock-get-time (mem-ref clock :int) time) - (with-foreign-slots ((tv-sec tv-nsec) time mach-timespec) - (+ tv-sec (/ tv-nsec 1d9))))))) - ;;;; Timeouts (deftype timeout () @@ -110,7 +49,7 @@ (defun abs-timeout (timeout) (when timeout - (+ (get-monotonic-time) (normalize-timeout timeout)))) + (+ (nix:get-monotonic-time) (normalize-timeout timeout)))) (defun calc-min-timeout (t1 t2) (if t1 diff --git a/sockets/common.lisp b/sockets/common.lisp index 4ea9abb8..39da8db9 100644 --- a/sockets/common.lisp +++ b/sockets/common.lisp @@ -102,13 +102,13 @@ ;;;; Constructors for SOCKADDR_* structs -(defun make-sockaddr-in (sin ub8-vector &optional (port 0)) - (declare (type ipv4-array ub8-vector) (type ub16 port)) +(defun make-sockaddr-in (sin ub8-vector &optional (portno 0)) + (declare (type ipv4-array ub8-vector) (type ub16 portno)) (bzero sin size-of-sockaddr-in) (with-foreign-slots ((family addr port) sin sockaddr-in) (setf family af-inet) (setf addr (htonl (vector-to-integer ub8-vector))) - (setf port (htons port))) + (setf port (htons portno))) (values sin)) (defmacro with-sockaddr-in ((var address &optional (port 0)) &body body) @@ -116,13 +116,13 @@ (make-sockaddr-in ,var ,address ,port) ,@body)) -(defun make-sockaddr-in6 (sin6 ub16-vector &optional (port 0)) - (declare (type ipv6-array ub16-vector) (type ub16 port)) +(defun make-sockaddr-in6 (sin6 ub16-vector &optional (portno 0)) + (declare (type ipv6-array ub16-vector) (type ub16 portno)) (bzero sin6 size-of-sockaddr-in6) (with-foreign-slots ((family addr port) sin6 sockaddr-in6) (setf family af-inet6) (copy-simple-array-ub16-to-alien-vector ub16-vector addr) - (setf port (htons port))) + (setf port (htons portno))) (values sin6)) (defmacro with-sockaddr-in6 ((var address &optional port) &body body) diff --git a/tests/net.sockets-tests.lisp b/tests/net.sockets-tests.lisp index 63fe8772..bbc4563d 100644 --- a/tests/net.sockets-tests.lisp +++ b/tests/net.sockets-tests.lisp @@ -415,7 +415,7 @@ :type nil :defaults (asdf:system-definition-pathname - (asdf:find-system '#:bsd-sockets-tests)))))) + (asdf:find-system '#:net.sockets-tests)))))) (ignore-errors (delete-file file)) (with-socket (p :family :local :connect :passive :local-filename file) (with-socket (a :family :local :remote-filename file)