Skip to content

Commit

Permalink
Fix misc post-merge breakage.
Browse files Browse the repository at this point in the history
  • Loading branch information
luismbo committed Aug 4, 2007
1 parent 885aa24 commit cd0ca6c
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 72 deletions.
6 changes: 3 additions & 3 deletions io-multiplex/common.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -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))))

Expand Down Expand Up @@ -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)))))
Expand Down Expand Up @@ -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)
Expand Down
63 changes: 1 addition & 62 deletions io-multiplex/time.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -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 ()
Expand All @@ -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
Expand Down
12 changes: 6 additions & 6 deletions sockets/common.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -102,27 +102,27 @@

;;;; 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)
`(with-foreign-object (,var 'sockaddr-in)
(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)
Expand Down
2 changes: 1 addition & 1 deletion tests/net.sockets-tests.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit cd0ca6c

Please sign in to comment.