+;;; FIXME, KLUDGE: GET-TIME-OF-DAY used to be UNIX-GETTIMEOFDAY, and had a
+;;; primary return value indicating sucess, and also returned timezone
+;;; information -- though the timezone data was not there on Darwin.
+;;; Now we have GET-TIME-OF-DAY, but it turns out that despite SB-UNIX being
+;;; an implementation package UNIX-GETTIMEOFDAY has users in the wild.
+;;; So we're stuck with it for a while -- maybe delete it towards the end
+;;; of 2009.
+(defun unix-gettimeofday ()
+ (multiple-value-bind (sec usec) (get-time-of-day)
+ (values t sec usec nil nil)))
+\f
+;;;; opendir, readdir, closedir, and dirent-name
+
+(declaim (inline unix-opendir))
+(defun unix-opendir (namestring &optional (errorp t))
+ (let ((dir (alien-funcall
+ (extern-alien "sb_opendir"
+ (function system-area-pointer c-string))
+ namestring)))
+ (if (zerop (sap-int dir))
+ (when errorp (simple-perror
+ (format nil "Error opening directory ~S"
+ namestring)))
+ dir)))
+
+(declaim (inline unix-readdir))
+(defun unix-readdir (dir &optional (errorp t) namestring)
+ (let ((ent (alien-funcall
+ (extern-alien "sb_readdir"
+ (function system-area-pointer system-area-pointer))
+ dir)))
+ (if (zerop (sap-int ent))
+ (when errorp (simple-perror
+ (format nil "Error reading directory entry~@[ from ~S~]"
+ namestring)))
+ ent)))
+
+(declaim (inline unix-closedir))
+(defun unix-closedir (dir &optional (errorp t) namestring)
+ (let ((r (alien-funcall
+ (extern-alien "sb_closedir" (function int system-area-pointer))
+ dir)))
+ (if (minusp r)
+ (when errorp (simple-perror
+ (format nil "Error closing directory~@[ ~S~]"
+ namestring)))
+ r)))
+
+(declaim (inline unix-dirent-name))
+(defun unix-dirent-name (ent)
+ (alien-funcall
+ (extern-alien "sb_dirent_name" (function c-string system-area-pointer))
+ ent))
+\f