{
return ((((double) (clock ())) * 1000.0) / ((double) CLOCKS_PER_SEC));
}
+
+clock_t
+OS_current_jiffy (void)
+{
+ return (clock ());
+}
+
+clock_t
+OS_jiffies_per_second (void)
+{
+ return (CLOCKS_PER_SEC);
+}
\f
/* The timers are all the same.
This just provides three distinct timers.
extern void OS_real_timer_clear (void);
extern const char * OS_working_dir_pathname (void);
extern void OS_set_working_dir_pathname (const char *);
+extern clock_t OS_current_jiffy (void);
+extern clock_t OS_jiffies_per_second (void);
#endif /* SCM_OSENV_H */
PRIMITIVE_RETURN (double_to_integer (OS_real_time_clock ()));
}
+DEFINE_PRIMITIVE ("CURRENT-JIFFY", Prim_current_jiffy, 0, 0, 0)
+{
+ PRIMITIVE_HEADER (0);
+ clock_t n = (OS_current_jiffy ());
+ PRIMITIVE_RETURN ((n < 0) ? SHARP_F : (intmax_to_integer (n)));
+}
+
+DEFINE_PRIMITIVE ("JIFFIES-PER-SECOND", Prim_jiffies_per_second, 0, 0, 0)
+{
+ PRIMITIVE_HEADER (0);
+ PRIMITIVE_RETURN (intmax_to_integer (OS_jiffies_per_second ()));
+}
+
DEFINE_PRIMITIVE ("PROCESS-TIMER-CLEAR", Prim_process_timer_clear, 0, 0,
"Turn off the process timer.")
{
#endif /* HAVE_TIMES */
#endif /* HAVE_GETTIMEOFDAY */
+
+/* current-jiffy and jiffies-per-second */
+
+#ifdef HAVE_TIMES
+
+clock_t
+OS_current_jiffy (void)
+{
+ struct tms buffer;
+ return (UX_times (&buffer));
+}
+
+clock_t
+OS_jiffies_per_second (void)
+{
+#ifdef __APPLE__
+ return (CLK_TCK);
+#else
+ return (CLOCKS_PER_SEC);
+#endif
+}
+
+#else /* not HAVE_TIMES */
+
+clock_t
+OS_current_jiffy (void)
+{
+ return (clock ());
+}
+
+clock_t
+OS_jiffies_per_second (void)
+{
+ return (CLOCKS_PER_SEC);
+}
+
+#endif /* HAVE_TIMES */
\f
#ifdef HAVE_SETITIMER
(files "sysclk")
(parent (runtime))
(export ()
+ current-jiffy
internal-time/seconds->ticks
internal-time/ticks->seconds
+ jiffies-per-second
measure-interval
process-time-clock
real-time-clock
(define (reset-system-clock!)
(set! offset-time (process-time-clock))
- (set! non-runtime 0))
+ (set! non-runtime 0)
+ unspecific)
+
+(define current-jiffy (ucode-primitive current-jiffy 0))
+(define jiffies-per-second (ucode-primitive jiffies-per-second 0))
(define offset-time)
(define non-runtime)
(process->system-time (- (process-time-clock) non-runtime)))
(define (increment-non-runtime! ticks)
- (set! non-runtime (+ non-runtime ticks)))
+ (set! non-runtime (+ non-runtime ticks))
+ unspecific)
(define (measure-interval runtime? thunk)
(let ((start (process-time-clock)))