Ignore:
Timestamp:
Mar 21, 2008, 5:38:34 AM (13 years ago)
Author:
gb
Message:

Conditionalize some TIME/GET-INTERNAL-RUN-TIME stuff for win64.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/win64/lib/time.lisp

    r8738 r8837  
    6060;;; For now, if the time won't fit in a :time_t, use an arbitrary time
    6161;;; value to get the time zone and assume that DST was -not- in effect.
     62#-windows-target
    6263(defun get-timezone (time)
    6364  (let* ((toobig (not (typep time '(unsigned-byte
     
    7576            (values (floor (pref tm :tm.tm_gmtoff) -60)
    7677                    (unless toobig (not (zerop (pref tm :tm.tm_isdst)))))))))))
     78
     79#+windows-target
     80(defun get-timezone (time)
     81  (declare (ignore time))
     82  (rlet ((tzinfo #>TIME_ZONE_INFORMATION))
     83    (let* ((id (#_GetTimeZoneInformation tzinfo))
     84           (minutes-west (pref tzinfo #>TIME_ZONE_INFORMATION.Bias))
     85           (is-dst (= id #$TIME_ZONE_ID_DAYLIGHT)))
     86      (values (floor (+ minutes-west
     87                        (if is-dst
     88                          (pref tzinfo #>TIME_ZONE_INFORMATION.DaylightBias)
     89                          0)))
     90              is-dst))))
    7791
    7892
     
    209223  )
    210224
    211 (defun get-internal-run-time ()
    212   "Return the run time in the internal time format. (See
    213   INTERNAL-TIME-UNITS-PER-SECOND.) This is useful for finding CPU usage."
     225
     226(defun %internal-run-time ()
     227  ;; Returns user and system times in internal-time-units as multiple values.
     228  #-windows-target
    214229  (rlet ((usage :rusage))
    215230    (%%rusage usage)
     
    218233           (user-micros (pref usage :rusage.ru_utime.tv_usec))
    219234           (system-micros (pref usage :rusage.ru_stime.tv_usec)))
    220       (+ (* (+ user-seconds system-seconds) internal-time-units-per-second)
    221          (round (+ user-micros system-micros) (floor 1000000 internal-time-units-per-second))))))
     235      (values (+ (* user-seconds internal-time-units-per-second)
     236                 (round user-micros (floor 1000000 internal-time-units-per-second)))
     237              (+ (* system-seconds internal-time-units-per-second)
     238                 (round system-micros (floor 1000000 internal-time-units-per-second))))))
     239  #+windows-target
     240  (rlet ((start #>FILETIME)
     241         (end #>FILETIME)
     242         (kernel #>FILETIME)
     243         (user #>FILETIME))
     244    (#_GetProcessTimes (#_GetCurrentProcess) start end kernel user)
     245    (let* ((user-100ns (dpb (pref user #>FILETIME.dwHighDateTime)
     246                            (byte 32 32)
     247                            (pref user #>FILETIME.dwLowDateTime)))
     248           (kernel-100ns (dpb (pref kernel #>FILETIME.dwHighDateTime)
     249                            (byte 32 32)
     250                            (pref kernel #>FILETIME.dwLowDateTime)))
     251           (convert (floor 10000000 internal-time-units-per-second)))
     252      (values (floor user-100ns convert) (floor kernel-100ns convert)))))
     253
     254(defun get-internal-run-time ()
     255  "Return the run time in the internal time format. (See
     256  INTERNAL-TIME-UNITS-PER-SECOND.) This is useful for finding CPU usage."
     257  (multiple-value-bind (user sys) (%internal-run-time)
     258    (+ user sys)))
    222259
    223260
Note: See TracChangeset for help on using the changeset viewer.