X-Git-Url: http://git.kpe.io/?a=blobdiff_plain;f=tests%2Ftime.lisp;fp=tests%2Ftime.lisp;h=8e45adadee65039e6981b32360b28ab1cd862049;hb=72190043201239567658cfbae1c36bbd7233419b;hp=9d9546364243e08e53deb1d7409f8e304efae311;hpb=da9ef130a96ba9102fc0cf68b1fe8cd0a90e67b7;p=uffi.git diff --git a/tests/time.lisp b/tests/time.lisp index 9d95463..8e45ada 100644 --- a/tests/time.lisp +++ b/tests/time.lisp @@ -30,7 +30,7 @@ ;; gmoffset present on SusE SLES9 (gmoffset :long)) -(uffi:def-function ("time" c-time) +(uffi:def-function ("time" c-time) ((time (* time-t))) :returning time-t) @@ -56,16 +56,16 @@ (setf (uffi:deref-pointer time :unsigned-long) 7381) (let ((tm-ptr (the tm-pointer (gmtime time)))) (values (1+ (uffi:get-slot-value tm-ptr 'tm 'mon)) - (uffi:get-slot-value tm-ptr 'tm 'mday) - (+ 1900 (uffi:get-slot-value tm-ptr 'tm 'year)) - (uffi:get-slot-value tm-ptr 'tm 'hour) - (uffi:get-slot-value tm-ptr 'tm 'min) - (uffi:get-slot-value tm-ptr 'tm 'sec) - ))) + (uffi:get-slot-value tm-ptr 'tm 'mday) + (+ 1900 (uffi:get-slot-value tm-ptr 'tm 'year)) + (uffi:get-slot-value tm-ptr 'tm 'hour) + (uffi:get-slot-value tm-ptr 'tm 'min) + (uffi:get-slot-value tm-ptr 'tm 'sec) + ))) 1 1 1970 2 3 1) -(uffi:def-struct timeval +(uffi:def-struct timeval (secs :long) (usecs :long)) @@ -73,29 +73,29 @@ (minutes-west :int) (dsttime :int)) -(uffi:def-function ("gettimeofday" c-gettimeofday) +(uffi:def-function ("gettimeofday" c-gettimeofday) ((tv (* timeval)) (tz (* timezone))) :returning :int) - + (defun get-utime () (uffi:with-foreign-object (tv 'timeval) (let ((res (c-gettimeofday tv (uffi:make-null-pointer 'timezone)))) (values (+ (* 1000000 (uffi:get-slot-value tv 'timeval 'secs)) - (uffi:get-slot-value tv 'timeval 'usecs)) + (uffi:get-slot-value tv 'timeval 'usecs)) res)))) (deftest :timeofday.1 (multiple-value-bind (t1 res1) (get-utime) (multiple-value-bind (t2 res2) (get-utime) - (and (or (= t2 t1) (> t2 t1)) - (> t1 1000000000) - (> t2 1000000000) - (zerop res1) - (zerop res2)))) + (and (or (= t2 t1) (> t2 t1)) + (> t1 1000000000) + (> t2 1000000000) + (zerop res1) + (zerop res2)))) t) - + (defun posix-time-to-asctime (secs) "Converts number of seconds elapsed since 00:00:00 on January 1, 1970, Coordinated Universal Time (UTC)" (string-right-trim