extern Lisp_Object w32_get_internal_run_time (void);
#endif
-static Lisp_Object format_time_string (char const *, ptrdiff_t, EMACS_TIME,
+static Lisp_Object format_time_string (char const *, ptrdiff_t, struct timespec,
bool, struct tm *);
static int tm_diff (struct tm *, struct tm *);
static void update_buffer_properties (ptrdiff_t, ptrdiff_t);
picosecond counts. */)
(void)
{
- return make_lisp_time (current_emacs_time ());
+ return make_lisp_time (current_timespec ());
}
DEFUN ("get-internal-run-time", Fget_internal_run_time, Sget_internal_run_time,
usecs -= 1000000;
secs++;
}
- return make_lisp_time (make_emacs_time (secs, usecs * 1000));
+ return make_lisp_time (make_timespec (secs, usecs * 1000));
#else /* ! HAVE_GETRUSAGE */
#ifdef WINDOWSNT
return w32_get_internal_run_time ();
UNKNOWN_MODTIME_NSECS; in that case, the Lisp list contains a
correspondingly negative picosecond count. */
Lisp_Object
-make_lisp_time (EMACS_TIME t)
+make_lisp_time (struct timespec t)
{
- int ns = EMACS_NSECS (t);
- return make_time_tail (EMACS_SECS (t), list2i (ns / 1000, ns % 1000 * 1000));
+ int ns = t.tv_nsec;
+ return make_time_tail (t.tv_sec, list2i (ns / 1000, ns % 1000 * 1000));
}
/* Decode a Lisp list SPECIFIED_TIME that represents a time.
list, generate the corresponding time value.
If RESULT is not null, store into *RESULT the converted time;
- this can fail if the converted time does not fit into EMACS_TIME.
+ this can fail if the converted time does not fit into struct timespec.
If *DRESULT is not null, store into *DRESULT the number of
seconds since the start of the POSIX Epoch.
bool
decode_time_components (Lisp_Object high, Lisp_Object low, Lisp_Object usec,
Lisp_Object psec,
- EMACS_TIME *result, double *dresult)
+ struct timespec *result, double *dresult)
{
EMACS_INT hi, lo, us, ps;
if (! (INTEGERP (high) && INTEGERP (low)
/* Return the greatest representable time that is not greater
than the requested time. */
time_t sec = hi;
- *result = make_emacs_time ((sec << 16) + lo, us * 1000 + ps / 1000);
+ *result = make_timespec ((sec << 16) + lo, us * 1000 + ps / 1000);
}
else
{
/* Decode a Lisp list SPECIFIED_TIME that represents a time.
If SPECIFIED_TIME is nil, use the current time.
- Round the time down to the nearest EMACS_TIME value.
+ Round the time down to the nearest struct timespec value.
Return seconds since the Epoch.
Signal an error if unsuccessful. */
-EMACS_TIME
+struct timespec
lisp_time_argument (Lisp_Object specified_time)
{
- EMACS_TIME t;
+ struct timespec t;
if (NILP (specified_time))
- t = current_emacs_time ();
+ t = current_timespec ();
else
{
Lisp_Object high, low, usec, psec;
else
{
Lisp_Object high, low, usec, psec;
- EMACS_TIME t;
+ struct timespec t;
if (! (disassemble_lisp_time (specified_time, &high, &low, &usec, &psec)
&& decode_time_components (high, low, make_number (0),
make_number (0), &t, 0)))
error ("Invalid time specification");
- return EMACS_SECS (t);
+ return t.tv_sec;
}
}
double t;
if (NILP (specified_time))
{
- EMACS_TIME now = current_emacs_time ();
- t = EMACS_SECS (now) + EMACS_NSECS (now) / 1e9;
+ struct timespec now = current_timespec ();
+ t = now.tv_sec + now.tv_nsec / 1e9;
}
else
{
usage: (format-time-string FORMAT-STRING &optional TIME UNIVERSAL) */)
(Lisp_Object format_string, Lisp_Object timeval, Lisp_Object universal)
{
- EMACS_TIME t = lisp_time_argument (timeval);
+ struct timespec t = lisp_time_argument (timeval);
struct tm tm;
CHECK_STRING (format_string);
static Lisp_Object
format_time_string (char const *format, ptrdiff_t formatlen,
- EMACS_TIME t, bool ut, struct tm *tmp)
+ struct timespec t, bool ut, struct tm *tmp)
{
char buffer[4000];
char *buf = buffer;
ptrdiff_t size = sizeof buffer;
size_t len;
Lisp_Object bufstring;
- int ns = EMACS_NSECS (t);
+ int ns = t.tv_nsec;
struct tm *tm;
USE_SAFE_ALLOCA;
while (1)
{
- time_t *taddr = emacs_secs_addr (&t);
+ time_t *taddr = &t.tv_sec;
block_input ();
synchronize_system_time_locale ();
the data it can't find. */)
(Lisp_Object specified_time)
{
- EMACS_TIME value;
+ struct timespec value;
int offset;
struct tm *t;
struct tm localtm;
Lisp_Object zone_offset, zone_name;
zone_offset = Qnil;
- value = make_emacs_time (lisp_seconds_argument (specified_time), 0);
+ value = make_timespec (lisp_seconds_argument (specified_time), 0);
zone_name = format_time_string ("%Z", sizeof "%Z" - 1, value, 0, &localtm);
block_input ();
- t = gmtime (emacs_secs_addr (&value));
+ t = gmtime (&value.tv_sec);
if (t)
offset = tm_diff (&localtm, t);
unblock_input ();