times.
/* -*-C-*-
-$Id: dosenv.c,v 1.2 1992/10/21 00:02:44 jinx Exp $
+$Id: dosenv.c,v 1.3 1993/01/12 19:48:36 gjr Exp $
-Copyright (c) 1992 Massachusetts Institute of Technology
+Copyright (c) 1992-1993 Massachusetts Institute of Technology
This material was developed by the Scheme project at the Massachusetts
Institute of Technology, Department of Electrical Engineering and
#include "osenv.h"
#include <stdlib.h>
\f
-void
-DEFUN (OS_current_time, (buffer), struct time_structure * buffer)
+time_t
+DEFUN_VOID (OS_encoded_time)
{
time_t t;
- struct tm * ts;
STD_UINT_SYSTEM_CALL (syscall_time, t, (DOS_time (0)));
+ return (t);
+}
+
+void
+DEFUN (OS_decode_time, (t, buffer), time_t t AND struct time_structure * buffer)
+{
+ struct tm * ts;
STD_PTR_SYSTEM_CALL (syscall_localtime, ts, (DOS_localtime (&t)));
(buffer -> year) = ((ts -> tm_year) + 1900);
(buffer -> month) = ((ts -> tm_mon) + 1);
}
}
+time_t
+DEFUN (OS_encode_time ,(buffer), struct time_structure * buffer)
+{
+ time_t t;
+ struct tm ts_s, * ts;
+ ts = &ts_s;
+ (ts -> tm_year) = ((buffer -> year) - 1900);
+ (ts -> tm_mon) = ((buffer -> month) - 1);
+ (ts -> tm_mday) = (buffer -> day);
+ (ts -> tm_hour) = (buffer -> hour);
+ (ts -> tm_min) = (buffer -> minute);
+ (ts -> tm_sec) = (buffer -> second);
+ {
+ /* In localtime() encoding, 0 is Sunday; in ours, it's Monday. */
+ int wday = (buffer -> day_of_week);
+ (ts -> tm_wday) = ((wday == 6) ? 0 : (wday + 1));
+ }
+ STD_UINT_SYSTEM_CALL (syscall_mktime, t, (DOS_mktime (ts)));
+ return (t);
+}
+
clock_t
DEFUN_VOID (OS_process_clock)
{
return (clock()*((clock_t) (1000/CLOCKS_PER_SEC)));
}
-\f
-
clock_t
DEFUN_VOID (OS_real_time_clock)
{
return (clock()*((clock_t) (1000/CLOCKS_PER_SEC)));
}
-
-
\f
/* Timer adjustments */
#define PC_TIMER_TICKS_PER_SECOND (18.2)
/* -*-C-*-
-$Id: osenv.h,v 1.2 1992/10/20 23:57:09 jinx Exp $
+$Id: osenv.h,v 1.3 1993/01/12 19:48:12 gjr Exp $
-Copyright (c) 1990-1992 Massachusetts Institute of Technology
+Copyright (c) 1990-1993 Massachusetts Institute of Technology
This material was developed by the Scheme project at the Massachusetts
Institute of Technology, Department of Electrical Engineering and
unsigned int day_of_week;
};
-extern void EXFUN (OS_current_time, (struct time_structure * ts));
+extern time_t EXFUN (OS_encoded_time, ());
+extern void EXFUN (OS_decode_time, (time_t, struct time_structure * ts));
+extern time_t EXFUN (OS_encode_time, (struct time_structure * ts));
extern clock_t EXFUN (OS_process_clock, (void));
extern clock_t EXFUN (OS_real_time_clock, (void));
extern void EXFUN (OS_process_timer_set, (clock_t first, clock_t interval));
/* -*-C-*-
-$Id: prosenv.c,v 1.7 1992/10/20 23:59:33 jinx Exp $
+$Id: prosenv.c,v 1.8 1993/01/12 19:48:19 gjr Exp $
-Copyright (c) 1987-1992 Massachusetts Institute of Technology
+Copyright (c) 1987-1993 Massachusetts Institute of Technology
This material was developed by the Scheme project at the Massachusetts
Institute of Technology, Department of Electrical Engineering and
#include "osenv.h"
#include "ostop.h"
\f
+/* This primitive is obsolete.
+ Left here for a while for compatibility purposes (booting old bands).
+ */
+
DEFINE_PRIMITIVE ("GET-DECODED-TIME", Prim_get_decoded_time, 1, 1,
"Return a vector with the current decoded time;\n\
arg TAG is used to tag the vector.\n\
The vector's elements are:\n\
#(TAG second minute hour day month year day-of-week)")
{
+ time_t t;
struct time_structure ts;
PRIMITIVE_HEADER (1);
- OS_current_time (&ts);
+
+ t = (OS_encoded_time ());
+ OS_decode_time (t, &ts);
{
SCHEME_OBJECT result = (allocate_marked_vector (TC_VECTOR, 8, 1));
FAST_VECTOR_SET (result, 0, (ARG_REF (1)));
PRIMITIVE_RETURN (result);
}
}
+\f
+DEFINE_PRIMITIVE ("ENCODED-TIME", Prim_encoded_time, 0, 0,
+ "Return the current time as an integer.")
+{
+ PRIMITIVE_RETURN (long_to_integer ((long) (OS_encoded_time ())));
+}
-DEFINE_PRIMITIVE ("CURRENT-YEAR", Prim_current_year, 0, 0,
- "This is an obsolete primitive; use `get-decoded-time' instead.")
+DEFINE_PRIMITIVE ("DECODE-TIME", Prim_decode_time, 2, 2,
+ "Fill a vector with the second argument decoded.\n\
+The vector's elements are:\n\
+ #(TAG second minute hour day month year day-of-week)")
{
+ SCHEME_OBJECT vec;
struct time_structure ts;
- PRIMITIVE_HEADER (0);
- OS_current_time (&ts);
- PRIMITIVE_RETURN (long_to_integer ((ts . year) - 1900));
-}
+ PRIMITIVE_HEADER (1);
-#define DATE_PRIMITIVE(element) \
-{ \
- struct time_structure ts; \
- PRIMITIVE_HEADER (0); \
- OS_current_time (&ts); \
- PRIMITIVE_RETURN (long_to_integer (ts . element)); \
+ vec = (VECTOR_ARG (1));
+ if ((VECTOR_LENGTH (vec)) != 8)
+ error_bad_range_arg (1);
+ OS_decode_time (((time_t) (arg_integer (2))), &ts);
+ FAST_VECTOR_SET (vec, 1, (long_to_integer (ts . second)));
+ FAST_VECTOR_SET (vec, 2, (long_to_integer (ts . minute)));
+ FAST_VECTOR_SET (vec, 3, (long_to_integer (ts . hour)));
+ FAST_VECTOR_SET (vec, 4, (long_to_integer (ts . day)));
+ FAST_VECTOR_SET (vec, 5, (long_to_integer (ts . month)));
+ FAST_VECTOR_SET (vec, 6, (long_to_integer (ts . year)));
+ FAST_VECTOR_SET (vec, 7, (long_to_integer (ts . day_of_week)));
+ PRIMITIVE_RETURN (UNSPECIFIC);
}
-DEFINE_PRIMITIVE ("CURRENT-MONTH", Prim_current_month, 0, 0,
- "This is an obsolete primitive; use `get-decoded-time' instead.")
- DATE_PRIMITIVE (month)
-
-DEFINE_PRIMITIVE ("CURRENT-DAY", Prim_current_day, 0, 0,
- "This is an obsolete primitive; use `get-decoded-time' instead.")
- DATE_PRIMITIVE (day)
-
-DEFINE_PRIMITIVE ("CURRENT-HOUR", Prim_current_hour, 0, 0,
- "This is an obsolete primitive; use `get-decoded-time' instead.")
- DATE_PRIMITIVE (hour)
-
-DEFINE_PRIMITIVE ("CURRENT-MINUTE", Prim_current_minute, 0, 0,
- "This is an obsolete primitive; use `get-decoded-time' instead.")
- DATE_PRIMITIVE (minute)
+DEFINE_PRIMITIVE ("ENCODE-TIME", Prim_encode_time, 1, 1,
+ "Return the file time corresponding to the time structure given.")
+{
+ SCHEME_OBJECT vec;
+ struct time_structure ts;
+ PRIMITIVE_HEADER (1);
-DEFINE_PRIMITIVE ("CURRENT-SECOND", Prim_current_second, 0, 0,
- "This is an obsolete primitive; use `get-decoded-time' instead.")
- DATE_PRIMITIVE (second)
+ vec = (VECTOR_ARG (1));
+ if ((VECTOR_LENGTH (vec)) != 8)
+ error_bad_range_arg (1);
+
+ ts.second = (integer_to_long (FAST_VECTOR_REF (vec, 1)));
+ ts.minute = (integer_to_long (FAST_VECTOR_REF (vec, 2)));
+ ts.hour = (integer_to_long (FAST_VECTOR_REF (vec, 3)));
+ ts.day = (integer_to_long (FAST_VECTOR_REF (vec, 4)));
+ ts.month = (integer_to_long (FAST_VECTOR_REF (vec, 5)));
+ ts.year = (integer_to_long (FAST_VECTOR_REF (vec, 6)));
+ ts.day_of_week = (integer_to_long (FAST_VECTOR_REF (vec, 7)));
+ PRIMITIVE_RETURN (long_to_integer ((long) (OS_encode_time (&ts))));
+}
\f
DEFINE_PRIMITIVE ("SYSTEM-CLOCK", Prim_system_clock, 0, 0,
"Return the current process time in units of milliseconds.")
/* -*-C-*-
-$Id: uxenv.c,v 1.8 1992/10/21 00:06:14 jinx Exp $
+$Id: uxenv.c,v 1.9 1993/01/12 19:48:31 gjr Exp $
-Copyright (c) 1990-1992 Massachusetts Institute of Technology
+Copyright (c) 1990-1993 Massachusetts Institute of Technology
This material was developed by the Scheme project at the Massachusetts
Institute of Technology, Department of Electrical Engineering and
#include "ux.h"
#include "osenv.h"
\f
-void
-DEFUN (OS_current_time, (buffer), struct time_structure * buffer)
+time_t
+DEFUN_VOID (OS_encoded_time)
{
time_t t;
- struct tm * ts;
STD_UINT_SYSTEM_CALL (syscall_time, t, (UX_time (0)));
+ return (t);
+}
+
+void
+DEFUN (OS_decode_time, (t, buffer), time_t t AND struct time_structure * buffer)
+{
+ struct tm * ts;
STD_PTR_SYSTEM_CALL (syscall_localtime, ts, (UX_localtime (&t)));
(buffer -> year) = ((ts -> tm_year) + 1900);
(buffer -> month) = ((ts -> tm_mon) + 1);
}
}
+time_t
+DEFUN (OS_encode_time ,(buffer), struct time_structure * buffer)
+{
+ time_t t;
+ struct tm ts_s, * ts;
+ ts = &ts_s;
+ (ts -> tm_year) = ((buffer -> year) - 1900);
+ (ts -> tm_mon) = ((buffer -> month) - 1);
+ (ts -> tm_mday) = (buffer -> day);
+ (ts -> tm_hour) = (buffer -> hour);
+ (ts -> tm_min) = (buffer -> minute);
+ (ts -> tm_sec) = (buffer -> second);
+#if 0
+ {
+ /* In localtime() encoding, 0 is Sunday; in ours, it's Monday. */
+ int wday = (buffer -> day_of_week);
+ (ts -> tm_wday) = ((wday == 6) ? 0 : (wday + 1));
+ }
+#else
+ (ts -> tm_wday) = 0;
+#endif
+ (ts -> tm_yday) = 0;
+ (ts -> tm_isdst) = -1; /* Let mktime figure it out */
+ STD_UINT_SYSTEM_CALL (syscall_mktime, t, (UX_mktime (ts)));
+ return (t);
+}
+\f
#ifdef HAVE_TIMES
static clock_t initial_process_clock;
/* -*-C-*-
-$Id: version.h,v 11.126 1993/01/12 10:43:22 cph Exp $
+$Id: version.h,v 11.127 1993/01/12 19:49:50 gjr Exp $
-Copyright (c) 1988-1992 Massachusetts Institute of Technology
+Copyright (c) 1988-1993 Massachusetts Institute of Technology
This material was developed by the Scheme project at the Massachusetts
Institute of Technology, Department of Electrical Engineering and
#define VERSION 11
#endif
#ifndef SUBVERSION
-#define SUBVERSION 126
+#define SUBVERSION 127
#endif
#| -*-Scheme-*-
-$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/runtime/datime.scm,v 14.3 1990/06/21 23:19:39 cph Rel $
+$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/runtime/datime.scm,v 14.4 1993/01/12 19:52:14 gjr Exp $
-Copyright (c) 1988, 1990 Massachusetts Institute of Technology
+Copyright (c) 1988-1993 Massachusetts Institute of Technology
This material was developed by the Scheme project at the Massachusetts
Institute of Technology, Department of Electrical Engineering and
(type vector)
(named decoded-time-structure-tag)
(conc-name decoded-time/)
- (constructor false))
+ (constructor make-decoded-time ()))
(second false read-only true)
(minute false read-only true)
(hour false read-only true)
(year false read-only true)
(day-of-week false read-only true))
+(define (decode-time time)
+ (let ((result (make-decoded-time)))
+ ((ucode-primitive decode-time 2) result time)
+ result))
+
+(define (encode-time dt)
+ ((ucode-primitive encode-time 1) dt))
+
+(define (get-time)
+ ((ucode-primitive encoded-time 0)))
+
(define (get-decoded-time)
- ((ucode-primitive get-decoded-time 1) decoded-time-structure-tag))
+ (decode-time (get-time)))
(define (decoded-time/date-string time)
(string-append
/* -*-C-*-
-$Id: version.h,v 11.126 1993/01/12 10:43:22 cph Exp $
+$Id: version.h,v 11.127 1993/01/12 19:49:50 gjr Exp $
-Copyright (c) 1988-1992 Massachusetts Institute of Technology
+Copyright (c) 1988-1993 Massachusetts Institute of Technology
This material was developed by the Scheme project at the Massachusetts
Institute of Technology, Department of Electrical Engineering and
#define VERSION 11
#endif
#ifndef SUBVERSION
-#define SUBVERSION 126
+#define SUBVERSION 127
#endif