Changeset 15313


Ignore:
Timestamp:
Apr 10, 2012, 12:42:23 PM (8 years ago)
Author:
gb
Message:

Define and export CURRENT-TIME-IN-NANOSECONDS. Use CLOCK_MONOTONIC if available. Fixes ticket:924

Location:
trunk/source/lib
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/source/lib/ccl-export-syms.lisp

    r15311 r15313  
    472472     set-gc-notification-threshold
    473473     *pending-gc-notification-hook*
     474     current-time-in-nanoseconds
    474475     
    475476     population
  • trunk/source/lib/time.lisp

    r15304 r15313  
    285285    (+ user sys)))
    286286
    287 
    288 
    289 
    290 
    291      
     287#-(or darwin-target windows-target)
     288(defloadvar preferred-posix-clock-id
     289  (rlet ((ts :timespec))
     290    (if (eql 0 (#_clock_gettime #$CLOCK_MONOTONIC ts))
     291      #$CLOCK_MONOTONIC
     292      #$CLOCK_REALTIME)))   
     293
     294(defun current-time-in-nanoseconds ()
     295  #-(or darwin-target windows-target)
     296  (rlet ((ts :timespec))
     297    (#_clock_gettime preferred-posix-clock-id ts)
     298    (+ (* (pref ts :timespec.tv_sec) 1000000000)
     299       (pref ts :timespec.tv_nsec)))
     300  #+darwin-target (#_mach_absolute_time)
     301  #+windows-target
     302  (rlet ((time #>FILETIME))
     303    (#_GetSystemTimeAsFileTime time)
     304    (* (logior (pref time #>FILETIME.dwLowDateTime)
     305               (ash (pref time #>FILETIME.dwHighDateTime) 32))
     306       100)))
     307
Note: See TracChangeset for help on using the changeset viewer.