diff options
| author | Paul Eggert | 2013-08-27 11:47:55 -0700 |
|---|---|---|
| committer | Paul Eggert | 2013-08-27 11:47:55 -0700 |
| commit | 43aac990c339c0fc3304aa476ebc8ea8467f107e (patch) | |
| tree | 24f6477d7ec79c7f3529e08c421f309b1180c436 | |
| parent | 278208b8e6917af1e7e2623a3869614fa70059ed (diff) | |
| download | emacs-43aac990c339c0fc3304aa476ebc8ea8467f107e.tar.gz emacs-43aac990c339c0fc3304aa476ebc8ea8467f107e.zip | |
Simplify EMACS_TIME-related code.
This portability layer is no longer needed, since Emacs has been
using struct timespec as a portability layer for some time.
Merge from gnulib, incorporating:
2013-08-27 timespec: new convenience constants and function
* src/atimer.h, src/buffer.h, src/dispextern.h, src/xgselect.h:
Include <time.h> rather than "systime.h"; that's all that's needed now.
* src/dispnew.c: Include <timespec.h> rather than "systime.h";
that's all that's needed now.
* src/systime.h (EMACS_TIME): Remove. All uses changed to struct timespec.
(EMACS_TIME_RESOLUTION): Remove. All uses changed to
TIMESPEC_RESOLUTION.
(LOG10_EMACS_TIME_RESOLUTION): Remove. All uses changed to
LOG10_TIMESPEC_RESOLUTION.
(EMACS_SECS, emacs_secs_addr): Remove. All uses changed to tv_sec.
(EMACS_NSECS): Remove. All uses changed to tv_nsec.
(make_emacs_time): Remove. All used changed to make_timespec.
(invalid_timespec): Rename from invalid_emacs_time. All uses changed.
(current_timespec): Rename from current_emacs_time. All uses changed.
(add_emacs_time): Remove. All uses changed to timespec_add.
(sub_emacs_time): Remove. All uses change dot timespec_sub.
(EMACS_TIME_SIGN): Remove. All uses changed to timespec_sign.
(timespec_valid_p): Rename from EMACS_TIME_VALID_P. All uses changed.
(EMACS_TIME_FROM_DOUBLE): Remove. All uses changed to dtotimespec.
(EMACS_TIME_TO_DOUBLE): Remove. All uses changed to timespectod.
(current_timespec): Rename from current_emacs_time. All uses changed.
(EMACS_TIME_EQ, EMACS_TIME_LT, EMACS_TIME_LE): Remove. All uses
changed to timespec_cmp.
* src/xgselect.c: Include <timespec.h>, since our .h files don't.
| -rw-r--r-- | ChangeLog | 6 | ||||
| -rw-r--r-- | lib-src/profile.c | 14 | ||||
| -rw-r--r-- | lib/timespec.h | 17 | ||||
| -rw-r--r-- | src/ChangeLog | 30 | ||||
| -rw-r--r-- | src/alloc.c | 8 | ||||
| -rw-r--r-- | src/atimer.c | 33 | ||||
| -rw-r--r-- | src/atimer.h | 8 | ||||
| -rw-r--r-- | src/buffer.c | 2 | ||||
| -rw-r--r-- | src/buffer.h | 10 | ||||
| -rw-r--r-- | src/dispextern.h | 6 | ||||
| -rw-r--r-- | src/dispnew.c | 16 | ||||
| -rw-r--r-- | src/editfns.c | 48 | ||||
| -rw-r--r-- | src/fileio.c | 58 | ||||
| -rw-r--r-- | src/gtkutil.c | 10 | ||||
| -rw-r--r-- | src/image.c | 22 | ||||
| -rw-r--r-- | src/keyboard.c | 125 | ||||
| -rw-r--r-- | src/keyboard.h | 10 | ||||
| -rw-r--r-- | src/lread.c | 8 | ||||
| -rw-r--r-- | src/msdos.c | 14 | ||||
| -rw-r--r-- | src/nsmenu.m | 6 | ||||
| -rw-r--r-- | src/nsterm.h | 2 | ||||
| -rw-r--r-- | src/nsterm.m | 18 | ||||
| -rw-r--r-- | src/process.c | 64 | ||||
| -rw-r--r-- | src/profiler.c | 4 | ||||
| -rw-r--r-- | src/sysdep.c | 75 | ||||
| -rw-r--r-- | src/systime.h | 134 | ||||
| -rw-r--r-- | src/w32.c | 4 | ||||
| -rw-r--r-- | src/w32proc.c | 2 | ||||
| -rw-r--r-- | src/xdisp.c | 10 | ||||
| -rw-r--r-- | src/xgselect.c | 13 | ||||
| -rw-r--r-- | src/xgselect.h | 4 | ||||
| -rw-r--r-- | src/xmenu.c | 4 | ||||
| -rw-r--r-- | src/xterm.c | 26 |
33 files changed, 389 insertions, 422 deletions
| @@ -1,3 +1,9 @@ | |||
| 1 | 2013-08-27 Paul Eggert <eggert@cs.ucla.edu> | ||
| 2 | |||
| 3 | Simplify EMACS_TIME-related code. | ||
| 4 | Merge from gnulib, incorporating: | ||
| 5 | 2013-08-27 timespec: new convenience constants and function | ||
| 6 | |||
| 1 | 2013-08-27 Dmitry Antipov <dmantipov@yandex.ru> | 7 | 2013-08-27 Dmitry Antipov <dmantipov@yandex.ru> |
| 2 | 8 | ||
| 3 | * configure.ac (DOCMISC_DVI_W32, DOCMISC_HTML_W32, DOCMISC_INFO_W32) | 9 | * configure.ac (DOCMISC_DVI_W32, DOCMISC_HTML_W32, DOCMISC_INFO_W32) |
diff --git a/lib-src/profile.c b/lib-src/profile.c index ab17b52ca28..bddfea76334 100644 --- a/lib-src/profile.c +++ b/lib-src/profile.c | |||
| @@ -39,17 +39,17 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 39 | #include <intprops.h> | 39 | #include <intprops.h> |
| 40 | #include <systime.h> | 40 | #include <systime.h> |
| 41 | 41 | ||
| 42 | static EMACS_TIME TV1; | 42 | static struct timespec TV1; |
| 43 | static int watch_not_started = 1; /* flag */ | 43 | static int watch_not_started = 1; /* flag */ |
| 44 | static char time_string[INT_STRLEN_BOUND (uintmax_t) + sizeof "." | 44 | static char time_string[INT_STRLEN_BOUND (uintmax_t) + sizeof "." |
| 45 | + LOG10_EMACS_TIME_RESOLUTION]; | 45 | + LOG10_TIMESPEC_RESOLUTION]; |
| 46 | 46 | ||
| 47 | /* Reset the stopwatch to zero. */ | 47 | /* Reset the stopwatch to zero. */ |
| 48 | 48 | ||
| 49 | static void | 49 | static void |
| 50 | reset_watch (void) | 50 | reset_watch (void) |
| 51 | { | 51 | { |
| 52 | TV1 = current_emacs_time (); | 52 | TV1 = current_timespec (); |
| 53 | watch_not_started = 0; | 53 | watch_not_started = 0; |
| 54 | } | 54 | } |
| 55 | 55 | ||
| @@ -60,12 +60,12 @@ reset_watch (void) | |||
| 60 | static char * | 60 | static char * |
| 61 | get_time (void) | 61 | get_time (void) |
| 62 | { | 62 | { |
| 63 | EMACS_TIME TV2 = sub_emacs_time (current_emacs_time (), TV1); | 63 | struct timespec TV2 = timespec_sub (current_timespec (), TV1); |
| 64 | uintmax_t s = EMACS_SECS (TV2); | 64 | uintmax_t s = TV2.tv_sec; |
| 65 | int ns = EMACS_NSECS (TV2); | 65 | int ns = TV2.tv_nsec; |
| 66 | if (watch_not_started) | 66 | if (watch_not_started) |
| 67 | exit (EXIT_FAILURE); /* call reset_watch first ! */ | 67 | exit (EXIT_FAILURE); /* call reset_watch first ! */ |
| 68 | sprintf (time_string, "%"PRIuMAX".%0*d", s, LOG10_EMACS_TIME_RESOLUTION, ns); | 68 | sprintf (time_string, "%"PRIuMAX".%0*d", s, LOG10_TIMESPEC_RESOLUTION, ns); |
| 69 | return time_string; | 69 | return time_string; |
| 70 | } | 70 | } |
| 71 | 71 | ||
diff --git a/lib/timespec.h b/lib/timespec.h index d665e6ccf9a..c7450ad8de0 100644 --- a/lib/timespec.h +++ b/lib/timespec.h | |||
| @@ -26,6 +26,23 @@ _GL_INLINE_HEADER_BEGIN | |||
| 26 | # define _GL_TIMESPEC_INLINE _GL_INLINE | 26 | # define _GL_TIMESPEC_INLINE _GL_INLINE |
| 27 | #endif | 27 | #endif |
| 28 | 28 | ||
| 29 | /* Resolution of timespec time stamps (in units per second), and log | ||
| 30 | base 10 of the resolution. */ | ||
| 31 | |||
| 32 | enum { TIMESPEC_RESOLUTION = 1000000000 }; | ||
| 33 | enum { LOG10_TIMESPEC_RESOLUTION = 9 }; | ||
| 34 | |||
| 35 | /* Return a timespec with seconds S and nanoseconds NS. */ | ||
| 36 | |||
| 37 | _GL_TIMESPEC_INLINE struct timespec | ||
| 38 | make_timespec (time_t s, long int ns) | ||
| 39 | { | ||
| 40 | struct timespec r; | ||
| 41 | r.tv_sec = s; | ||
| 42 | r.tv_nsec = ns; | ||
| 43 | return r; | ||
| 44 | } | ||
| 45 | |||
| 29 | /* Return negative, zero, positive if A < B, A == B, A > B, respectively. | 46 | /* Return negative, zero, positive if A < B, A == B, A > B, respectively. |
| 30 | 47 | ||
| 31 | For each time stamp T, this code assumes that either: | 48 | For each time stamp T, this code assumes that either: |
diff --git a/src/ChangeLog b/src/ChangeLog index 59bf6b420c6..5d5a811b3c4 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,33 @@ | |||
| 1 | 2013-08-27 Paul Eggert <eggert@cs.ucla.edu> | ||
| 2 | |||
| 3 | Simplify EMACS_TIME-related code. | ||
| 4 | This portability layer is no longer needed, since Emacs has been | ||
| 5 | using struct timespec as a portability layer for some time. | ||
| 6 | * atimer.h, buffer.h, dispextern.h, xgselect.h: | ||
| 7 | Include <time.h> rather than "systime.h"; that's all that's needed now. | ||
| 8 | * dispnew.c: Include <timespec.h> rather than "systime.h"; | ||
| 9 | that's all that's needed now. | ||
| 10 | * systime.h (EMACS_TIME): Remove. All uses changed to struct timespec. | ||
| 11 | (EMACS_TIME_RESOLUTION): Remove. All uses changed to | ||
| 12 | TIMESPEC_RESOLUTION. | ||
| 13 | (LOG10_EMACS_TIME_RESOLUTION): Remove. All uses changed to | ||
| 14 | LOG10_TIMESPEC_RESOLUTION. | ||
| 15 | (EMACS_SECS, emacs_secs_addr): Remove. All uses changed to tv_sec. | ||
| 16 | (EMACS_NSECS): Remove. All uses changed to tv_nsec. | ||
| 17 | (make_emacs_time): Remove. All used changed to make_timespec. | ||
| 18 | (invalid_timespec): Rename from invalid_emacs_time. All uses changed. | ||
| 19 | (current_timespec): Rename from current_emacs_time. All uses changed. | ||
| 20 | (add_emacs_time): Remove. All uses changed to timespec_add. | ||
| 21 | (sub_emacs_time): Remove. All uses change dot timespec_sub. | ||
| 22 | (EMACS_TIME_SIGN): Remove. All uses changed to timespec_sign. | ||
| 23 | (timespec_valid_p): Rename from EMACS_TIME_VALID_P. All uses changed. | ||
| 24 | (EMACS_TIME_FROM_DOUBLE): Remove. All uses changed to dtotimespec. | ||
| 25 | (EMACS_TIME_TO_DOUBLE): Remove. All uses changed to timespectod. | ||
| 26 | (current_timespec): Rename from current_emacs_time. All uses changed. | ||
| 27 | (EMACS_TIME_EQ, EMACS_TIME_LT, EMACS_TIME_LE): Remove. All uses | ||
| 28 | changed to timespec_cmp. | ||
| 29 | * xgselect.c: Include <timespec.h>, since our .h files don't. | ||
| 30 | |||
| 1 | 2013-08-27 Dmitry Antipov <dmantipov@yandex.ru> | 31 | 2013-08-27 Dmitry Antipov <dmantipov@yandex.ru> |
| 2 | 32 | ||
| 3 | * xterm.h (FONT_TYPE_FOR_UNIBYTE, FONT_TYPE_FOR_MULTIBYTE:) | 33 | * xterm.h (FONT_TYPE_FOR_UNIBYTE, FONT_TYPE_FOR_MULTIBYTE:) |
diff --git a/src/alloc.c b/src/alloc.c index 70a23488613..ebb8ef58991 100644 --- a/src/alloc.c +++ b/src/alloc.c | |||
| @@ -5233,7 +5233,7 @@ See Info node `(elisp)Garbage Collection'. */) | |||
| 5233 | ptrdiff_t i; | 5233 | ptrdiff_t i; |
| 5234 | bool message_p; | 5234 | bool message_p; |
| 5235 | ptrdiff_t count = SPECPDL_INDEX (); | 5235 | ptrdiff_t count = SPECPDL_INDEX (); |
| 5236 | EMACS_TIME start; | 5236 | struct timespec start; |
| 5237 | Lisp_Object retval = Qnil; | 5237 | Lisp_Object retval = Qnil; |
| 5238 | size_t tot_before = 0; | 5238 | size_t tot_before = 0; |
| 5239 | 5239 | ||
| @@ -5258,7 +5258,7 @@ See Info node `(elisp)Garbage Collection'. */) | |||
| 5258 | if (profiler_memory_running) | 5258 | if (profiler_memory_running) |
| 5259 | tot_before = total_bytes_of_live_objects (); | 5259 | tot_before = total_bytes_of_live_objects (); |
| 5260 | 5260 | ||
| 5261 | start = current_emacs_time (); | 5261 | start = current_timespec (); |
| 5262 | 5262 | ||
| 5263 | /* In case user calls debug_print during GC, | 5263 | /* In case user calls debug_print during GC, |
| 5264 | don't let that cause a recursive GC. */ | 5264 | don't let that cause a recursive GC. */ |
| @@ -5521,9 +5521,9 @@ See Info node `(elisp)Garbage Collection'. */) | |||
| 5521 | /* Accumulate statistics. */ | 5521 | /* Accumulate statistics. */ |
| 5522 | if (FLOATP (Vgc_elapsed)) | 5522 | if (FLOATP (Vgc_elapsed)) |
| 5523 | { | 5523 | { |
| 5524 | EMACS_TIME since_start = sub_emacs_time (current_emacs_time (), start); | 5524 | struct timespec since_start = timespec_sub (current_timespec (), start); |
| 5525 | Vgc_elapsed = make_float (XFLOAT_DATA (Vgc_elapsed) | 5525 | Vgc_elapsed = make_float (XFLOAT_DATA (Vgc_elapsed) |
| 5526 | + EMACS_TIME_TO_DOUBLE (since_start)); | 5526 | + timespectod (since_start)); |
| 5527 | } | 5527 | } |
| 5528 | 5528 | ||
| 5529 | gcs_done++; | 5529 | gcs_done++; |
diff --git a/src/atimer.c b/src/atimer.c index 219b3502acc..6aef71db873 100644 --- a/src/atimer.c +++ b/src/atimer.c | |||
| @@ -94,17 +94,16 @@ static struct atimer *append_atimer_lists (struct atimer *, | |||
| 94 | to cancel_atimer; don't free it yourself. */ | 94 | to cancel_atimer; don't free it yourself. */ |
| 95 | 95 | ||
| 96 | struct atimer * | 96 | struct atimer * |
| 97 | start_atimer (enum atimer_type type, EMACS_TIME timestamp, atimer_callback fn, | 97 | start_atimer (enum atimer_type type, struct timespec timestamp, |
| 98 | void *client_data) | 98 | atimer_callback fn, void *client_data) |
| 99 | { | 99 | { |
| 100 | struct atimer *t; | 100 | struct atimer *t; |
| 101 | 101 | ||
| 102 | /* Round TIME up to the next full second if we don't have | 102 | /* Round TIME up to the next full second if we don't have |
| 103 | itimers. */ | 103 | itimers. */ |
| 104 | #ifndef HAVE_SETITIMER | 104 | #ifndef HAVE_SETITIMER |
| 105 | if (EMACS_NSECS (timestamp) != 0 | 105 | if (timestamp.tv_nsec != 0 && timestamp.tv_sec < TYPE_MAXIMUM (time_t)) |
| 106 | && EMACS_SECS (timestamp) < TYPE_MAXIMUM (time_t)) | 106 | timestamp = make_timespec (timestamp.tv_sec + 1, 0); |
| 107 | timestamp = make_emacs_time (EMACS_SECS (timestamp) + 1, 0); | ||
| 108 | #endif /* not HAVE_SETITIMER */ | 107 | #endif /* not HAVE_SETITIMER */ |
| 109 | 108 | ||
| 110 | /* Get an atimer structure from the free-list, or allocate | 109 | /* Get an atimer structure from the free-list, or allocate |
| @@ -133,11 +132,11 @@ start_atimer (enum atimer_type type, EMACS_TIME timestamp, atimer_callback fn, | |||
| 133 | break; | 132 | break; |
| 134 | 133 | ||
| 135 | case ATIMER_RELATIVE: | 134 | case ATIMER_RELATIVE: |
| 136 | t->expiration = add_emacs_time (current_emacs_time (), timestamp); | 135 | t->expiration = timespec_add (current_timespec (), timestamp); |
| 137 | break; | 136 | break; |
| 138 | 137 | ||
| 139 | case ATIMER_CONTINUOUS: | 138 | case ATIMER_CONTINUOUS: |
| 140 | t->expiration = add_emacs_time (current_emacs_time (), timestamp); | 139 | t->expiration = timespec_add (current_timespec (), timestamp); |
| 141 | t->interval = timestamp; | 140 | t->interval = timestamp; |
| 142 | break; | 141 | break; |
| 143 | } | 142 | } |
| @@ -284,7 +283,7 @@ set_alarm (void) | |||
| 284 | #ifdef HAVE_SETITIMER | 283 | #ifdef HAVE_SETITIMER |
| 285 | struct itimerval it; | 284 | struct itimerval it; |
| 286 | #endif | 285 | #endif |
| 287 | EMACS_TIME now, interval; | 286 | struct timespec now, interval; |
| 288 | 287 | ||
| 289 | #ifdef HAVE_ITIMERSPEC | 288 | #ifdef HAVE_ITIMERSPEC |
| 290 | if (alarm_timer_ok) | 289 | if (alarm_timer_ok) |
| @@ -299,10 +298,10 @@ set_alarm (void) | |||
| 299 | 298 | ||
| 300 | /* Determine interval till the next timer is ripe. | 299 | /* Determine interval till the next timer is ripe. |
| 301 | Don't set the interval to 0; this disables the timer. */ | 300 | Don't set the interval to 0; this disables the timer. */ |
| 302 | now = current_emacs_time (); | 301 | now = current_timespec (); |
| 303 | interval = (EMACS_TIME_LE (atimers->expiration, now) | 302 | interval = (timespec_cmp (atimers->expiration, now) <= 0 |
| 304 | ? make_emacs_time (0, 1000 * 1000) | 303 | ? make_timespec (0, 1000 * 1000) |
| 305 | : sub_emacs_time (atimers->expiration, now)); | 304 | : timespec_sub (atimers->expiration, now)); |
| 306 | 305 | ||
| 307 | #ifdef HAVE_SETITIMER | 306 | #ifdef HAVE_SETITIMER |
| 308 | 307 | ||
| @@ -310,7 +309,7 @@ set_alarm (void) | |||
| 310 | it.it_value = make_timeval (interval); | 309 | it.it_value = make_timeval (interval); |
| 311 | setitimer (ITIMER_REAL, &it, 0); | 310 | setitimer (ITIMER_REAL, &it, 0); |
| 312 | #else /* not HAVE_SETITIMER */ | 311 | #else /* not HAVE_SETITIMER */ |
| 313 | alarm (max (EMACS_SECS (interval), 1)); | 312 | alarm (max (interval.tv_sec, 1)); |
| 314 | #endif /* not HAVE_SETITIMER */ | 313 | #endif /* not HAVE_SETITIMER */ |
| 315 | } | 314 | } |
| 316 | } | 315 | } |
| @@ -326,7 +325,7 @@ schedule_atimer (struct atimer *t) | |||
| 326 | struct atimer *a = atimers, *prev = NULL; | 325 | struct atimer *a = atimers, *prev = NULL; |
| 327 | 326 | ||
| 328 | /* Look for the first atimer that is ripe after T. */ | 327 | /* Look for the first atimer that is ripe after T. */ |
| 329 | while (a && EMACS_TIME_LT (a->expiration, t->expiration)) | 328 | while (a && timespec_cmp (a->expiration, t->expiration) < 0) |
| 330 | prev = a, a = a->next; | 329 | prev = a, a = a->next; |
| 331 | 330 | ||
| 332 | /* Insert T in front of the atimer found, if any. */ | 331 | /* Insert T in front of the atimer found, if any. */ |
| @@ -341,9 +340,9 @@ schedule_atimer (struct atimer *t) | |||
| 341 | static void | 340 | static void |
| 342 | run_timers (void) | 341 | run_timers (void) |
| 343 | { | 342 | { |
| 344 | EMACS_TIME now = current_emacs_time (); | 343 | struct timespec now = current_timespec (); |
| 345 | 344 | ||
| 346 | while (atimers && EMACS_TIME_LE (atimers->expiration, now)) | 345 | while (atimers && timespec_cmp (atimers->expiration, now) <= 0) |
| 347 | { | 346 | { |
| 348 | struct atimer *t = atimers; | 347 | struct atimer *t = atimers; |
| 349 | atimers = atimers->next; | 348 | atimers = atimers->next; |
| @@ -351,7 +350,7 @@ run_timers (void) | |||
| 351 | 350 | ||
| 352 | if (t->type == ATIMER_CONTINUOUS) | 351 | if (t->type == ATIMER_CONTINUOUS) |
| 353 | { | 352 | { |
| 354 | t->expiration = add_emacs_time (now, t->interval); | 353 | t->expiration = timespec_add (now, t->interval); |
| 355 | schedule_atimer (t); | 354 | schedule_atimer (t); |
| 356 | } | 355 | } |
| 357 | else | 356 | else |
diff --git a/src/atimer.h b/src/atimer.h index a1825fc0933..8c4d732aa4e 100644 --- a/src/atimer.h +++ b/src/atimer.h | |||
| @@ -19,8 +19,8 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 19 | #ifndef EMACS_ATIMER_H | 19 | #ifndef EMACS_ATIMER_H |
| 20 | #define EMACS_ATIMER_H | 20 | #define EMACS_ATIMER_H |
| 21 | 21 | ||
| 22 | #include "systime.h" /* for EMACS_TIME */ | ||
| 23 | #include <stdbool.h> | 22 | #include <stdbool.h> |
| 23 | #include <time.h> | ||
| 24 | 24 | ||
| 25 | /* Forward declaration. */ | 25 | /* Forward declaration. */ |
| 26 | 26 | ||
| @@ -52,10 +52,10 @@ struct atimer | |||
| 52 | enum atimer_type type; | 52 | enum atimer_type type; |
| 53 | 53 | ||
| 54 | /* Time when this timer is ripe. */ | 54 | /* Time when this timer is ripe. */ |
| 55 | EMACS_TIME expiration; | 55 | struct timespec expiration; |
| 56 | 56 | ||
| 57 | /* Interval of this timer. */ | 57 | /* Interval of this timer. */ |
| 58 | EMACS_TIME interval; | 58 | struct timespec interval; |
| 59 | 59 | ||
| 60 | /* Function to call when timer is ripe. Interrupt input is | 60 | /* Function to call when timer is ripe. Interrupt input is |
| 61 | guaranteed to not be blocked when this function is called. */ | 61 | guaranteed to not be blocked when this function is called. */ |
| @@ -70,7 +70,7 @@ struct atimer | |||
| 70 | 70 | ||
| 71 | /* Function prototypes. */ | 71 | /* Function prototypes. */ |
| 72 | 72 | ||
| 73 | struct atimer *start_atimer (enum atimer_type, EMACS_TIME, | 73 | struct atimer *start_atimer (enum atimer_type, struct timespec, |
| 74 | atimer_callback, void *); | 74 | atimer_callback, void *); |
| 75 | void cancel_atimer (struct atimer *); | 75 | void cancel_atimer (struct atimer *); |
| 76 | void do_pending_atimers (void); | 76 | void do_pending_atimers (void); |
diff --git a/src/buffer.c b/src/buffer.c index 58530248abc..7bc98a8b1d3 100644 --- a/src/buffer.c +++ b/src/buffer.c | |||
| @@ -933,7 +933,7 @@ reset_buffer (register struct buffer *b) | |||
| 933 | bset_filename (b, Qnil); | 933 | bset_filename (b, Qnil); |
| 934 | bset_file_truename (b, Qnil); | 934 | bset_file_truename (b, Qnil); |
| 935 | bset_directory (b, current_buffer ? BVAR (current_buffer, directory) : Qnil); | 935 | bset_directory (b, current_buffer ? BVAR (current_buffer, directory) : Qnil); |
| 936 | b->modtime = make_emacs_time (0, UNKNOWN_MODTIME_NSECS); | 936 | b->modtime = make_timespec (0, UNKNOWN_MODTIME_NSECS); |
| 937 | b->modtime_size = -1; | 937 | b->modtime_size = -1; |
| 938 | XSETFASTINT (BVAR (b, save_length), 0); | 938 | XSETFASTINT (BVAR (b, save_length), 0); |
| 939 | b->last_window_start = 1; | 939 | b->last_window_start = 1; |
diff --git a/src/buffer.h b/src/buffer.h index 55a9e8d2a1c..bedb7890939 100644 --- a/src/buffer.h +++ b/src/buffer.h | |||
| @@ -18,8 +18,8 @@ GNU General Public License for more details. | |||
| 18 | You should have received a copy of the GNU General Public License | 18 | You should have received a copy of the GNU General Public License |
| 19 | along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | 19 | along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ |
| 20 | 20 | ||
| 21 | #include <sys/types.h> /* for off_t, time_t */ | 21 | #include <sys/types.h> |
| 22 | #include "systime.h" /* for EMACS_TIME */ | 22 | #include <time.h> |
| 23 | 23 | ||
| 24 | INLINE_HEADER_BEGIN | 24 | INLINE_HEADER_BEGIN |
| 25 | #ifndef BUFFER_INLINE | 25 | #ifndef BUFFER_INLINE |
| @@ -794,13 +794,13 @@ struct buffer | |||
| 794 | char local_flags[MAX_PER_BUFFER_VARS]; | 794 | char local_flags[MAX_PER_BUFFER_VARS]; |
| 795 | 795 | ||
| 796 | /* Set to the modtime of the visited file when read or written. | 796 | /* Set to the modtime of the visited file when read or written. |
| 797 | EMACS_NSECS (modtime) == NONEXISTENT_MODTIME_NSECS means | 797 | modtime.tv_nsec == NONEXISTENT_MODTIME_NSECS means |
| 798 | visited file was nonexistent. EMACS_NSECS (modtime) == | 798 | visited file was nonexistent. modtime.tv_nsec == |
| 799 | UNKNOWN_MODTIME_NSECS means visited file modtime unknown; | 799 | UNKNOWN_MODTIME_NSECS means visited file modtime unknown; |
| 800 | in no case complain about any mismatch on next save attempt. */ | 800 | in no case complain about any mismatch on next save attempt. */ |
| 801 | #define NONEXISTENT_MODTIME_NSECS (-1) | 801 | #define NONEXISTENT_MODTIME_NSECS (-1) |
| 802 | #define UNKNOWN_MODTIME_NSECS (-2) | 802 | #define UNKNOWN_MODTIME_NSECS (-2) |
| 803 | EMACS_TIME modtime; | 803 | struct timespec modtime; |
| 804 | 804 | ||
| 805 | /* Size of the file when modtime was set. This is used to detect the | 805 | /* Size of the file when modtime was set. This is used to detect the |
| 806 | case where the file grew while we were reading it, so the modtime | 806 | case where the file grew while we were reading it, so the modtime |
diff --git a/src/dispextern.h b/src/dispextern.h index cb9dddd82cb..a5cb66f7d5e 100644 --- a/src/dispextern.h +++ b/src/dispextern.h | |||
| @@ -83,7 +83,7 @@ typedef XImagePtr XImagePtr_or_DC; | |||
| 83 | #endif | 83 | #endif |
| 84 | 84 | ||
| 85 | #ifdef HAVE_WINDOW_SYSTEM | 85 | #ifdef HAVE_WINDOW_SYSTEM |
| 86 | # include "systime.h" | 86 | # include <time.h> |
| 87 | #endif | 87 | #endif |
| 88 | 88 | ||
| 89 | #ifndef HAVE_WINDOW_SYSTEM | 89 | #ifndef HAVE_WINDOW_SYSTEM |
| @@ -2710,7 +2710,7 @@ reset_mouse_highlight (Mouse_HLInfo *hlinfo) | |||
| 2710 | hlinfo->mouse_face_mouse_x = hlinfo->mouse_face_mouse_y = 0; | 2710 | hlinfo->mouse_face_mouse_x = hlinfo->mouse_face_mouse_y = 0; |
| 2711 | hlinfo->mouse_face_beg_x = hlinfo->mouse_face_end_x = 0; | 2711 | hlinfo->mouse_face_beg_x = hlinfo->mouse_face_end_x = 0; |
| 2712 | hlinfo->mouse_face_face_id = DEFAULT_FACE_ID; | 2712 | hlinfo->mouse_face_face_id = DEFAULT_FACE_ID; |
| 2713 | hlinfo->mouse_face_mouse_frame = NULL; | 2713 | hlinfo->mouse_face_mouse_frame = NULL; |
| 2714 | hlinfo->mouse_face_window = Qnil; | 2714 | hlinfo->mouse_face_window = Qnil; |
| 2715 | hlinfo->mouse_face_overlay = Qnil; | 2715 | hlinfo->mouse_face_overlay = Qnil; |
| 2716 | hlinfo->mouse_face_past_end = 0; | 2716 | hlinfo->mouse_face_past_end = 0; |
| @@ -2914,7 +2914,7 @@ struct image | |||
| 2914 | { | 2914 | { |
| 2915 | /* The time in seconds at which the image was last displayed. Set | 2915 | /* The time in seconds at which the image was last displayed. Set |
| 2916 | in prepare_image_for_display. */ | 2916 | in prepare_image_for_display. */ |
| 2917 | EMACS_TIME timestamp; | 2917 | struct timespec timestamp; |
| 2918 | 2918 | ||
| 2919 | /* Pixmaps of the image. */ | 2919 | /* Pixmaps of the image. */ |
| 2920 | Pixmap pixmap, mask; | 2920 | Pixmap pixmap, mask; |
diff --git a/src/dispnew.c b/src/dispnew.c index 3c6b89bde68..1c80facd422 100644 --- a/src/dispnew.c +++ b/src/dispnew.c | |||
| @@ -49,12 +49,10 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 49 | #include TERM_HEADER | 49 | #include TERM_HEADER |
| 50 | #endif /* HAVE_WINDOW_SYSTEM */ | 50 | #endif /* HAVE_WINDOW_SYSTEM */ |
| 51 | 51 | ||
| 52 | /* Include systime.h after xterm.h to avoid double inclusion of time.h. */ | ||
| 53 | |||
| 54 | #include "systime.h" | ||
| 55 | #include <errno.h> | 52 | #include <errno.h> |
| 56 | 53 | ||
| 57 | #include <fpending.h> | 54 | #include <fpending.h> |
| 55 | #include <timespec.h> | ||
| 58 | 56 | ||
| 59 | #if defined (HAVE_TERM_H) && defined (GNU_LINUX) | 57 | #if defined (HAVE_TERM_H) && defined (GNU_LINUX) |
| 60 | #include <term.h> /* for tgetent */ | 58 | #include <term.h> /* for tgetent */ |
| @@ -5708,9 +5706,9 @@ additional wait period, in milliseconds; this is for backwards compatibility. | |||
| 5708 | 5706 | ||
| 5709 | if (duration > 0) | 5707 | if (duration > 0) |
| 5710 | { | 5708 | { |
| 5711 | EMACS_TIME t = EMACS_TIME_FROM_DOUBLE (duration); | 5709 | struct timespec t = dtotimespec (duration); |
| 5712 | wait_reading_process_output (min (EMACS_SECS (t), WAIT_READING_MAX), | 5710 | wait_reading_process_output (min (t.tv_sec, WAIT_READING_MAX), |
| 5713 | EMACS_NSECS (t), 0, 0, Qnil, NULL, 0); | 5711 | t.tv_nsec, 0, 0, Qnil, NULL, 0); |
| 5714 | } | 5712 | } |
| 5715 | 5713 | ||
| 5716 | return Qnil; | 5714 | return Qnil; |
| @@ -5757,9 +5755,9 @@ sit_for (Lisp_Object timeout, bool reading, int display_option) | |||
| 5757 | return Qt; | 5755 | return Qt; |
| 5758 | else | 5756 | else |
| 5759 | { | 5757 | { |
| 5760 | EMACS_TIME t = EMACS_TIME_FROM_DOUBLE (seconds); | 5758 | struct timespec t = dtotimespec (seconds); |
| 5761 | sec = min (EMACS_SECS (t), WAIT_READING_MAX); | 5759 | sec = min (t.tv_sec, WAIT_READING_MAX); |
| 5762 | nsec = EMACS_NSECS (t); | 5760 | nsec = t.tv_nsec; |
| 5763 | } | 5761 | } |
| 5764 | } | 5762 | } |
| 5765 | else if (EQ (timeout, Qt)) | 5763 | else if (EQ (timeout, Qt)) |
diff --git a/src/editfns.c b/src/editfns.c index bbaeaea5240..9e36655f3d3 100644 --- a/src/editfns.c +++ b/src/editfns.c | |||
| @@ -64,7 +64,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 64 | extern Lisp_Object w32_get_internal_run_time (void); | 64 | extern Lisp_Object w32_get_internal_run_time (void); |
| 65 | #endif | 65 | #endif |
| 66 | 66 | ||
| 67 | static Lisp_Object format_time_string (char const *, ptrdiff_t, EMACS_TIME, | 67 | static Lisp_Object format_time_string (char const *, ptrdiff_t, struct timespec, |
| 68 | bool, struct tm *); | 68 | bool, struct tm *); |
| 69 | static int tm_diff (struct tm *, struct tm *); | 69 | static int tm_diff (struct tm *, struct tm *); |
| 70 | static void update_buffer_properties (ptrdiff_t, ptrdiff_t); | 70 | static void update_buffer_properties (ptrdiff_t, ptrdiff_t); |
| @@ -1420,7 +1420,7 @@ least significant 16 bits. USEC and PSEC are the microsecond and | |||
| 1420 | picosecond counts. */) | 1420 | picosecond counts. */) |
| 1421 | (void) | 1421 | (void) |
| 1422 | { | 1422 | { |
| 1423 | return make_lisp_time (current_emacs_time ()); | 1423 | return make_lisp_time (current_timespec ()); |
| 1424 | } | 1424 | } |
| 1425 | 1425 | ||
| 1426 | DEFUN ("get-internal-run-time", Fget_internal_run_time, Sget_internal_run_time, | 1426 | DEFUN ("get-internal-run-time", Fget_internal_run_time, Sget_internal_run_time, |
| @@ -1450,7 +1450,7 @@ does the same thing as `current-time'. */) | |||
| 1450 | usecs -= 1000000; | 1450 | usecs -= 1000000; |
| 1451 | secs++; | 1451 | secs++; |
| 1452 | } | 1452 | } |
| 1453 | return make_lisp_time (make_emacs_time (secs, usecs * 1000)); | 1453 | return make_lisp_time (make_timespec (secs, usecs * 1000)); |
| 1454 | #else /* ! HAVE_GETRUSAGE */ | 1454 | #else /* ! HAVE_GETRUSAGE */ |
| 1455 | #ifdef WINDOWSNT | 1455 | #ifdef WINDOWSNT |
| 1456 | return w32_get_internal_run_time (); | 1456 | return w32_get_internal_run_time (); |
| @@ -1481,10 +1481,10 @@ make_time (time_t t) | |||
| 1481 | UNKNOWN_MODTIME_NSECS; in that case, the Lisp list contains a | 1481 | UNKNOWN_MODTIME_NSECS; in that case, the Lisp list contains a |
| 1482 | correspondingly negative picosecond count. */ | 1482 | correspondingly negative picosecond count. */ |
| 1483 | Lisp_Object | 1483 | Lisp_Object |
| 1484 | make_lisp_time (EMACS_TIME t) | 1484 | make_lisp_time (struct timespec t) |
| 1485 | { | 1485 | { |
| 1486 | int ns = EMACS_NSECS (t); | 1486 | int ns = t.tv_nsec; |
| 1487 | return make_time_tail (EMACS_SECS (t), list2i (ns / 1000, ns % 1000 * 1000)); | 1487 | return make_time_tail (t.tv_sec, list2i (ns / 1000, ns % 1000 * 1000)); |
| 1488 | } | 1488 | } |
| 1489 | 1489 | ||
| 1490 | /* Decode a Lisp list SPECIFIED_TIME that represents a time. | 1490 | /* Decode a Lisp list SPECIFIED_TIME that represents a time. |
| @@ -1529,7 +1529,7 @@ disassemble_lisp_time (Lisp_Object specified_time, Lisp_Object *phigh, | |||
| 1529 | list, generate the corresponding time value. | 1529 | list, generate the corresponding time value. |
| 1530 | 1530 | ||
| 1531 | If RESULT is not null, store into *RESULT the converted time; | 1531 | If RESULT is not null, store into *RESULT the converted time; |
| 1532 | this can fail if the converted time does not fit into EMACS_TIME. | 1532 | this can fail if the converted time does not fit into struct timespec. |
| 1533 | If *DRESULT is not null, store into *DRESULT the number of | 1533 | If *DRESULT is not null, store into *DRESULT the number of |
| 1534 | seconds since the start of the POSIX Epoch. | 1534 | seconds since the start of the POSIX Epoch. |
| 1535 | 1535 | ||
| @@ -1537,7 +1537,7 @@ disassemble_lisp_time (Lisp_Object specified_time, Lisp_Object *phigh, | |||
| 1537 | bool | 1537 | bool |
| 1538 | decode_time_components (Lisp_Object high, Lisp_Object low, Lisp_Object usec, | 1538 | decode_time_components (Lisp_Object high, Lisp_Object low, Lisp_Object usec, |
| 1539 | Lisp_Object psec, | 1539 | Lisp_Object psec, |
| 1540 | EMACS_TIME *result, double *dresult) | 1540 | struct timespec *result, double *dresult) |
| 1541 | { | 1541 | { |
| 1542 | EMACS_INT hi, lo, us, ps; | 1542 | EMACS_INT hi, lo, us, ps; |
| 1543 | if (! (INTEGERP (high) && INTEGERP (low) | 1543 | if (! (INTEGERP (high) && INTEGERP (low) |
| @@ -1565,7 +1565,7 @@ decode_time_components (Lisp_Object high, Lisp_Object low, Lisp_Object usec, | |||
| 1565 | /* Return the greatest representable time that is not greater | 1565 | /* Return the greatest representable time that is not greater |
| 1566 | than the requested time. */ | 1566 | than the requested time. */ |
| 1567 | time_t sec = hi; | 1567 | time_t sec = hi; |
| 1568 | *result = make_emacs_time ((sec << 16) + lo, us * 1000 + ps / 1000); | 1568 | *result = make_timespec ((sec << 16) + lo, us * 1000 + ps / 1000); |
| 1569 | } | 1569 | } |
| 1570 | else | 1570 | else |
| 1571 | { | 1571 | { |
| @@ -1583,15 +1583,15 @@ decode_time_components (Lisp_Object high, Lisp_Object low, Lisp_Object usec, | |||
| 1583 | /* Decode a Lisp list SPECIFIED_TIME that represents a time. | 1583 | /* Decode a Lisp list SPECIFIED_TIME that represents a time. |
| 1584 | If SPECIFIED_TIME is nil, use the current time. | 1584 | If SPECIFIED_TIME is nil, use the current time. |
| 1585 | 1585 | ||
| 1586 | Round the time down to the nearest EMACS_TIME value. | 1586 | Round the time down to the nearest struct timespec value. |
| 1587 | Return seconds since the Epoch. | 1587 | Return seconds since the Epoch. |
| 1588 | Signal an error if unsuccessful. */ | 1588 | Signal an error if unsuccessful. */ |
| 1589 | EMACS_TIME | 1589 | struct timespec |
| 1590 | lisp_time_argument (Lisp_Object specified_time) | 1590 | lisp_time_argument (Lisp_Object specified_time) |
| 1591 | { | 1591 | { |
| 1592 | EMACS_TIME t; | 1592 | struct timespec t; |
| 1593 | if (NILP (specified_time)) | 1593 | if (NILP (specified_time)) |
| 1594 | t = current_emacs_time (); | 1594 | t = current_timespec (); |
| 1595 | else | 1595 | else |
| 1596 | { | 1596 | { |
| 1597 | Lisp_Object high, low, usec, psec; | 1597 | Lisp_Object high, low, usec, psec; |
| @@ -1613,12 +1613,12 @@ lisp_seconds_argument (Lisp_Object specified_time) | |||
| 1613 | else | 1613 | else |
| 1614 | { | 1614 | { |
| 1615 | Lisp_Object high, low, usec, psec; | 1615 | Lisp_Object high, low, usec, psec; |
| 1616 | EMACS_TIME t; | 1616 | struct timespec t; |
| 1617 | if (! (disassemble_lisp_time (specified_time, &high, &low, &usec, &psec) | 1617 | if (! (disassemble_lisp_time (specified_time, &high, &low, &usec, &psec) |
| 1618 | && decode_time_components (high, low, make_number (0), | 1618 | && decode_time_components (high, low, make_number (0), |
| 1619 | make_number (0), &t, 0))) | 1619 | make_number (0), &t, 0))) |
| 1620 | error ("Invalid time specification"); | 1620 | error ("Invalid time specification"); |
| 1621 | return EMACS_SECS (t); | 1621 | return t.tv_sec; |
| 1622 | } | 1622 | } |
| 1623 | } | 1623 | } |
| 1624 | 1624 | ||
| @@ -1639,8 +1639,8 @@ or (if you need time as a string) `format-time-string'. */) | |||
| 1639 | double t; | 1639 | double t; |
| 1640 | if (NILP (specified_time)) | 1640 | if (NILP (specified_time)) |
| 1641 | { | 1641 | { |
| 1642 | EMACS_TIME now = current_emacs_time (); | 1642 | struct timespec now = current_timespec (); |
| 1643 | t = EMACS_SECS (now) + EMACS_NSECS (now) / 1e9; | 1643 | t = now.tv_sec + now.tv_nsec / 1e9; |
| 1644 | } | 1644 | } |
| 1645 | else | 1645 | else |
| 1646 | { | 1646 | { |
| @@ -1758,7 +1758,7 @@ For example, to produce full ISO 8601 format, use "%Y-%m-%dT%T%z". | |||
| 1758 | usage: (format-time-string FORMAT-STRING &optional TIME UNIVERSAL) */) | 1758 | usage: (format-time-string FORMAT-STRING &optional TIME UNIVERSAL) */) |
| 1759 | (Lisp_Object format_string, Lisp_Object timeval, Lisp_Object universal) | 1759 | (Lisp_Object format_string, Lisp_Object timeval, Lisp_Object universal) |
| 1760 | { | 1760 | { |
| 1761 | EMACS_TIME t = lisp_time_argument (timeval); | 1761 | struct timespec t = lisp_time_argument (timeval); |
| 1762 | struct tm tm; | 1762 | struct tm tm; |
| 1763 | 1763 | ||
| 1764 | CHECK_STRING (format_string); | 1764 | CHECK_STRING (format_string); |
| @@ -1770,20 +1770,20 @@ usage: (format-time-string FORMAT-STRING &optional TIME UNIVERSAL) */) | |||
| 1770 | 1770 | ||
| 1771 | static Lisp_Object | 1771 | static Lisp_Object |
| 1772 | format_time_string (char const *format, ptrdiff_t formatlen, | 1772 | format_time_string (char const *format, ptrdiff_t formatlen, |
| 1773 | EMACS_TIME t, bool ut, struct tm *tmp) | 1773 | struct timespec t, bool ut, struct tm *tmp) |
| 1774 | { | 1774 | { |
| 1775 | char buffer[4000]; | 1775 | char buffer[4000]; |
| 1776 | char *buf = buffer; | 1776 | char *buf = buffer; |
| 1777 | ptrdiff_t size = sizeof buffer; | 1777 | ptrdiff_t size = sizeof buffer; |
| 1778 | size_t len; | 1778 | size_t len; |
| 1779 | Lisp_Object bufstring; | 1779 | Lisp_Object bufstring; |
| 1780 | int ns = EMACS_NSECS (t); | 1780 | int ns = t.tv_nsec; |
| 1781 | struct tm *tm; | 1781 | struct tm *tm; |
| 1782 | USE_SAFE_ALLOCA; | 1782 | USE_SAFE_ALLOCA; |
| 1783 | 1783 | ||
| 1784 | while (1) | 1784 | while (1) |
| 1785 | { | 1785 | { |
| 1786 | time_t *taddr = emacs_secs_addr (&t); | 1786 | time_t *taddr = &t.tv_sec; |
| 1787 | block_input (); | 1787 | block_input (); |
| 1788 | 1788 | ||
| 1789 | synchronize_system_time_locale (); | 1789 | synchronize_system_time_locale (); |
| @@ -2068,17 +2068,17 @@ in this case, `current-time-zone' returns a list containing nil for | |||
| 2068 | the data it can't find. */) | 2068 | the data it can't find. */) |
| 2069 | (Lisp_Object specified_time) | 2069 | (Lisp_Object specified_time) |
| 2070 | { | 2070 | { |
| 2071 | EMACS_TIME value; | 2071 | struct timespec value; |
| 2072 | int offset; | 2072 | int offset; |
| 2073 | struct tm *t; | 2073 | struct tm *t; |
| 2074 | struct tm localtm; | 2074 | struct tm localtm; |
| 2075 | Lisp_Object zone_offset, zone_name; | 2075 | Lisp_Object zone_offset, zone_name; |
| 2076 | 2076 | ||
| 2077 | zone_offset = Qnil; | 2077 | zone_offset = Qnil; |
| 2078 | value = make_emacs_time (lisp_seconds_argument (specified_time), 0); | 2078 | value = make_timespec (lisp_seconds_argument (specified_time), 0); |
| 2079 | zone_name = format_time_string ("%Z", sizeof "%Z" - 1, value, 0, &localtm); | 2079 | zone_name = format_time_string ("%Z", sizeof "%Z" - 1, value, 0, &localtm); |
| 2080 | block_input (); | 2080 | block_input (); |
| 2081 | t = gmtime (emacs_secs_addr (&value)); | 2081 | t = gmtime (&value.tv_sec); |
| 2082 | if (t) | 2082 | if (t) |
| 2083 | offset = tm_diff (&localtm, t); | 2083 | offset = tm_diff (&localtm, t); |
| 2084 | unblock_input (); | 2084 | unblock_input (); |
diff --git a/src/fileio.c b/src/fileio.c index 7cad8d29da2..a751a73ae50 100644 --- a/src/fileio.c +++ b/src/fileio.c | |||
| @@ -2045,7 +2045,7 @@ entries (depending on how Emacs was built). */) | |||
| 2045 | /* CopyFile retains the timestamp by default. */ | 2045 | /* CopyFile retains the timestamp by default. */ |
| 2046 | else if (NILP (keep_time)) | 2046 | else if (NILP (keep_time)) |
| 2047 | { | 2047 | { |
| 2048 | EMACS_TIME now; | 2048 | struct timespec now; |
| 2049 | DWORD attributes; | 2049 | DWORD attributes; |
| 2050 | char * filename; | 2050 | char * filename; |
| 2051 | 2051 | ||
| @@ -2054,7 +2054,7 @@ entries (depending on how Emacs was built). */) | |||
| 2054 | /* Ensure file is writable while its modified time is set. */ | 2054 | /* Ensure file is writable while its modified time is set. */ |
| 2055 | attributes = GetFileAttributes (filename); | 2055 | attributes = GetFileAttributes (filename); |
| 2056 | SetFileAttributes (filename, attributes & ~FILE_ATTRIBUTE_READONLY); | 2056 | SetFileAttributes (filename, attributes & ~FILE_ATTRIBUTE_READONLY); |
| 2057 | now = current_emacs_time (); | 2057 | now = current_timespec (); |
| 2058 | if (set_file_times (-1, filename, now, now)) | 2058 | if (set_file_times (-1, filename, now, now)) |
| 2059 | { | 2059 | { |
| 2060 | /* Restore original attributes. */ | 2060 | /* Restore original attributes. */ |
| @@ -2178,8 +2178,8 @@ entries (depending on how Emacs was built). */) | |||
| 2178 | 2178 | ||
| 2179 | if (!NILP (keep_time)) | 2179 | if (!NILP (keep_time)) |
| 2180 | { | 2180 | { |
| 2181 | EMACS_TIME atime = get_stat_atime (&st); | 2181 | struct timespec atime = get_stat_atime (&st); |
| 2182 | EMACS_TIME mtime = get_stat_mtime (&st); | 2182 | struct timespec mtime = get_stat_mtime (&st); |
| 2183 | if (set_file_times (ofd, SSDATA (encoded_newname), atime, mtime)) | 2183 | if (set_file_times (ofd, SSDATA (encoded_newname), atime, mtime)) |
| 2184 | xsignal2 (Qfile_date_error, | 2184 | xsignal2 (Qfile_date_error, |
| 2185 | build_string ("Cannot set file date"), newname); | 2185 | build_string ("Cannot set file date"), newname); |
| @@ -3286,7 +3286,7 @@ Use the current time if TIMESTAMP is nil. TIMESTAMP is in the format of | |||
| 3286 | { | 3286 | { |
| 3287 | Lisp_Object absname, encoded_absname; | 3287 | Lisp_Object absname, encoded_absname; |
| 3288 | Lisp_Object handler; | 3288 | Lisp_Object handler; |
| 3289 | EMACS_TIME t = lisp_time_argument (timestamp); | 3289 | struct timespec t = lisp_time_argument (timestamp); |
| 3290 | 3290 | ||
| 3291 | absname = Fexpand_file_name (filename, BVAR (current_buffer, directory)); | 3291 | absname = Fexpand_file_name (filename, BVAR (current_buffer, directory)); |
| 3292 | 3292 | ||
| @@ -3363,7 +3363,7 @@ otherwise, if FILE2 does not exist, the answer is t. */) | |||
| 3363 | if (stat (SSDATA (absname2), &st2) < 0) | 3363 | if (stat (SSDATA (absname2), &st2) < 0) |
| 3364 | return Qt; | 3364 | return Qt; |
| 3365 | 3365 | ||
| 3366 | return (EMACS_TIME_LT (get_stat_mtime (&st2), get_stat_mtime (&st1)) | 3366 | return (timespec_cmp (get_stat_mtime (&st2), get_stat_mtime (&st1)) < 0 |
| 3367 | ? Qt : Qnil); | 3367 | ? Qt : Qnil); |
| 3368 | } | 3368 | } |
| 3369 | 3369 | ||
| @@ -3463,13 +3463,13 @@ file_offset (Lisp_Object val) | |||
| 3463 | } | 3463 | } |
| 3464 | 3464 | ||
| 3465 | /* Return a special time value indicating the error number ERRNUM. */ | 3465 | /* Return a special time value indicating the error number ERRNUM. */ |
| 3466 | static EMACS_TIME | 3466 | static struct timespec |
| 3467 | time_error_value (int errnum) | 3467 | time_error_value (int errnum) |
| 3468 | { | 3468 | { |
| 3469 | int ns = (errnum == ENOENT || errnum == EACCES || errnum == ENOTDIR | 3469 | int ns = (errnum == ENOENT || errnum == EACCES || errnum == ENOTDIR |
| 3470 | ? NONEXISTENT_MODTIME_NSECS | 3470 | ? NONEXISTENT_MODTIME_NSECS |
| 3471 | : UNKNOWN_MODTIME_NSECS); | 3471 | : UNKNOWN_MODTIME_NSECS); |
| 3472 | return make_emacs_time (0, ns); | 3472 | return make_timespec (0, ns); |
| 3473 | } | 3473 | } |
| 3474 | 3474 | ||
| 3475 | DEFUN ("insert-file-contents", Finsert_file_contents, Sinsert_file_contents, | 3475 | DEFUN ("insert-file-contents", Finsert_file_contents, Sinsert_file_contents, |
| @@ -3501,7 +3501,7 @@ by calling `format-decode', which see. */) | |||
| 3501 | (Lisp_Object filename, Lisp_Object visit, Lisp_Object beg, Lisp_Object end, Lisp_Object replace) | 3501 | (Lisp_Object filename, Lisp_Object visit, Lisp_Object beg, Lisp_Object end, Lisp_Object replace) |
| 3502 | { | 3502 | { |
| 3503 | struct stat st; | 3503 | struct stat st; |
| 3504 | EMACS_TIME mtime; | 3504 | struct timespec mtime; |
| 3505 | int fd; | 3505 | int fd; |
| 3506 | ptrdiff_t inserted = 0; | 3506 | ptrdiff_t inserted = 0; |
| 3507 | ptrdiff_t how_much; | 3507 | ptrdiff_t how_much; |
| @@ -4567,7 +4567,7 @@ by calling `format-decode', which see. */) | |||
| 4567 | } | 4567 | } |
| 4568 | 4568 | ||
| 4569 | if (!NILP (visit) | 4569 | if (!NILP (visit) |
| 4570 | && EMACS_NSECS (current_buffer->modtime) == NONEXISTENT_MODTIME_NSECS) | 4570 | && current_buffer->modtime.tv_nsec == NONEXISTENT_MODTIME_NSECS) |
| 4571 | { | 4571 | { |
| 4572 | /* If visiting nonexistent file, return nil. */ | 4572 | /* If visiting nonexistent file, return nil. */ |
| 4573 | report_file_errno ("Opening input file", orig_filename, save_errno); | 4573 | report_file_errno ("Opening input file", orig_filename, save_errno); |
| @@ -4766,7 +4766,7 @@ write_region (Lisp_Object start, Lisp_Object end, Lisp_Object filename, | |||
| 4766 | int save_errno = 0; | 4766 | int save_errno = 0; |
| 4767 | const char *fn; | 4767 | const char *fn; |
| 4768 | struct stat st; | 4768 | struct stat st; |
| 4769 | EMACS_TIME modtime; | 4769 | struct timespec modtime; |
| 4770 | ptrdiff_t count = SPECPDL_INDEX (); | 4770 | ptrdiff_t count = SPECPDL_INDEX (); |
| 4771 | ptrdiff_t count1 IF_LINT (= 0); | 4771 | ptrdiff_t count1 IF_LINT (= 0); |
| 4772 | Lisp_Object handler; | 4772 | Lisp_Object handler; |
| @@ -4980,7 +4980,7 @@ write_region (Lisp_Object start, Lisp_Object end, Lisp_Object filename, | |||
| 4980 | } | 4980 | } |
| 4981 | } | 4981 | } |
| 4982 | 4982 | ||
| 4983 | modtime = invalid_emacs_time (); | 4983 | modtime = invalid_timespec (); |
| 4984 | if (visiting) | 4984 | if (visiting) |
| 4985 | { | 4985 | { |
| 4986 | if (fstat (desc, &st) == 0) | 4986 | if (fstat (desc, &st) == 0) |
| @@ -5014,7 +5014,7 @@ write_region (Lisp_Object start, Lisp_Object end, Lisp_Object filename, | |||
| 5014 | unlikely and a similar race between the last write and the fstat | 5014 | unlikely and a similar race between the last write and the fstat |
| 5015 | above cannot possibly be closed anyway. */ | 5015 | above cannot possibly be closed anyway. */ |
| 5016 | 5016 | ||
| 5017 | if (EMACS_TIME_VALID_P (modtime) | 5017 | if (timespec_valid_p (modtime) |
| 5018 | && ! (valid_timestamp_file_system && st.st_dev == timestamp_file_system)) | 5018 | && ! (valid_timestamp_file_system && st.st_dev == timestamp_file_system)) |
| 5019 | { | 5019 | { |
| 5020 | int desc1 = emacs_open (fn, O_WRONLY | O_BINARY, 0); | 5020 | int desc1 = emacs_open (fn, O_WRONLY | O_BINARY, 0); |
| @@ -5036,11 +5036,11 @@ write_region (Lisp_Object start, Lisp_Object end, Lisp_Object filename, | |||
| 5036 | bool use_heuristic | 5036 | bool use_heuristic |
| 5037 | = ((open_flags & (O_EXCL | O_TRUNC)) != 0 | 5037 | = ((open_flags & (O_EXCL | O_TRUNC)) != 0 |
| 5038 | && st.st_size != 0 | 5038 | && st.st_size != 0 |
| 5039 | && EMACS_NSECS (modtime) % 100 != 0); | 5039 | && modtime.tv_nsec % 100 != 0); |
| 5040 | 5040 | ||
| 5041 | EMACS_TIME modtime1 = get_stat_mtime (&st1); | 5041 | struct timespec modtime1 = get_stat_mtime (&st1); |
| 5042 | if (use_heuristic | 5042 | if (use_heuristic |
| 5043 | && EMACS_TIME_EQ (modtime, modtime1) | 5043 | && timespec_cmp (modtime, modtime1) == 0 |
| 5044 | && st.st_size == st1.st_size) | 5044 | && st.st_size == st1.st_size) |
| 5045 | { | 5045 | { |
| 5046 | timestamp_file_system = st.st_dev; | 5046 | timestamp_file_system = st.st_dev; |
| @@ -5080,7 +5080,7 @@ write_region (Lisp_Object start, Lisp_Object end, Lisp_Object filename, | |||
| 5080 | /* Do this before reporting IO error | 5080 | /* Do this before reporting IO error |
| 5081 | to avoid a "file has changed on disk" warning on | 5081 | to avoid a "file has changed on disk" warning on |
| 5082 | next attempt to save. */ | 5082 | next attempt to save. */ |
| 5083 | if (EMACS_TIME_VALID_P (modtime)) | 5083 | if (timespec_valid_p (modtime)) |
| 5084 | { | 5084 | { |
| 5085 | current_buffer->modtime = modtime; | 5085 | current_buffer->modtime = modtime; |
| 5086 | current_buffer->modtime_size = st.st_size; | 5086 | current_buffer->modtime_size = st.st_size; |
| @@ -5355,7 +5355,7 @@ See Info node `(elisp)Modification Time' for more details. */) | |||
| 5355 | struct stat st; | 5355 | struct stat st; |
| 5356 | Lisp_Object handler; | 5356 | Lisp_Object handler; |
| 5357 | Lisp_Object filename; | 5357 | Lisp_Object filename; |
| 5358 | EMACS_TIME mtime; | 5358 | struct timespec mtime; |
| 5359 | 5359 | ||
| 5360 | if (NILP (buf)) | 5360 | if (NILP (buf)) |
| 5361 | b = current_buffer; | 5361 | b = current_buffer; |
| @@ -5366,7 +5366,7 @@ See Info node `(elisp)Modification Time' for more details. */) | |||
| 5366 | } | 5366 | } |
| 5367 | 5367 | ||
| 5368 | if (!STRINGP (BVAR (b, filename))) return Qt; | 5368 | if (!STRINGP (BVAR (b, filename))) return Qt; |
| 5369 | if (EMACS_NSECS (b->modtime) == UNKNOWN_MODTIME_NSECS) return Qt; | 5369 | if (b->modtime.tv_nsec == UNKNOWN_MODTIME_NSECS) return Qt; |
| 5370 | 5370 | ||
| 5371 | /* If the file name has special constructs in it, | 5371 | /* If the file name has special constructs in it, |
| 5372 | call the corresponding file handler. */ | 5372 | call the corresponding file handler. */ |
| @@ -5380,7 +5380,7 @@ See Info node `(elisp)Modification Time' for more details. */) | |||
| 5380 | mtime = (stat (SSDATA (filename), &st) == 0 | 5380 | mtime = (stat (SSDATA (filename), &st) == 0 |
| 5381 | ? get_stat_mtime (&st) | 5381 | ? get_stat_mtime (&st) |
| 5382 | : time_error_value (errno)); | 5382 | : time_error_value (errno)); |
| 5383 | if (EMACS_TIME_EQ (mtime, b->modtime) | 5383 | if (timespec_cmp (mtime, b->modtime) == 0 |
| 5384 | && (b->modtime_size < 0 | 5384 | && (b->modtime_size < 0 |
| 5385 | || st.st_size == b->modtime_size)) | 5385 | || st.st_size == b->modtime_size)) |
| 5386 | return Qt; | 5386 | return Qt; |
| @@ -5397,7 +5397,7 @@ doesn't exist, return -1. | |||
| 5397 | See Info node `(elisp)Modification Time' for more details. */) | 5397 | See Info node `(elisp)Modification Time' for more details. */) |
| 5398 | (void) | 5398 | (void) |
| 5399 | { | 5399 | { |
| 5400 | int ns = EMACS_NSECS (current_buffer->modtime); | 5400 | int ns = current_buffer->modtime.tv_nsec; |
| 5401 | if (ns < 0) | 5401 | if (ns < 0) |
| 5402 | return make_number (UNKNOWN_MODTIME_NSECS - ns); | 5402 | return make_number (UNKNOWN_MODTIME_NSECS - ns); |
| 5403 | return make_lisp_time (current_buffer->modtime); | 5403 | return make_lisp_time (current_buffer->modtime); |
| @@ -5416,11 +5416,11 @@ An argument specifies the modification time value to use | |||
| 5416 | { | 5416 | { |
| 5417 | if (!NILP (time_flag)) | 5417 | if (!NILP (time_flag)) |
| 5418 | { | 5418 | { |
| 5419 | EMACS_TIME mtime; | 5419 | struct timespec mtime; |
| 5420 | if (INTEGERP (time_flag)) | 5420 | if (INTEGERP (time_flag)) |
| 5421 | { | 5421 | { |
| 5422 | CHECK_RANGED_INTEGER (time_flag, -1, 0); | 5422 | CHECK_RANGED_INTEGER (time_flag, -1, 0); |
| 5423 | mtime = make_emacs_time (0, UNKNOWN_MODTIME_NSECS - XINT (time_flag)); | 5423 | mtime = make_timespec (0, UNKNOWN_MODTIME_NSECS - XINT (time_flag)); |
| 5424 | } | 5424 | } |
| 5425 | else | 5425 | else |
| 5426 | mtime = lisp_time_argument (time_flag); | 5426 | mtime = lisp_time_argument (time_flag); |
| @@ -5683,12 +5683,12 @@ A non-nil CURRENT-ONLY argument means save only current buffer. */) | |||
| 5683 | || NILP (Ffind_file_name_handler (BVAR (b, auto_save_file_name), | 5683 | || NILP (Ffind_file_name_handler (BVAR (b, auto_save_file_name), |
| 5684 | Qwrite_region)))) | 5684 | Qwrite_region)))) |
| 5685 | { | 5685 | { |
| 5686 | EMACS_TIME before_time = current_emacs_time (); | 5686 | struct timespec before_time = current_timespec (); |
| 5687 | EMACS_TIME after_time; | 5687 | struct timespec after_time; |
| 5688 | 5688 | ||
| 5689 | /* If we had a failure, don't try again for 20 minutes. */ | 5689 | /* If we had a failure, don't try again for 20 minutes. */ |
| 5690 | if (b->auto_save_failure_time > 0 | 5690 | if (b->auto_save_failure_time > 0 |
| 5691 | && EMACS_SECS (before_time) - b->auto_save_failure_time < 1200) | 5691 | && before_time.tv_sec - b->auto_save_failure_time < 1200) |
| 5692 | continue; | 5692 | continue; |
| 5693 | 5693 | ||
| 5694 | set_buffer_internal (b); | 5694 | set_buffer_internal (b); |
| @@ -5721,12 +5721,12 @@ A non-nil CURRENT-ONLY argument means save only current buffer. */) | |||
| 5721 | XSETFASTINT (BVAR (current_buffer, save_length), Z - BEG); | 5721 | XSETFASTINT (BVAR (current_buffer, save_length), Z - BEG); |
| 5722 | set_buffer_internal (old); | 5722 | set_buffer_internal (old); |
| 5723 | 5723 | ||
| 5724 | after_time = current_emacs_time (); | 5724 | after_time = current_timespec (); |
| 5725 | 5725 | ||
| 5726 | /* If auto-save took more than 60 seconds, | 5726 | /* If auto-save took more than 60 seconds, |
| 5727 | assume it was an NFS failure that got a timeout. */ | 5727 | assume it was an NFS failure that got a timeout. */ |
| 5728 | if (EMACS_SECS (after_time) - EMACS_SECS (before_time) > 60) | 5728 | if (after_time.tv_sec - before_time.tv_sec > 60) |
| 5729 | b->auto_save_failure_time = EMACS_SECS (after_time); | 5729 | b->auto_save_failure_time = after_time.tv_sec; |
| 5730 | } | 5730 | } |
| 5731 | } | 5731 | } |
| 5732 | 5732 | ||
diff --git a/src/gtkutil.c b/src/gtkutil.c index 0de748654eb..f03ca592834 100644 --- a/src/gtkutil.c +++ b/src/gtkutil.c | |||
| @@ -1685,15 +1685,15 @@ static gboolean | |||
| 1685 | xg_maybe_add_timer (gpointer data) | 1685 | xg_maybe_add_timer (gpointer data) |
| 1686 | { | 1686 | { |
| 1687 | struct xg_dialog_data *dd = data; | 1687 | struct xg_dialog_data *dd = data; |
| 1688 | EMACS_TIME next_time = timer_check (); | 1688 | struct timespec next_time = timer_check (); |
| 1689 | 1689 | ||
| 1690 | dd->timerid = 0; | 1690 | dd->timerid = 0; |
| 1691 | 1691 | ||
| 1692 | if (EMACS_TIME_VALID_P (next_time)) | 1692 | if (timespec_valid_p (next_time)) |
| 1693 | { | 1693 | { |
| 1694 | time_t s = EMACS_SECS (next_time); | 1694 | time_t s = next_time.tv_sec; |
| 1695 | int per_ms = EMACS_TIME_RESOLUTION / 1000; | 1695 | int per_ms = TIMESPEC_RESOLUTION / 1000; |
| 1696 | int ms = (EMACS_NSECS (next_time) + per_ms - 1) / per_ms; | 1696 | int ms = (next_time.tv_nsec + per_ms - 1) / per_ms; |
| 1697 | if (s <= ((guint) -1 - ms) / 1000) | 1697 | if (s <= ((guint) -1 - ms) / 1000) |
| 1698 | dd->timerid = g_timeout_add (s * 1000 + ms, xg_maybe_add_timer, dd); | 1698 | dd->timerid = g_timeout_add (s * 1000 + ms, xg_maybe_add_timer, dd); |
| 1699 | } | 1699 | } |
diff --git a/src/image.c b/src/image.c index 8d9c33de12c..bcc0fcd78a3 100644 --- a/src/image.c +++ b/src/image.c | |||
| @@ -1041,7 +1041,7 @@ void | |||
| 1041 | prepare_image_for_display (struct frame *f, struct image *img) | 1041 | prepare_image_for_display (struct frame *f, struct image *img) |
| 1042 | { | 1042 | { |
| 1043 | /* We're about to display IMG, so set its timestamp to `now'. */ | 1043 | /* We're about to display IMG, so set its timestamp to `now'. */ |
| 1044 | img->timestamp = current_emacs_time (); | 1044 | img->timestamp = current_timespec (); |
| 1045 | 1045 | ||
| 1046 | /* If IMG doesn't have a pixmap yet, load it now, using the image | 1046 | /* If IMG doesn't have a pixmap yet, load it now, using the image |
| 1047 | type dependent loader function. */ | 1047 | type dependent loader function. */ |
| @@ -1480,7 +1480,7 @@ clear_image_cache (struct frame *f, Lisp_Object filter) | |||
| 1480 | else if (INTEGERP (Vimage_cache_eviction_delay)) | 1480 | else if (INTEGERP (Vimage_cache_eviction_delay)) |
| 1481 | { | 1481 | { |
| 1482 | /* Free cache based on timestamp. */ | 1482 | /* Free cache based on timestamp. */ |
| 1483 | EMACS_TIME old, t; | 1483 | struct timespec old, t; |
| 1484 | double delay; | 1484 | double delay; |
| 1485 | ptrdiff_t nimages = 0; | 1485 | ptrdiff_t nimages = 0; |
| 1486 | 1486 | ||
| @@ -1495,13 +1495,13 @@ clear_image_cache (struct frame *f, Lisp_Object filter) | |||
| 1495 | delay = 1600 * delay / nimages / nimages; | 1495 | delay = 1600 * delay / nimages / nimages; |
| 1496 | delay = max (delay, 1); | 1496 | delay = max (delay, 1); |
| 1497 | 1497 | ||
| 1498 | t = current_emacs_time (); | 1498 | t = current_timespec (); |
| 1499 | old = sub_emacs_time (t, EMACS_TIME_FROM_DOUBLE (delay)); | 1499 | old = timespec_sub (t, dtotimespec (delay)); |
| 1500 | 1500 | ||
| 1501 | for (i = 0; i < c->used; ++i) | 1501 | for (i = 0; i < c->used; ++i) |
| 1502 | { | 1502 | { |
| 1503 | struct image *img = c->images[i]; | 1503 | struct image *img = c->images[i]; |
| 1504 | if (img && EMACS_TIME_LT (img->timestamp, old)) | 1504 | if (img && timespec_cmp (img->timestamp, old) < 0) |
| 1505 | { | 1505 | { |
| 1506 | free_image (f, img); | 1506 | free_image (f, img); |
| 1507 | ++nfreed; | 1507 | ++nfreed; |
| @@ -1764,7 +1764,7 @@ lookup_image (struct frame *f, Lisp_Object spec) | |||
| 1764 | } | 1764 | } |
| 1765 | 1765 | ||
| 1766 | /* We're using IMG, so set its timestamp to `now'. */ | 1766 | /* We're using IMG, so set its timestamp to `now'. */ |
| 1767 | img->timestamp = current_emacs_time (); | 1767 | img->timestamp = current_timespec (); |
| 1768 | 1768 | ||
| 1769 | /* Value is the image id. */ | 1769 | /* Value is the image id. */ |
| 1770 | return img->id; | 1770 | return img->id; |
| @@ -7884,7 +7884,7 @@ struct animation_cache | |||
| 7884 | { | 7884 | { |
| 7885 | MagickWand *wand; | 7885 | MagickWand *wand; |
| 7886 | int index; | 7886 | int index; |
| 7887 | EMACS_TIME update_time; | 7887 | struct timespec update_time; |
| 7888 | struct animation_cache *next; | 7888 | struct animation_cache *next; |
| 7889 | char signature[FLEXIBLE_ARRAY_MEMBER]; | 7889 | char signature[FLEXIBLE_ARRAY_MEMBER]; |
| 7890 | }; | 7890 | }; |
| @@ -7909,13 +7909,13 @@ static void | |||
| 7909 | imagemagick_prune_animation_cache (void) | 7909 | imagemagick_prune_animation_cache (void) |
| 7910 | { | 7910 | { |
| 7911 | struct animation_cache **pcache = &animation_cache; | 7911 | struct animation_cache **pcache = &animation_cache; |
| 7912 | EMACS_TIME old = sub_emacs_time (current_emacs_time (), | 7912 | struct timespec old = timespec_sub (current_timespec (), |
| 7913 | make_emacs_time (60, 0)); | 7913 | make_timespec (60, 0)); |
| 7914 | 7914 | ||
| 7915 | while (*pcache) | 7915 | while (*pcache) |
| 7916 | { | 7916 | { |
| 7917 | struct animation_cache *cache = *pcache; | 7917 | struct animation_cache *cache = *pcache; |
| 7918 | if (EMACS_TIME_LE (old, cache->update_time)) | 7918 | if (timespec_cmp (old, cache->update_time) <= 0) |
| 7919 | pcache = &cache->next; | 7919 | pcache = &cache->next; |
| 7920 | else | 7920 | else |
| 7921 | { | 7921 | { |
| @@ -7950,7 +7950,7 @@ imagemagick_get_animation_cache (MagickWand *wand) | |||
| 7950 | } | 7950 | } |
| 7951 | 7951 | ||
| 7952 | DestroyString (signature); | 7952 | DestroyString (signature); |
| 7953 | cache->update_time = current_emacs_time (); | 7953 | cache->update_time = current_timespec (); |
| 7954 | return cache; | 7954 | return cache; |
| 7955 | } | 7955 | } |
| 7956 | 7956 | ||
diff --git a/src/keyboard.c b/src/keyboard.c index 8a99d5a0766..b8e05cf7925 100644 --- a/src/keyboard.c +++ b/src/keyboard.c | |||
| @@ -360,7 +360,7 @@ Lisp_Object Qmenu_bar; | |||
| 360 | static void recursive_edit_unwind (Lisp_Object buffer); | 360 | static void recursive_edit_unwind (Lisp_Object buffer); |
| 361 | static Lisp_Object command_loop (void); | 361 | static Lisp_Object command_loop (void); |
| 362 | static Lisp_Object Qcommand_execute; | 362 | static Lisp_Object Qcommand_execute; |
| 363 | EMACS_TIME timer_check (void); | 363 | struct timespec timer_check (void); |
| 364 | 364 | ||
| 365 | static void echo_now (void); | 365 | static void echo_now (void); |
| 366 | static ptrdiff_t echo_length (void); | 366 | static ptrdiff_t echo_length (void); |
| @@ -370,9 +370,9 @@ static Lisp_Object Qpolling_period; | |||
| 370 | /* Incremented whenever a timer is run. */ | 370 | /* Incremented whenever a timer is run. */ |
| 371 | unsigned timers_run; | 371 | unsigned timers_run; |
| 372 | 372 | ||
| 373 | /* Address (if not 0) of EMACS_TIME to zero out if a SIGIO interrupt | 373 | /* Address (if not 0) of struct timespec to zero out if a SIGIO interrupt |
| 374 | happens. */ | 374 | happens. */ |
| 375 | EMACS_TIME *input_available_clear_time; | 375 | struct timespec *input_available_clear_time; |
| 376 | 376 | ||
| 377 | /* True means use SIGIO interrupts; false means use CBREAK mode. | 377 | /* True means use SIGIO interrupts; false means use CBREAK mode. |
| 378 | Default is true if INTERRUPT_INPUT is defined. */ | 378 | Default is true if INTERRUPT_INPUT is defined. */ |
| @@ -389,12 +389,12 @@ bool interrupts_deferred; | |||
| 389 | 389 | ||
| 390 | /* The time when Emacs started being idle. */ | 390 | /* The time when Emacs started being idle. */ |
| 391 | 391 | ||
| 392 | static EMACS_TIME timer_idleness_start_time; | 392 | static struct timespec timer_idleness_start_time; |
| 393 | 393 | ||
| 394 | /* After Emacs stops being idle, this saves the last value | 394 | /* After Emacs stops being idle, this saves the last value |
| 395 | of timer_idleness_start_time from when it was idle. */ | 395 | of timer_idleness_start_time from when it was idle. */ |
| 396 | 396 | ||
| 397 | static EMACS_TIME timer_last_idleness_start_time; | 397 | static struct timespec timer_last_idleness_start_time; |
| 398 | 398 | ||
| 399 | 399 | ||
| 400 | /* Global variable declarations. */ | 400 | /* Global variable declarations. */ |
| @@ -1986,10 +1986,10 @@ start_polling (void) | |||
| 1986 | /* If poll timer doesn't exist, are we need one with | 1986 | /* If poll timer doesn't exist, are we need one with |
| 1987 | a different interval, start a new one. */ | 1987 | a different interval, start a new one. */ |
| 1988 | if (poll_timer == NULL | 1988 | if (poll_timer == NULL |
| 1989 | || EMACS_SECS (poll_timer->interval) != polling_period) | 1989 | || poll_timer->interval.tv_sec != polling_period) |
| 1990 | { | 1990 | { |
| 1991 | time_t period = max (1, min (polling_period, TYPE_MAXIMUM (time_t))); | 1991 | time_t period = max (1, min (polling_period, TYPE_MAXIMUM (time_t))); |
| 1992 | EMACS_TIME interval = make_emacs_time (period, 0); | 1992 | struct timespec interval = make_timespec (period, 0); |
| 1993 | 1993 | ||
| 1994 | if (poll_timer) | 1994 | if (poll_timer) |
| 1995 | cancel_atimer (poll_timer); | 1995 | cancel_atimer (poll_timer); |
| @@ -2182,7 +2182,7 @@ show_help_echo (Lisp_Object help, Lisp_Object window, Lisp_Object object, | |||
| 2182 | /* Input of single characters from keyboard */ | 2182 | /* Input of single characters from keyboard */ |
| 2183 | 2183 | ||
| 2184 | static Lisp_Object kbd_buffer_get_event (KBOARD **kbp, bool *used_mouse_menu, | 2184 | static Lisp_Object kbd_buffer_get_event (KBOARD **kbp, bool *used_mouse_menu, |
| 2185 | EMACS_TIME *end_time); | 2185 | struct timespec *end_time); |
| 2186 | static void record_char (Lisp_Object c); | 2186 | static void record_char (Lisp_Object c); |
| 2187 | 2187 | ||
| 2188 | static Lisp_Object help_form_saved_window_configs; | 2188 | static Lisp_Object help_form_saved_window_configs; |
| @@ -2204,7 +2204,7 @@ do { if (polling_stopped_here) start_polling (); \ | |||
| 2204 | polling_stopped_here = 0; } while (0) | 2204 | polling_stopped_here = 0; } while (0) |
| 2205 | 2205 | ||
| 2206 | static Lisp_Object | 2206 | static Lisp_Object |
| 2207 | read_event_from_main_queue (EMACS_TIME *end_time, | 2207 | read_event_from_main_queue (struct timespec *end_time, |
| 2208 | sys_jmp_buf local_getcjmp, | 2208 | sys_jmp_buf local_getcjmp, |
| 2209 | bool *used_mouse_menu) | 2209 | bool *used_mouse_menu) |
| 2210 | { | 2210 | { |
| @@ -2217,7 +2217,7 @@ read_event_from_main_queue (EMACS_TIME *end_time, | |||
| 2217 | /* Read from the main queue, and if that gives us something we can't use yet, | 2217 | /* Read from the main queue, and if that gives us something we can't use yet, |
| 2218 | we put it on the appropriate side queue and try again. */ | 2218 | we put it on the appropriate side queue and try again. */ |
| 2219 | 2219 | ||
| 2220 | if (end_time && EMACS_TIME_LE (*end_time, current_emacs_time ())) | 2220 | if (end_time && timespec_cmp (*end_time, current_timespec ()) <= 0) |
| 2221 | return c; | 2221 | return c; |
| 2222 | 2222 | ||
| 2223 | /* Actually read a character, waiting if necessary. */ | 2223 | /* Actually read a character, waiting if necessary. */ |
| @@ -2278,7 +2278,7 @@ read_event_from_main_queue (EMACS_TIME *end_time, | |||
| 2278 | /* Like `read_event_from_main_queue' but applies keyboard-coding-system | 2278 | /* Like `read_event_from_main_queue' but applies keyboard-coding-system |
| 2279 | to tty input. */ | 2279 | to tty input. */ |
| 2280 | static Lisp_Object | 2280 | static Lisp_Object |
| 2281 | read_decoded_event_from_main_queue (EMACS_TIME *end_time, | 2281 | read_decoded_event_from_main_queue (struct timespec *end_time, |
| 2282 | sys_jmp_buf local_getcjmp, | 2282 | sys_jmp_buf local_getcjmp, |
| 2283 | Lisp_Object prev_event, | 2283 | Lisp_Object prev_event, |
| 2284 | bool *used_mouse_menu) | 2284 | bool *used_mouse_menu) |
| @@ -2376,7 +2376,7 @@ read_decoded_event_from_main_queue (EMACS_TIME *end_time, | |||
| 2376 | Value is -2 when we find input on another keyboard. A second call | 2376 | Value is -2 when we find input on another keyboard. A second call |
| 2377 | to read_char will read it. | 2377 | to read_char will read it. |
| 2378 | 2378 | ||
| 2379 | If END_TIME is non-null, it is a pointer to an EMACS_TIME | 2379 | If END_TIME is non-null, it is a pointer to a struct timespec |
| 2380 | specifying the maximum time to wait until. If no input arrives by | 2380 | specifying the maximum time to wait until. If no input arrives by |
| 2381 | that time, stop waiting and return nil. | 2381 | that time, stop waiting and return nil. |
| 2382 | 2382 | ||
| @@ -2385,7 +2385,7 @@ read_decoded_event_from_main_queue (EMACS_TIME *end_time, | |||
| 2385 | Lisp_Object | 2385 | Lisp_Object |
| 2386 | read_char (int commandflag, Lisp_Object map, | 2386 | read_char (int commandflag, Lisp_Object map, |
| 2387 | Lisp_Object prev_event, | 2387 | Lisp_Object prev_event, |
| 2388 | bool *used_mouse_menu, EMACS_TIME *end_time) | 2388 | bool *used_mouse_menu, struct timespec *end_time) |
| 2389 | { | 2389 | { |
| 2390 | Lisp_Object c; | 2390 | Lisp_Object c; |
| 2391 | ptrdiff_t jmpcount; | 2391 | ptrdiff_t jmpcount; |
| @@ -2877,7 +2877,7 @@ read_char (int commandflag, Lisp_Object map, | |||
| 2877 | { | 2877 | { |
| 2878 | c = read_decoded_event_from_main_queue (end_time, local_getcjmp, | 2878 | c = read_decoded_event_from_main_queue (end_time, local_getcjmp, |
| 2879 | prev_event, used_mouse_menu); | 2879 | prev_event, used_mouse_menu); |
| 2880 | if (end_time && EMACS_TIME_LE (*end_time, current_emacs_time ())) | 2880 | if (end_time && timespec_cmp (*end_time, current_timespec ()) <= 0) |
| 2881 | goto exit; | 2881 | goto exit; |
| 2882 | if (EQ (c, make_number (-2))) | 2882 | if (EQ (c, make_number (-2))) |
| 2883 | { | 2883 | { |
| @@ -3798,7 +3798,7 @@ clear_event (struct input_event *event) | |||
| 3798 | static Lisp_Object | 3798 | static Lisp_Object |
| 3799 | kbd_buffer_get_event (KBOARD **kbp, | 3799 | kbd_buffer_get_event (KBOARD **kbp, |
| 3800 | bool *used_mouse_menu, | 3800 | bool *used_mouse_menu, |
| 3801 | EMACS_TIME *end_time) | 3801 | struct timespec *end_time) |
| 3802 | { | 3802 | { |
| 3803 | Lisp_Object obj; | 3803 | Lisp_Object obj; |
| 3804 | 3804 | ||
| @@ -3856,15 +3856,15 @@ kbd_buffer_get_event (KBOARD **kbp, | |||
| 3856 | break; | 3856 | break; |
| 3857 | if (end_time) | 3857 | if (end_time) |
| 3858 | { | 3858 | { |
| 3859 | EMACS_TIME now = current_emacs_time (); | 3859 | struct timespec now = current_timespec (); |
| 3860 | if (EMACS_TIME_LE (*end_time, now)) | 3860 | if (timespec_cmp (*end_time, now) <= 0) |
| 3861 | return Qnil; /* Finished waiting. */ | 3861 | return Qnil; /* Finished waiting. */ |
| 3862 | else | 3862 | else |
| 3863 | { | 3863 | { |
| 3864 | EMACS_TIME duration = sub_emacs_time (*end_time, now); | 3864 | struct timespec duration = timespec_sub (*end_time, now); |
| 3865 | wait_reading_process_output (min (EMACS_SECS (duration), | 3865 | wait_reading_process_output (min (duration.tv_sec, |
| 3866 | WAIT_READING_MAX), | 3866 | WAIT_READING_MAX), |
| 3867 | EMACS_NSECS (duration), | 3867 | duration.tv_nsec, |
| 3868 | -1, 1, Qnil, NULL, 0); | 3868 | -1, 1, Qnil, NULL, 0); |
| 3869 | } | 3869 | } |
| 3870 | } | 3870 | } |
| @@ -4295,10 +4295,10 @@ static void | |||
| 4295 | timer_start_idle (void) | 4295 | timer_start_idle (void) |
| 4296 | { | 4296 | { |
| 4297 | /* If we are already in the idle state, do nothing. */ | 4297 | /* If we are already in the idle state, do nothing. */ |
| 4298 | if (EMACS_TIME_VALID_P (timer_idleness_start_time)) | 4298 | if (timespec_valid_p (timer_idleness_start_time)) |
| 4299 | return; | 4299 | return; |
| 4300 | 4300 | ||
| 4301 | timer_idleness_start_time = current_emacs_time (); | 4301 | timer_idleness_start_time = current_timespec (); |
| 4302 | timer_last_idleness_start_time = timer_idleness_start_time; | 4302 | timer_last_idleness_start_time = timer_idleness_start_time; |
| 4303 | 4303 | ||
| 4304 | /* Mark all idle-time timers as once again candidates for running. */ | 4304 | /* Mark all idle-time timers as once again candidates for running. */ |
| @@ -4310,7 +4310,7 @@ timer_start_idle (void) | |||
| 4310 | static void | 4310 | static void |
| 4311 | timer_stop_idle (void) | 4311 | timer_stop_idle (void) |
| 4312 | { | 4312 | { |
| 4313 | timer_idleness_start_time = invalid_emacs_time (); | 4313 | timer_idleness_start_time = invalid_timespec (); |
| 4314 | } | 4314 | } |
| 4315 | 4315 | ||
| 4316 | /* Resume idle timer from last idle start time. */ | 4316 | /* Resume idle timer from last idle start time. */ |
| @@ -4318,7 +4318,7 @@ timer_stop_idle (void) | |||
| 4318 | static void | 4318 | static void |
| 4319 | timer_resume_idle (void) | 4319 | timer_resume_idle (void) |
| 4320 | { | 4320 | { |
| 4321 | if (EMACS_TIME_VALID_P (timer_idleness_start_time)) | 4321 | if (timespec_valid_p (timer_idleness_start_time)) |
| 4322 | return; | 4322 | return; |
| 4323 | 4323 | ||
| 4324 | timer_idleness_start_time = timer_last_idleness_start_time; | 4324 | timer_idleness_start_time = timer_last_idleness_start_time; |
| @@ -4334,7 +4334,7 @@ Lisp_Object pending_funcalls; | |||
| 4334 | 4334 | ||
| 4335 | /* Return true if TIMER is a valid timer, placing its value into *RESULT. */ | 4335 | /* Return true if TIMER is a valid timer, placing its value into *RESULT. */ |
| 4336 | static bool | 4336 | static bool |
| 4337 | decode_timer (Lisp_Object timer, EMACS_TIME *result) | 4337 | decode_timer (Lisp_Object timer, struct timespec *result) |
| 4338 | { | 4338 | { |
| 4339 | Lisp_Object *vector; | 4339 | Lisp_Object *vector; |
| 4340 | 4340 | ||
| @@ -4361,16 +4361,16 @@ decode_timer (Lisp_Object timer, EMACS_TIME *result) | |||
| 4361 | In that case we return 0 to indicate that a new timer_check_2 call | 4361 | In that case we return 0 to indicate that a new timer_check_2 call |
| 4362 | should be done. */ | 4362 | should be done. */ |
| 4363 | 4363 | ||
| 4364 | static EMACS_TIME | 4364 | static struct timespec |
| 4365 | timer_check_2 (Lisp_Object timers, Lisp_Object idle_timers) | 4365 | timer_check_2 (Lisp_Object timers, Lisp_Object idle_timers) |
| 4366 | { | 4366 | { |
| 4367 | EMACS_TIME nexttime; | 4367 | struct timespec nexttime; |
| 4368 | EMACS_TIME now; | 4368 | struct timespec now; |
| 4369 | EMACS_TIME idleness_now; | 4369 | struct timespec idleness_now; |
| 4370 | Lisp_Object chosen_timer; | 4370 | Lisp_Object chosen_timer; |
| 4371 | struct gcpro gcpro1; | 4371 | struct gcpro gcpro1; |
| 4372 | 4372 | ||
| 4373 | nexttime = invalid_emacs_time (); | 4373 | nexttime = invalid_timespec (); |
| 4374 | 4374 | ||
| 4375 | chosen_timer = Qnil; | 4375 | chosen_timer = Qnil; |
| 4376 | GCPRO1 (chosen_timer); | 4376 | GCPRO1 (chosen_timer); |
| @@ -4385,19 +4385,19 @@ timer_check_2 (Lisp_Object timers, Lisp_Object idle_timers) | |||
| 4385 | 4385 | ||
| 4386 | if (CONSP (timers) || CONSP (idle_timers)) | 4386 | if (CONSP (timers) || CONSP (idle_timers)) |
| 4387 | { | 4387 | { |
| 4388 | now = current_emacs_time (); | 4388 | now = current_timespec (); |
| 4389 | idleness_now = (EMACS_TIME_VALID_P (timer_idleness_start_time) | 4389 | idleness_now = (timespec_valid_p (timer_idleness_start_time) |
| 4390 | ? sub_emacs_time (now, timer_idleness_start_time) | 4390 | ? timespec_sub (now, timer_idleness_start_time) |
| 4391 | : make_emacs_time (0, 0)); | 4391 | : make_timespec (0, 0)); |
| 4392 | } | 4392 | } |
| 4393 | 4393 | ||
| 4394 | while (CONSP (timers) || CONSP (idle_timers)) | 4394 | while (CONSP (timers) || CONSP (idle_timers)) |
| 4395 | { | 4395 | { |
| 4396 | Lisp_Object timer = Qnil, idle_timer = Qnil; | 4396 | Lisp_Object timer = Qnil, idle_timer = Qnil; |
| 4397 | EMACS_TIME timer_time, idle_timer_time; | 4397 | struct timespec timer_time, idle_timer_time; |
| 4398 | EMACS_TIME difference; | 4398 | struct timespec difference; |
| 4399 | EMACS_TIME timer_difference = invalid_emacs_time (); | 4399 | struct timespec timer_difference = invalid_timespec (); |
| 4400 | EMACS_TIME idle_timer_difference = invalid_emacs_time (); | 4400 | struct timespec idle_timer_difference = invalid_timespec (); |
| 4401 | bool ripe, timer_ripe = 0, idle_timer_ripe = 0; | 4401 | bool ripe, timer_ripe = 0, idle_timer_ripe = 0; |
| 4402 | 4402 | ||
| 4403 | /* Set TIMER and TIMER_DIFFERENCE | 4403 | /* Set TIMER and TIMER_DIFFERENCE |
| @@ -4414,10 +4414,10 @@ timer_check_2 (Lisp_Object timers, Lisp_Object idle_timers) | |||
| 4414 | continue; | 4414 | continue; |
| 4415 | } | 4415 | } |
| 4416 | 4416 | ||
| 4417 | timer_ripe = EMACS_TIME_LE (timer_time, now); | 4417 | timer_ripe = timespec_cmp (timer_time, now) <= 0; |
| 4418 | timer_difference = (timer_ripe | 4418 | timer_difference = (timer_ripe |
| 4419 | ? sub_emacs_time (now, timer_time) | 4419 | ? timespec_sub (now, timer_time) |
| 4420 | : sub_emacs_time (timer_time, now)); | 4420 | : timespec_sub (timer_time, now)); |
| 4421 | } | 4421 | } |
| 4422 | 4422 | ||
| 4423 | /* Likewise for IDLE_TIMER and IDLE_TIMER_DIFFERENCE | 4423 | /* Likewise for IDLE_TIMER and IDLE_TIMER_DIFFERENCE |
| @@ -4431,26 +4431,27 @@ timer_check_2 (Lisp_Object timers, Lisp_Object idle_timers) | |||
| 4431 | continue; | 4431 | continue; |
| 4432 | } | 4432 | } |
| 4433 | 4433 | ||
| 4434 | idle_timer_ripe = EMACS_TIME_LE (idle_timer_time, idleness_now); | 4434 | idle_timer_ripe = timespec_cmp (idle_timer_time, idleness_now) <= 0; |
| 4435 | idle_timer_difference | 4435 | idle_timer_difference |
| 4436 | = (idle_timer_ripe | 4436 | = (idle_timer_ripe |
| 4437 | ? sub_emacs_time (idleness_now, idle_timer_time) | 4437 | ? timespec_sub (idleness_now, idle_timer_time) |
| 4438 | : sub_emacs_time (idle_timer_time, idleness_now)); | 4438 | : timespec_sub (idle_timer_time, idleness_now)); |
| 4439 | } | 4439 | } |
| 4440 | 4440 | ||
| 4441 | /* Decide which timer is the next timer, | 4441 | /* Decide which timer is the next timer, |
| 4442 | and set CHOSEN_TIMER, DIFFERENCE, and RIPE accordingly. | 4442 | and set CHOSEN_TIMER, DIFFERENCE, and RIPE accordingly. |
| 4443 | Also step down the list where we found that timer. */ | 4443 | Also step down the list where we found that timer. */ |
| 4444 | 4444 | ||
| 4445 | if (EMACS_TIME_VALID_P (timer_difference) | 4445 | if (timespec_valid_p (timer_difference) |
| 4446 | && (! EMACS_TIME_VALID_P (idle_timer_difference) | 4446 | && (! timespec_valid_p (idle_timer_difference) |
| 4447 | || idle_timer_ripe < timer_ripe | 4447 | || idle_timer_ripe < timer_ripe |
| 4448 | || (idle_timer_ripe == timer_ripe | 4448 | || (idle_timer_ripe == timer_ripe |
| 4449 | && (timer_ripe | 4449 | && ((timer_ripe |
| 4450 | ? EMACS_TIME_LT (idle_timer_difference, | 4450 | ? timespec_cmp (idle_timer_difference, |
| 4451 | timer_difference) | 4451 | timer_difference) |
| 4452 | : EMACS_TIME_LT (timer_difference, | 4452 | : timespec_cmp (timer_difference, |
| 4453 | idle_timer_difference))))) | 4453 | idle_timer_difference)) |
| 4454 | < 0)))) | ||
| 4454 | { | 4455 | { |
| 4455 | chosen_timer = timer; | 4456 | chosen_timer = timer; |
| 4456 | timers = XCDR (timers); | 4457 | timers = XCDR (timers); |
| @@ -4490,7 +4491,7 @@ timer_check_2 (Lisp_Object timers, Lisp_Object idle_timers) | |||
| 4490 | return 0 to indicate that. */ | 4491 | return 0 to indicate that. */ |
| 4491 | } | 4492 | } |
| 4492 | 4493 | ||
| 4493 | nexttime = make_emacs_time (0, 0); | 4494 | nexttime = make_timespec (0, 0); |
| 4494 | break; | 4495 | break; |
| 4495 | } | 4496 | } |
| 4496 | else | 4497 | else |
| @@ -4518,10 +4519,10 @@ timer_check_2 (Lisp_Object timers, Lisp_Object idle_timers) | |||
| 4518 | 4519 | ||
| 4519 | As long as any timer is ripe, we run it. */ | 4520 | As long as any timer is ripe, we run it. */ |
| 4520 | 4521 | ||
| 4521 | EMACS_TIME | 4522 | struct timespec |
| 4522 | timer_check (void) | 4523 | timer_check (void) |
| 4523 | { | 4524 | { |
| 4524 | EMACS_TIME nexttime; | 4525 | struct timespec nexttime; |
| 4525 | Lisp_Object timers, idle_timers; | 4526 | Lisp_Object timers, idle_timers; |
| 4526 | struct gcpro gcpro1, gcpro2; | 4527 | struct gcpro gcpro1, gcpro2; |
| 4527 | 4528 | ||
| @@ -4535,7 +4536,7 @@ timer_check (void) | |||
| 4535 | /* Always consider the ordinary timers. */ | 4536 | /* Always consider the ordinary timers. */ |
| 4536 | timers = Fcopy_sequence (Vtimer_list); | 4537 | timers = Fcopy_sequence (Vtimer_list); |
| 4537 | /* Consider the idle timers only if Emacs is idle. */ | 4538 | /* Consider the idle timers only if Emacs is idle. */ |
| 4538 | if (EMACS_TIME_VALID_P (timer_idleness_start_time)) | 4539 | if (timespec_valid_p (timer_idleness_start_time)) |
| 4539 | idle_timers = Fcopy_sequence (Vtimer_idle_list); | 4540 | idle_timers = Fcopy_sequence (Vtimer_idle_list); |
| 4540 | else | 4541 | else |
| 4541 | idle_timers = Qnil; | 4542 | idle_timers = Qnil; |
| @@ -4548,7 +4549,7 @@ timer_check (void) | |||
| 4548 | { | 4549 | { |
| 4549 | nexttime = timer_check_2 (timers, idle_timers); | 4550 | nexttime = timer_check_2 (timers, idle_timers); |
| 4550 | } | 4551 | } |
| 4551 | while (EMACS_SECS (nexttime) == 0 && EMACS_NSECS (nexttime) == 0); | 4552 | while (nexttime.tv_sec == 0 && nexttime.tv_nsec == 0); |
| 4552 | 4553 | ||
| 4553 | UNGCPRO; | 4554 | UNGCPRO; |
| 4554 | return nexttime; | 4555 | return nexttime; |
| @@ -4564,9 +4565,9 @@ The value when Emacs is not idle is nil. | |||
| 4564 | PSEC is a multiple of the system clock resolution. */) | 4565 | PSEC is a multiple of the system clock resolution. */) |
| 4565 | (void) | 4566 | (void) |
| 4566 | { | 4567 | { |
| 4567 | if (EMACS_TIME_VALID_P (timer_idleness_start_time)) | 4568 | if (timespec_valid_p (timer_idleness_start_time)) |
| 4568 | return make_lisp_time (sub_emacs_time (current_emacs_time (), | 4569 | return make_lisp_time (timespec_sub (current_timespec (), |
| 4569 | timer_idleness_start_time)); | 4570 | timer_idleness_start_time)); |
| 4570 | 4571 | ||
| 4571 | return Qnil; | 4572 | return Qnil; |
| 4572 | } | 4573 | } |
| @@ -7126,7 +7127,7 @@ handle_input_available_signal (int sig) | |||
| 7126 | pending_signals = 1; | 7127 | pending_signals = 1; |
| 7127 | 7128 | ||
| 7128 | if (input_available_clear_time) | 7129 | if (input_available_clear_time) |
| 7129 | *input_available_clear_time = make_emacs_time (0, 0); | 7130 | *input_available_clear_time = make_timespec (0, 0); |
| 7130 | } | 7131 | } |
| 7131 | 7132 | ||
| 7132 | static void | 7133 | static void |
| @@ -7213,7 +7214,7 @@ handle_user_signal (int sig) | |||
| 7213 | /* Tell wait_reading_process_output that it needs to wake | 7214 | /* Tell wait_reading_process_output that it needs to wake |
| 7214 | up and look around. */ | 7215 | up and look around. */ |
| 7215 | if (input_available_clear_time) | 7216 | if (input_available_clear_time) |
| 7216 | *input_available_clear_time = make_emacs_time (0, 0); | 7217 | *input_available_clear_time = make_timespec (0, 0); |
| 7217 | } | 7218 | } |
| 7218 | break; | 7219 | break; |
| 7219 | } | 7220 | } |
| @@ -10235,7 +10236,7 @@ stuff_buffered_input (Lisp_Object stuffstring) | |||
| 10235 | } | 10236 | } |
| 10236 | 10237 | ||
| 10237 | void | 10238 | void |
| 10238 | set_waiting_for_input (EMACS_TIME *time_to_clear) | 10239 | set_waiting_for_input (struct timespec *time_to_clear) |
| 10239 | { | 10240 | { |
| 10240 | input_available_clear_time = time_to_clear; | 10241 | input_available_clear_time = time_to_clear; |
| 10241 | 10242 | ||
| @@ -10846,7 +10847,7 @@ init_keyboard (void) | |||
| 10846 | immediate_quit = 0; | 10847 | immediate_quit = 0; |
| 10847 | quit_char = Ctl ('g'); | 10848 | quit_char = Ctl ('g'); |
| 10848 | Vunread_command_events = Qnil; | 10849 | Vunread_command_events = Qnil; |
| 10849 | timer_idleness_start_time = invalid_emacs_time (); | 10850 | timer_idleness_start_time = invalid_timespec (); |
| 10850 | total_keys = 0; | 10851 | total_keys = 0; |
| 10851 | recent_keys_index = 0; | 10852 | recent_keys_index = 0; |
| 10852 | kbd_fetch_ptr = kbd_buffer; | 10853 | kbd_fetch_ptr = kbd_buffer; |
diff --git a/src/keyboard.h b/src/keyboard.h index daba94898d8..0953f1b7cfd 100644 --- a/src/keyboard.h +++ b/src/keyboard.h | |||
| @@ -17,7 +17,7 @@ GNU General Public License for more details. | |||
| 17 | You should have received a copy of the GNU General Public License | 17 | You should have received a copy of the GNU General Public License |
| 18 | along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | 18 | along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ |
| 19 | 19 | ||
| 20 | #include "systime.h" /* for EMACS_TIME, Time */ | 20 | #include "systime.h" /* for struct timespec, Time */ |
| 21 | #include "coding.h" /* for ENCODE_UTF_8 and ENCODE_SYSTEM */ | 21 | #include "coding.h" /* for ENCODE_UTF_8 and ENCODE_SYSTEM */ |
| 22 | 22 | ||
| 23 | INLINE_HEADER_BEGIN | 23 | INLINE_HEADER_BEGIN |
| @@ -466,9 +466,9 @@ extern Lisp_Object Qmode_line, Qvertical_line, Qheader_line; | |||
| 466 | /* True while doing kbd input. */ | 466 | /* True while doing kbd input. */ |
| 467 | extern bool waiting_for_input; | 467 | extern bool waiting_for_input; |
| 468 | 468 | ||
| 469 | /* Address (if not 0) of EMACS_TIME to zero out if a SIGIO interrupt | 469 | /* Address (if not 0) of struct timespec to zero out if a SIGIO interrupt |
| 470 | happens. */ | 470 | happens. */ |
| 471 | extern EMACS_TIME *input_available_clear_time; | 471 | extern struct timespec *input_available_clear_time; |
| 472 | 472 | ||
| 473 | #if defined HAVE_WINDOW_SYSTEM && !defined USE_GTK && !defined HAVE_NS | 473 | #if defined HAVE_WINDOW_SYSTEM && !defined USE_GTK && !defined HAVE_NS |
| 474 | extern bool ignore_mouse_drag_p; | 474 | extern bool ignore_mouse_drag_p; |
| @@ -483,7 +483,7 @@ struct input_event; | |||
| 483 | extern Lisp_Object parse_modifiers (Lisp_Object); | 483 | extern Lisp_Object parse_modifiers (Lisp_Object); |
| 484 | extern Lisp_Object reorder_modifiers (Lisp_Object); | 484 | extern Lisp_Object reorder_modifiers (Lisp_Object); |
| 485 | extern Lisp_Object read_char (int, Lisp_Object, Lisp_Object, | 485 | extern Lisp_Object read_char (int, Lisp_Object, Lisp_Object, |
| 486 | bool *, EMACS_TIME *); | 486 | bool *, struct timespec *); |
| 487 | extern int parse_solitary_modifier (Lisp_Object symbol); | 487 | extern int parse_solitary_modifier (Lisp_Object symbol); |
| 488 | 488 | ||
| 489 | 489 | ||
| @@ -549,7 +549,7 @@ extern bool kbd_buffer_events_waiting (void); | |||
| 549 | extern void add_user_signal (int, const char *); | 549 | extern void add_user_signal (int, const char *); |
| 550 | 550 | ||
| 551 | extern int tty_read_avail_input (struct terminal *, struct input_event *); | 551 | extern int tty_read_avail_input (struct terminal *, struct input_event *); |
| 552 | extern EMACS_TIME timer_check (void); | 552 | extern struct timespec timer_check (void); |
| 553 | extern void mark_kboards (void); | 553 | extern void mark_kboards (void); |
| 554 | 554 | ||
| 555 | #ifdef HAVE_NTGUI | 555 | #ifdef HAVE_NTGUI |
diff --git a/src/lread.c b/src/lread.c index 1f90970e93c..9518631ba6d 100644 --- a/src/lread.c +++ b/src/lread.c | |||
| @@ -609,7 +609,7 @@ read_filtered_event (bool no_switch_frame, bool ascii_required, | |||
| 609 | bool error_nonascii, bool input_method, Lisp_Object seconds) | 609 | bool error_nonascii, bool input_method, Lisp_Object seconds) |
| 610 | { | 610 | { |
| 611 | Lisp_Object val, delayed_switch_frame; | 611 | Lisp_Object val, delayed_switch_frame; |
| 612 | EMACS_TIME end_time; | 612 | struct timespec end_time; |
| 613 | 613 | ||
| 614 | #ifdef HAVE_WINDOW_SYSTEM | 614 | #ifdef HAVE_WINDOW_SYSTEM |
| 615 | if (display_hourglass_p) | 615 | if (display_hourglass_p) |
| @@ -622,8 +622,8 @@ read_filtered_event (bool no_switch_frame, bool ascii_required, | |||
| 622 | if (NUMBERP (seconds)) | 622 | if (NUMBERP (seconds)) |
| 623 | { | 623 | { |
| 624 | double duration = extract_float (seconds); | 624 | double duration = extract_float (seconds); |
| 625 | EMACS_TIME wait_time = EMACS_TIME_FROM_DOUBLE (duration); | 625 | struct timespec wait_time = dtotimespec (duration); |
| 626 | end_time = add_emacs_time (current_emacs_time (), wait_time); | 626 | end_time = timespec_add (current_timespec (), wait_time); |
| 627 | } | 627 | } |
| 628 | 628 | ||
| 629 | /* Read until we get an acceptable event. */ | 629 | /* Read until we get an acceptable event. */ |
| @@ -1262,7 +1262,7 @@ Return t if the file exists and loads successfully. */) | |||
| 1262 | } | 1262 | } |
| 1263 | 1263 | ||
| 1264 | if (result == 0 | 1264 | if (result == 0 |
| 1265 | && EMACS_TIME_LT (get_stat_mtime (&s1), get_stat_mtime (&s2))) | 1265 | && timespec_cmp (get_stat_mtime (&s1), get_stat_mtime (&s2)) < 0) |
| 1266 | { | 1266 | { |
| 1267 | /* Make the progress messages mention that source is newer. */ | 1267 | /* Make the progress messages mention that source is newer. */ |
| 1268 | newer = 1; | 1268 | newer = 1; |
diff --git a/src/msdos.c b/src/msdos.c index 6018f72bfae..3c78efbc47b 100644 --- a/src/msdos.c +++ b/src/msdos.c | |||
| @@ -4055,7 +4055,7 @@ dos_yield_time_slice (void) | |||
| 4055 | because wait_reading_process_output takes care of that. */ | 4055 | because wait_reading_process_output takes care of that. */ |
| 4056 | int | 4056 | int |
| 4057 | sys_select (int nfds, SELECT_TYPE *rfds, SELECT_TYPE *wfds, SELECT_TYPE *efds, | 4057 | sys_select (int nfds, SELECT_TYPE *rfds, SELECT_TYPE *wfds, SELECT_TYPE *efds, |
| 4058 | EMACS_TIME *timeout, void *ignored) | 4058 | struct timespec *timeout, void *ignored) |
| 4059 | { | 4059 | { |
| 4060 | int check_input; | 4060 | int check_input; |
| 4061 | struct timespec t; | 4061 | struct timespec t; |
| @@ -4085,20 +4085,20 @@ sys_select (int nfds, SELECT_TYPE *rfds, SELECT_TYPE *wfds, SELECT_TYPE *efds, | |||
| 4085 | } | 4085 | } |
| 4086 | else | 4086 | else |
| 4087 | { | 4087 | { |
| 4088 | EMACS_TIME clnow, cllast, cldiff; | 4088 | struct timespec clnow, cllast, cldiff; |
| 4089 | 4089 | ||
| 4090 | gettime (&t); | 4090 | gettime (&t); |
| 4091 | cllast = make_emacs_time (t.tv_sec, t.tv_nsec); | 4091 | cllast = make_timespec (t.tv_sec, t.tv_nsec); |
| 4092 | 4092 | ||
| 4093 | while (!check_input || !detect_input_pending ()) | 4093 | while (!check_input || !detect_input_pending ()) |
| 4094 | { | 4094 | { |
| 4095 | gettime (&t); | 4095 | gettime (&t); |
| 4096 | clnow = make_emacs_time (t.tv_sec, t.tv_nsec); | 4096 | clnow = make_timespec (t.tv_sec, t.tv_nsec); |
| 4097 | cldiff = sub_emacs_time (clnow, cllast); | 4097 | cldiff = timespec_sub (clnow, cllast); |
| 4098 | *timeout = sub_emacs_time (*timeout, cldiff); | 4098 | *timeout = timespec_sub (*timeout, cldiff); |
| 4099 | 4099 | ||
| 4100 | /* Stop when timeout value crosses zero. */ | 4100 | /* Stop when timeout value crosses zero. */ |
| 4101 | if (EMACS_TIME_SIGN (*timeout) <= 0) | 4101 | if (timespec_sign (*timeout) <= 0) |
| 4102 | return 0; | 4102 | return 0; |
| 4103 | cllast = clnow; | 4103 | cllast = clnow; |
| 4104 | dos_yield_time_slice (); | 4104 | dos_yield_time_slice (); |
diff --git a/src/nsmenu.m b/src/nsmenu.m index 7fe84343f1c..f9cd511efe9 100644 --- a/src/nsmenu.m +++ b/src/nsmenu.m | |||
| @@ -1867,11 +1867,11 @@ ns_popup_dialog (Lisp_Object position, Lisp_Object contents, Lisp_Object header) | |||
| 1867 | while (popup_activated_flag) | 1867 | while (popup_activated_flag) |
| 1868 | { | 1868 | { |
| 1869 | NSTimer *tmo = nil; | 1869 | NSTimer *tmo = nil; |
| 1870 | EMACS_TIME next_time = timer_check (); | 1870 | struct timespec next_time = timer_check (); |
| 1871 | 1871 | ||
| 1872 | if (EMACS_TIME_VALID_P (next_time)) | 1872 | if (timespec_valid_p (next_time)) |
| 1873 | { | 1873 | { |
| 1874 | double time = EMACS_TIME_TO_DOUBLE (next_time); | 1874 | double time = timespectod (next_time); |
| 1875 | tmo = [NSTimer timerWithTimeInterval: time | 1875 | tmo = [NSTimer timerWithTimeInterval: time |
| 1876 | target: self | 1876 | target: self |
| 1877 | selector: @selector (timeout_handler:) | 1877 | selector: @selector (timeout_handler:) |
diff --git a/src/nsterm.h b/src/nsterm.h index 4815cc4bb48..4e07d796250 100644 --- a/src/nsterm.h +++ b/src/nsterm.h | |||
| @@ -872,7 +872,7 @@ extern int x_display_pixel_width (struct ns_display_info *); | |||
| 872 | /* This in nsterm.m */ | 872 | /* This in nsterm.m */ |
| 873 | extern void x_destroy_window (struct frame *f); | 873 | extern void x_destroy_window (struct frame *f); |
| 874 | extern int ns_select (int nfds, fd_set *readfds, fd_set *writefds, | 874 | extern int ns_select (int nfds, fd_set *readfds, fd_set *writefds, |
| 875 | fd_set *exceptfds, EMACS_TIME const *timeout, | 875 | fd_set *exceptfds, struct timespec const *timeout, |
| 876 | sigset_t const *sigmask); | 876 | sigset_t const *sigmask); |
| 877 | extern unsigned long ns_get_rgb_color (struct frame *f, | 877 | extern unsigned long ns_get_rgb_color (struct frame *f, |
| 878 | float r, float g, float b, float a); | 878 | float r, float g, float b, float a); |
diff --git a/src/nsterm.m b/src/nsterm.m index f7f7b897830..ec365df0c22 100644 --- a/src/nsterm.m +++ b/src/nsterm.m | |||
| @@ -214,7 +214,7 @@ static NSTimer *scroll_repeat_entry = nil; | |||
| 214 | static fd_set select_readfds, select_writefds; | 214 | static fd_set select_readfds, select_writefds; |
| 215 | enum { SELECT_HAVE_READ = 1, SELECT_HAVE_WRITE = 2, SELECT_HAVE_TMO = 4 }; | 215 | enum { SELECT_HAVE_READ = 1, SELECT_HAVE_WRITE = 2, SELECT_HAVE_TMO = 4 }; |
| 216 | static int select_nfds = 0, select_valid = 0; | 216 | static int select_nfds = 0, select_valid = 0; |
| 217 | static EMACS_TIME select_timeout = { 0, 0 }; | 217 | static struct timespec select_timeout = { 0, 0 }; |
| 218 | static int selfds[2] = { -1, -1 }; | 218 | static int selfds[2] = { -1, -1 }; |
| 219 | static pthread_mutex_t select_mutex; | 219 | static pthread_mutex_t select_mutex; |
| 220 | static int apploopnr = 0; | 220 | static int apploopnr = 0; |
| @@ -485,16 +485,16 @@ ns_timeout (int usecs) | |||
| 485 | Blocking timer utility used by ns_ring_bell | 485 | Blocking timer utility used by ns_ring_bell |
| 486 | -------------------------------------------------------------------------- */ | 486 | -------------------------------------------------------------------------- */ |
| 487 | { | 487 | { |
| 488 | EMACS_TIME wakeup = add_emacs_time (current_emacs_time (), | 488 | struct timespec wakeup = timespec_add (current_timespec (), |
| 489 | make_emacs_time (0, usecs * 1000)); | 489 | make_timespec (0, usecs * 1000)); |
| 490 | 490 | ||
| 491 | /* Keep waiting until past the time wakeup. */ | 491 | /* Keep waiting until past the time wakeup. */ |
| 492 | while (1) | 492 | while (1) |
| 493 | { | 493 | { |
| 494 | EMACS_TIME timeout, now = current_emacs_time (); | 494 | struct timespec timeout, now = current_timespec (); |
| 495 | if (EMACS_TIME_LE (wakeup, now)) | 495 | if (timespec_cmp (wakeup, now) <= 0) |
| 496 | break; | 496 | break; |
| 497 | timeout = sub_emacs_time (wakeup, now); | 497 | timeout = timespec_sub (wakeup, now); |
| 498 | 498 | ||
| 499 | /* Try to wait that long--but we might wake up sooner. */ | 499 | /* Try to wait that long--but we might wake up sooner. */ |
| 500 | pselect (0, NULL, NULL, NULL, &timeout, NULL); | 500 | pselect (0, NULL, NULL, NULL, &timeout, NULL); |
| @@ -3529,7 +3529,7 @@ ns_read_socket (struct terminal *terminal, struct input_event *hold_quit) | |||
| 3529 | 3529 | ||
| 3530 | int | 3530 | int |
| 3531 | ns_select (int nfds, fd_set *readfds, fd_set *writefds, | 3531 | ns_select (int nfds, fd_set *readfds, fd_set *writefds, |
| 3532 | fd_set *exceptfds, EMACS_TIME const *timeout, | 3532 | fd_set *exceptfds, struct timespec const *timeout, |
| 3533 | sigset_t const *sigmask) | 3533 | sigset_t const *sigmask) |
| 3534 | /* -------------------------------------------------------------------------- | 3534 | /* -------------------------------------------------------------------------- |
| 3535 | Replacement for select, checking for events | 3535 | Replacement for select, checking for events |
| @@ -3600,7 +3600,7 @@ ns_select (int nfds, fd_set *readfds, fd_set *writefds, | |||
| 3600 | else if (nr == 0 && timeout) | 3600 | else if (nr == 0 && timeout) |
| 3601 | { | 3601 | { |
| 3602 | /* No file descriptor, just a timeout, no need to wake fd_handler */ | 3602 | /* No file descriptor, just a timeout, no need to wake fd_handler */ |
| 3603 | double time = EMACS_TIME_TO_DOUBLE (*timeout); | 3603 | double time = timespectod (*timeout); |
| 3604 | timed_entry = [[NSTimer scheduledTimerWithTimeInterval: time | 3604 | timed_entry = [[NSTimer scheduledTimerWithTimeInterval: time |
| 3605 | target: NSApp | 3605 | target: NSApp |
| 3606 | selector: | 3606 | selector: |
| @@ -4687,7 +4687,7 @@ not_in_argv (NSString *arg) | |||
| 4687 | char c; | 4687 | char c; |
| 4688 | 4688 | ||
| 4689 | SELECT_TYPE readfds, writefds, *wfds; | 4689 | SELECT_TYPE readfds, writefds, *wfds; |
| 4690 | EMACS_TIME timeout, *tmo; | 4690 | struct timespec timeout, *tmo; |
| 4691 | NSAutoreleasePool *pool = nil; | 4691 | NSAutoreleasePool *pool = nil; |
| 4692 | 4692 | ||
| 4693 | /* NSTRACE (fd_handler); */ | 4693 | /* NSTRACE (fd_handler); */ |
diff --git a/src/process.c b/src/process.c index c5e691bf602..3b62f45bf0a 100644 --- a/src/process.c +++ b/src/process.c | |||
| @@ -133,7 +133,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 133 | 133 | ||
| 134 | #ifdef WINDOWSNT | 134 | #ifdef WINDOWSNT |
| 135 | extern int sys_select (int, SELECT_TYPE *, SELECT_TYPE *, SELECT_TYPE *, | 135 | extern int sys_select (int, SELECT_TYPE *, SELECT_TYPE *, SELECT_TYPE *, |
| 136 | EMACS_TIME *, void *); | 136 | struct timespec *, void *); |
| 137 | #endif | 137 | #endif |
| 138 | 138 | ||
| 139 | #ifndef SOCK_CLOEXEC | 139 | #ifndef SOCK_CLOEXEC |
| @@ -261,7 +261,7 @@ static EMACS_INT update_tick; | |||
| 261 | #endif | 261 | #endif |
| 262 | 262 | ||
| 263 | #ifdef ADAPTIVE_READ_BUFFERING | 263 | #ifdef ADAPTIVE_READ_BUFFERING |
| 264 | #define READ_OUTPUT_DELAY_INCREMENT (EMACS_TIME_RESOLUTION / 100) | 264 | #define READ_OUTPUT_DELAY_INCREMENT (TIMESPEC_RESOLUTION / 100) |
| 265 | #define READ_OUTPUT_DELAY_MAX (READ_OUTPUT_DELAY_INCREMENT * 5) | 265 | #define READ_OUTPUT_DELAY_MAX (READ_OUTPUT_DELAY_INCREMENT * 5) |
| 266 | #define READ_OUTPUT_DELAY_MAX_MAX (READ_OUTPUT_DELAY_INCREMENT * 7) | 266 | #define READ_OUTPUT_DELAY_MAX_MAX (READ_OUTPUT_DELAY_INCREMENT * 7) |
| 267 | 267 | ||
| @@ -3932,9 +3932,9 @@ Return non-nil if we received any output before the timeout expired. */) | |||
| 3932 | { | 3932 | { |
| 3933 | if (XFLOAT_DATA (seconds) > 0) | 3933 | if (XFLOAT_DATA (seconds) > 0) |
| 3934 | { | 3934 | { |
| 3935 | EMACS_TIME t = EMACS_TIME_FROM_DOUBLE (XFLOAT_DATA (seconds)); | 3935 | struct timespec t = dtotimespec (XFLOAT_DATA (seconds)); |
| 3936 | secs = min (EMACS_SECS (t), WAIT_READING_MAX); | 3936 | secs = min (t.tv_sec, WAIT_READING_MAX); |
| 3937 | nsecs = EMACS_NSECS (t); | 3937 | nsecs = t.tv_nsec; |
| 3938 | } | 3938 | } |
| 3939 | } | 3939 | } |
| 3940 | else | 3940 | else |
| @@ -4239,7 +4239,7 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd, | |||
| 4239 | bool no_avail; | 4239 | bool no_avail; |
| 4240 | int xerrno; | 4240 | int xerrno; |
| 4241 | Lisp_Object proc; | 4241 | Lisp_Object proc; |
| 4242 | EMACS_TIME timeout, end_time; | 4242 | struct timespec timeout, end_time; |
| 4243 | int wait_channel = -1; | 4243 | int wait_channel = -1; |
| 4244 | bool got_some_input = 0; | 4244 | bool got_some_input = 0; |
| 4245 | ptrdiff_t count = SPECPDL_INDEX (); | 4245 | ptrdiff_t count = SPECPDL_INDEX (); |
| @@ -4272,8 +4272,8 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd, | |||
| 4272 | compute the absolute time to return at. */ | 4272 | compute the absolute time to return at. */ |
| 4273 | if (time_limit || nsecs > 0) | 4273 | if (time_limit || nsecs > 0) |
| 4274 | { | 4274 | { |
| 4275 | timeout = make_emacs_time (time_limit, nsecs); | 4275 | timeout = make_timespec (time_limit, nsecs); |
| 4276 | end_time = add_emacs_time (current_emacs_time (), timeout); | 4276 | end_time = timespec_add (current_timespec (), timeout); |
| 4277 | } | 4277 | } |
| 4278 | 4278 | ||
| 4279 | while (1) | 4279 | while (1) |
| @@ -4300,18 +4300,18 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd, | |||
| 4300 | gobble output available now | 4300 | gobble output available now |
| 4301 | but don't wait at all. */ | 4301 | but don't wait at all. */ |
| 4302 | 4302 | ||
| 4303 | timeout = make_emacs_time (0, 0); | 4303 | timeout = make_timespec (0, 0); |
| 4304 | } | 4304 | } |
| 4305 | else if (time_limit || nsecs > 0) | 4305 | else if (time_limit || nsecs > 0) |
| 4306 | { | 4306 | { |
| 4307 | EMACS_TIME now = current_emacs_time (); | 4307 | struct timespec now = current_timespec (); |
| 4308 | if (EMACS_TIME_LE (end_time, now)) | 4308 | if (timespec_cmp (end_time, now) <= 0) |
| 4309 | break; | 4309 | break; |
| 4310 | timeout = sub_emacs_time (end_time, now); | 4310 | timeout = timespec_sub (end_time, now); |
| 4311 | } | 4311 | } |
| 4312 | else | 4312 | else |
| 4313 | { | 4313 | { |
| 4314 | timeout = make_emacs_time (100000, 0); | 4314 | timeout = make_timespec (100000, 0); |
| 4315 | } | 4315 | } |
| 4316 | 4316 | ||
| 4317 | /* Normally we run timers here. | 4317 | /* Normally we run timers here. |
| @@ -4321,7 +4321,7 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd, | |||
| 4321 | if (NILP (wait_for_cell) | 4321 | if (NILP (wait_for_cell) |
| 4322 | && just_wait_proc >= 0) | 4322 | && just_wait_proc >= 0) |
| 4323 | { | 4323 | { |
| 4324 | EMACS_TIME timer_delay; | 4324 | struct timespec timer_delay; |
| 4325 | 4325 | ||
| 4326 | do | 4326 | do |
| 4327 | { | 4327 | { |
| @@ -4356,9 +4356,9 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd, | |||
| 4356 | /* A negative timeout means do not wait at all. */ | 4356 | /* A negative timeout means do not wait at all. */ |
| 4357 | if (nsecs >= 0) | 4357 | if (nsecs >= 0) |
| 4358 | { | 4358 | { |
| 4359 | if (EMACS_TIME_VALID_P (timer_delay)) | 4359 | if (timespec_valid_p (timer_delay)) |
| 4360 | { | 4360 | { |
| 4361 | if (EMACS_TIME_LT (timer_delay, timeout)) | 4361 | if (timespec_cmp (timer_delay, timeout) < 0) |
| 4362 | { | 4362 | { |
| 4363 | timeout = timer_delay; | 4363 | timeout = timer_delay; |
| 4364 | timeout_reduced_for_timers = 1; | 4364 | timeout_reduced_for_timers = 1; |
| @@ -4396,7 +4396,7 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd, | |||
| 4396 | Atemp = input_wait_mask; | 4396 | Atemp = input_wait_mask; |
| 4397 | Ctemp = write_mask; | 4397 | Ctemp = write_mask; |
| 4398 | 4398 | ||
| 4399 | timeout = make_emacs_time (0, 0); | 4399 | timeout = make_timespec (0, 0); |
| 4400 | if ((pselect (max (max_process_desc, max_input_desc) + 1, | 4400 | if ((pselect (max (max_process_desc, max_input_desc) + 1, |
| 4401 | &Atemp, | 4401 | &Atemp, |
| 4402 | #ifdef NON_BLOCKING_CONNECT | 4402 | #ifdef NON_BLOCKING_CONNECT |
| @@ -4518,8 +4518,8 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd, | |||
| 4518 | Vprocess_adaptive_read_buffering is nil. */ | 4518 | Vprocess_adaptive_read_buffering is nil. */ |
| 4519 | if (process_output_skip && check_delay > 0) | 4519 | if (process_output_skip && check_delay > 0) |
| 4520 | { | 4520 | { |
| 4521 | int nsecs = EMACS_NSECS (timeout); | 4521 | int nsecs = timeout.tv_nsec; |
| 4522 | if (EMACS_SECS (timeout) > 0 || nsecs > READ_OUTPUT_DELAY_MAX) | 4522 | if (timeout.tv_sec > 0 || nsecs > READ_OUTPUT_DELAY_MAX) |
| 4523 | nsecs = READ_OUTPUT_DELAY_MAX; | 4523 | nsecs = READ_OUTPUT_DELAY_MAX; |
| 4524 | for (channel = 0; check_delay > 0 && channel <= max_process_desc; channel++) | 4524 | for (channel = 0; check_delay > 0 && channel <= max_process_desc; channel++) |
| 4525 | { | 4525 | { |
| @@ -4539,7 +4539,7 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd, | |||
| 4539 | nsecs = XPROCESS (proc)->read_output_delay; | 4539 | nsecs = XPROCESS (proc)->read_output_delay; |
| 4540 | } | 4540 | } |
| 4541 | } | 4541 | } |
| 4542 | timeout = make_emacs_time (0, nsecs); | 4542 | timeout = make_timespec (0, nsecs); |
| 4543 | process_output_skip = 0; | 4543 | process_output_skip = 0; |
| 4544 | } | 4544 | } |
| 4545 | #endif | 4545 | #endif |
| @@ -6543,7 +6543,7 @@ keyboard_bit_set (fd_set *mask) | |||
| 6543 | 6543 | ||
| 6544 | /* Defined on msdos.c. */ | 6544 | /* Defined on msdos.c. */ |
| 6545 | extern int sys_select (int, SELECT_TYPE *, SELECT_TYPE *, SELECT_TYPE *, | 6545 | extern int sys_select (int, SELECT_TYPE *, SELECT_TYPE *, SELECT_TYPE *, |
| 6546 | EMACS_TIME *, void *); | 6546 | struct timespec *, void *); |
| 6547 | 6547 | ||
| 6548 | /* Implementation of wait_reading_process_output, assuming that there | 6548 | /* Implementation of wait_reading_process_output, assuming that there |
| 6549 | are no subprocesses. Used only by the MS-DOS build. | 6549 | are no subprocesses. Used only by the MS-DOS build. |
| @@ -6582,7 +6582,7 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd, | |||
| 6582 | struct Lisp_Process *wait_proc, int just_wait_proc) | 6582 | struct Lisp_Process *wait_proc, int just_wait_proc) |
| 6583 | { | 6583 | { |
| 6584 | register int nfds; | 6584 | register int nfds; |
| 6585 | EMACS_TIME end_time, timeout; | 6585 | struct timespec end_time, timeout; |
| 6586 | 6586 | ||
| 6587 | if (time_limit < 0) | 6587 | if (time_limit < 0) |
| 6588 | { | 6588 | { |
| @@ -6595,8 +6595,8 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd, | |||
| 6595 | /* What does time_limit really mean? */ | 6595 | /* What does time_limit really mean? */ |
| 6596 | if (time_limit || nsecs > 0) | 6596 | if (time_limit || nsecs > 0) |
| 6597 | { | 6597 | { |
| 6598 | timeout = make_emacs_time (time_limit, nsecs); | 6598 | timeout = make_timespec (time_limit, nsecs); |
| 6599 | end_time = add_emacs_time (current_emacs_time (), timeout); | 6599 | end_time = timespec_add (current_timespec (), timeout); |
| 6600 | } | 6600 | } |
| 6601 | 6601 | ||
| 6602 | /* Turn off periodic alarms (in case they are in use) | 6602 | /* Turn off periodic alarms (in case they are in use) |
| @@ -6629,18 +6629,18 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd, | |||
| 6629 | gobble output available now | 6629 | gobble output available now |
| 6630 | but don't wait at all. */ | 6630 | but don't wait at all. */ |
| 6631 | 6631 | ||
| 6632 | timeout = make_emacs_time (0, 0); | 6632 | timeout = make_timespec (0, 0); |
| 6633 | } | 6633 | } |
| 6634 | else if (time_limit || nsecs > 0) | 6634 | else if (time_limit || nsecs > 0) |
| 6635 | { | 6635 | { |
| 6636 | EMACS_TIME now = current_emacs_time (); | 6636 | struct timespec now = current_timespec (); |
| 6637 | if (EMACS_TIME_LE (end_time, now)) | 6637 | if (timespec_cmp (end_time, now) <= 0) |
| 6638 | break; | 6638 | break; |
| 6639 | timeout = sub_emacs_time (end_time, now); | 6639 | timeout = timespec_sub (end_time, now); |
| 6640 | } | 6640 | } |
| 6641 | else | 6641 | else |
| 6642 | { | 6642 | { |
| 6643 | timeout = make_emacs_time (100000, 0); | 6643 | timeout = make_timespec (100000, 0); |
| 6644 | } | 6644 | } |
| 6645 | 6645 | ||
| 6646 | /* If our caller will not immediately handle keyboard events, | 6646 | /* If our caller will not immediately handle keyboard events, |
| @@ -6649,7 +6649,7 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd, | |||
| 6649 | call timer_delay on their own.) */ | 6649 | call timer_delay on their own.) */ |
| 6650 | if (NILP (wait_for_cell)) | 6650 | if (NILP (wait_for_cell)) |
| 6651 | { | 6651 | { |
| 6652 | EMACS_TIME timer_delay; | 6652 | struct timespec timer_delay; |
| 6653 | 6653 | ||
| 6654 | do | 6654 | do |
| 6655 | { | 6655 | { |
| @@ -6669,9 +6669,9 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd, | |||
| 6669 | && requeued_events_pending_p ()) | 6669 | && requeued_events_pending_p ()) |
| 6670 | break; | 6670 | break; |
| 6671 | 6671 | ||
| 6672 | if (EMACS_TIME_VALID_P (timer_delay) && nsecs >= 0) | 6672 | if (timespec_valid_p (timer_delay) && nsecs >= 0) |
| 6673 | { | 6673 | { |
| 6674 | if (EMACS_TIME_LT (timer_delay, timeout)) | 6674 | if (timespec_cmp (timer_delay, timeout) < 0) |
| 6675 | { | 6675 | { |
| 6676 | timeout = timer_delay; | 6676 | timeout = timer_delay; |
| 6677 | timeout_reduced_for_timers = 1; | 6677 | timeout_reduced_for_timers = 1; |
diff --git a/src/profiler.c b/src/profiler.c index c86fb47d21d..64eb5cafc25 100644 --- a/src/profiler.c +++ b/src/profiler.c | |||
| @@ -267,8 +267,8 @@ setup_cpu_timer (Lisp_Object sampling_interval) | |||
| 267 | return NOT_RUNNING; | 267 | return NOT_RUNNING; |
| 268 | 268 | ||
| 269 | current_sampling_interval = XINT (sampling_interval); | 269 | current_sampling_interval = XINT (sampling_interval); |
| 270 | interval = make_emacs_time (current_sampling_interval / billion, | 270 | interval = make_timespec (current_sampling_interval / billion, |
| 271 | current_sampling_interval % billion); | 271 | current_sampling_interval % billion); |
| 272 | emacs_sigaction_init (&action, deliver_profiler_signal); | 272 | emacs_sigaction_init (&action, deliver_profiler_signal); |
| 273 | sigaction (SIGPROF, &action, 0); | 273 | sigaction (SIGPROF, &action, 0); |
| 274 | 274 | ||
diff --git a/src/sysdep.c b/src/sysdep.c index 0d732526528..e43991f41ab 100644 --- a/src/sysdep.c +++ b/src/sysdep.c | |||
| @@ -306,7 +306,7 @@ get_child_status (pid_t child, int *status, int options, bool interruptible) | |||
| 306 | /* If successful and status is requested, tell wait_reading_process_output | 306 | /* If successful and status is requested, tell wait_reading_process_output |
| 307 | that it needs to wake up and look around. */ | 307 | that it needs to wake up and look around. */ |
| 308 | if (pid && status && input_available_clear_time) | 308 | if (pid && status && input_available_clear_time) |
| 309 | *input_available_clear_time = make_emacs_time (0, 0); | 309 | *input_available_clear_time = make_timespec (0, 0); |
| 310 | 310 | ||
| 311 | return pid; | 311 | return pid; |
| 312 | } | 312 | } |
| @@ -2021,8 +2021,8 @@ seed_random (void *seed, ptrdiff_t seed_size) | |||
| 2021 | void | 2021 | void |
| 2022 | init_random (void) | 2022 | init_random (void) |
| 2023 | { | 2023 | { |
| 2024 | EMACS_TIME t = current_emacs_time (); | 2024 | struct timespec t = current_timespec (); |
| 2025 | uintmax_t v = getpid () ^ EMACS_SECS (t) ^ EMACS_NSECS (t); | 2025 | uintmax_t v = getpid () ^ t.tv_sec ^ t.tv_nsec; |
| 2026 | seed_random (&v, sizeof v); | 2026 | seed_random (&v, sizeof v); |
| 2027 | } | 2027 | } |
| 2028 | 2028 | ||
| @@ -2357,7 +2357,7 @@ emacs_perror (char const *message) | |||
| 2357 | Use the least timeval not less than T. | 2357 | Use the least timeval not less than T. |
| 2358 | Return an extremal value if the result would overflow. */ | 2358 | Return an extremal value if the result would overflow. */ |
| 2359 | struct timeval | 2359 | struct timeval |
| 2360 | make_timeval (EMACS_TIME t) | 2360 | make_timeval (struct timespec t) |
| 2361 | { | 2361 | { |
| 2362 | struct timeval tv; | 2362 | struct timeval tv; |
| 2363 | tv.tv_sec = t.tv_sec; | 2363 | tv.tv_sec = t.tv_sec; |
| @@ -2384,7 +2384,7 @@ make_timeval (EMACS_TIME t) | |||
| 2384 | If FD is nonnegative, then FILE can be NULL. */ | 2384 | If FD is nonnegative, then FILE can be NULL. */ |
| 2385 | int | 2385 | int |
| 2386 | set_file_times (int fd, const char *filename, | 2386 | set_file_times (int fd, const char *filename, |
| 2387 | EMACS_TIME atime, EMACS_TIME mtime) | 2387 | struct timespec atime, struct timespec mtime) |
| 2388 | { | 2388 | { |
| 2389 | struct timespec timespec[2]; | 2389 | struct timespec timespec[2]; |
| 2390 | timespec[0] = atime; | 2390 | timespec[0] = atime; |
| @@ -2701,7 +2701,7 @@ list_system_processes (void) | |||
| 2701 | #endif /* !defined (WINDOWSNT) */ | 2701 | #endif /* !defined (WINDOWSNT) */ |
| 2702 | 2702 | ||
| 2703 | #if defined GNU_LINUX && defined HAVE_LONG_LONG_INT | 2703 | #if defined GNU_LINUX && defined HAVE_LONG_LONG_INT |
| 2704 | static EMACS_TIME | 2704 | static struct timespec |
| 2705 | time_from_jiffies (unsigned long long tval, long hz) | 2705 | time_from_jiffies (unsigned long long tval, long hz) |
| 2706 | { | 2706 | { |
| 2707 | unsigned long long s = tval / hz; | 2707 | unsigned long long s = tval / hz; |
| @@ -2710,34 +2710,34 @@ time_from_jiffies (unsigned long long tval, long hz) | |||
| 2710 | 2710 | ||
| 2711 | if (TYPE_MAXIMUM (time_t) < s) | 2711 | if (TYPE_MAXIMUM (time_t) < s) |
| 2712 | time_overflow (); | 2712 | time_overflow (); |
| 2713 | if (LONG_MAX - 1 <= ULLONG_MAX / EMACS_TIME_RESOLUTION | 2713 | if (LONG_MAX - 1 <= ULLONG_MAX / TIMESPEC_RESOLUTION |
| 2714 | || frac <= ULLONG_MAX / EMACS_TIME_RESOLUTION) | 2714 | || frac <= ULLONG_MAX / TIMESPEC_RESOLUTION) |
| 2715 | ns = frac * EMACS_TIME_RESOLUTION / hz; | 2715 | ns = frac * TIMESPEC_RESOLUTION / hz; |
| 2716 | else | 2716 | else |
| 2717 | { | 2717 | { |
| 2718 | /* This is reachable only in the unlikely case that HZ * HZ | 2718 | /* This is reachable only in the unlikely case that HZ * HZ |
| 2719 | exceeds ULLONG_MAX. It calculates an approximation that is | 2719 | exceeds ULLONG_MAX. It calculates an approximation that is |
| 2720 | guaranteed to be in range. */ | 2720 | guaranteed to be in range. */ |
| 2721 | long hz_per_ns = (hz / EMACS_TIME_RESOLUTION | 2721 | long hz_per_ns = (hz / TIMESPEC_RESOLUTION |
| 2722 | + (hz % EMACS_TIME_RESOLUTION != 0)); | 2722 | + (hz % TIMESPEC_RESOLUTION != 0)); |
| 2723 | ns = frac / hz_per_ns; | 2723 | ns = frac / hz_per_ns; |
| 2724 | } | 2724 | } |
| 2725 | 2725 | ||
| 2726 | return make_emacs_time (s, ns); | 2726 | return make_timespec (s, ns); |
| 2727 | } | 2727 | } |
| 2728 | 2728 | ||
| 2729 | static Lisp_Object | 2729 | static Lisp_Object |
| 2730 | ltime_from_jiffies (unsigned long long tval, long hz) | 2730 | ltime_from_jiffies (unsigned long long tval, long hz) |
| 2731 | { | 2731 | { |
| 2732 | EMACS_TIME t = time_from_jiffies (tval, hz); | 2732 | struct timespec t = time_from_jiffies (tval, hz); |
| 2733 | return make_lisp_time (t); | 2733 | return make_lisp_time (t); |
| 2734 | } | 2734 | } |
| 2735 | 2735 | ||
| 2736 | static EMACS_TIME | 2736 | static struct timespec |
| 2737 | get_up_time (void) | 2737 | get_up_time (void) |
| 2738 | { | 2738 | { |
| 2739 | FILE *fup; | 2739 | FILE *fup; |
| 2740 | EMACS_TIME up = make_emacs_time (0, 0); | 2740 | struct timespec up = make_timespec (0, 0); |
| 2741 | 2741 | ||
| 2742 | block_input (); | 2742 | block_input (); |
| 2743 | fup = emacs_fopen ("/proc/uptime", "r"); | 2743 | fup = emacs_fopen ("/proc/uptime", "r"); |
| @@ -2755,18 +2755,18 @@ get_up_time (void) | |||
| 2755 | if (TYPE_MAXIMUM (time_t) < upsec) | 2755 | if (TYPE_MAXIMUM (time_t) < upsec) |
| 2756 | { | 2756 | { |
| 2757 | upsec = TYPE_MAXIMUM (time_t); | 2757 | upsec = TYPE_MAXIMUM (time_t); |
| 2758 | upfrac = EMACS_TIME_RESOLUTION - 1; | 2758 | upfrac = TIMESPEC_RESOLUTION - 1; |
| 2759 | } | 2759 | } |
| 2760 | else | 2760 | else |
| 2761 | { | 2761 | { |
| 2762 | int upfraclen = upfrac_end - upfrac_start; | 2762 | int upfraclen = upfrac_end - upfrac_start; |
| 2763 | for (; upfraclen < LOG10_EMACS_TIME_RESOLUTION; upfraclen++) | 2763 | for (; upfraclen < LOG10_TIMESPEC_RESOLUTION; upfraclen++) |
| 2764 | upfrac *= 10; | 2764 | upfrac *= 10; |
| 2765 | for (; LOG10_EMACS_TIME_RESOLUTION < upfraclen; upfraclen--) | 2765 | for (; LOG10_TIMESPEC_RESOLUTION < upfraclen; upfraclen--) |
| 2766 | upfrac /= 10; | 2766 | upfrac /= 10; |
| 2767 | upfrac = min (upfrac, EMACS_TIME_RESOLUTION - 1); | 2767 | upfrac = min (upfrac, TIMESPEC_RESOLUTION - 1); |
| 2768 | } | 2768 | } |
| 2769 | up = make_emacs_time (upsec, upfrac); | 2769 | up = make_timespec (upsec, upfrac); |
| 2770 | } | 2770 | } |
| 2771 | fclose (fup); | 2771 | fclose (fup); |
| 2772 | } | 2772 | } |
| @@ -2887,7 +2887,7 @@ system_process_attributes (Lisp_Object pid) | |||
| 2887 | unsigned long long u_time, s_time, cutime, cstime, start; | 2887 | unsigned long long u_time, s_time, cutime, cstime, start; |
| 2888 | long priority, niceness, rss; | 2888 | long priority, niceness, rss; |
| 2889 | unsigned long minflt, majflt, cminflt, cmajflt, vsize; | 2889 | unsigned long minflt, majflt, cminflt, cmajflt, vsize; |
| 2890 | EMACS_TIME tnow, tstart, tboot, telapsed, us_time; | 2890 | struct timespec tnow, tstart, tboot, telapsed, us_time; |
| 2891 | double pcpu, pmem; | 2891 | double pcpu, pmem; |
| 2892 | Lisp_Object attrs = Qnil; | 2892 | Lisp_Object attrs = Qnil; |
| 2893 | Lisp_Object cmd_str, decoded_cmd; | 2893 | Lisp_Object cmd_str, decoded_cmd; |
| @@ -3008,20 +3008,19 @@ system_process_attributes (Lisp_Object pid) | |||
| 3008 | attrs = Fcons (Fcons (Qnice, make_number (niceness)), attrs); | 3008 | attrs = Fcons (Fcons (Qnice, make_number (niceness)), attrs); |
| 3009 | attrs = Fcons (Fcons (Qthcount, make_fixnum_or_float (thcount)), | 3009 | attrs = Fcons (Fcons (Qthcount, make_fixnum_or_float (thcount)), |
| 3010 | attrs); | 3010 | attrs); |
| 3011 | tnow = current_emacs_time (); | 3011 | tnow = current_timespec (); |
| 3012 | telapsed = get_up_time (); | 3012 | telapsed = get_up_time (); |
| 3013 | tboot = sub_emacs_time (tnow, telapsed); | 3013 | tboot = timespec_sub (tnow, telapsed); |
| 3014 | tstart = time_from_jiffies (start, clocks_per_sec); | 3014 | tstart = time_from_jiffies (start, clocks_per_sec); |
| 3015 | tstart = add_emacs_time (tboot, tstart); | 3015 | tstart = timespec_add (tboot, tstart); |
| 3016 | attrs = Fcons (Fcons (Qstart, make_lisp_time (tstart)), attrs); | 3016 | attrs = Fcons (Fcons (Qstart, make_lisp_time (tstart)), attrs); |
| 3017 | attrs = Fcons (Fcons (Qvsize, make_fixnum_or_float (vsize / 1024)), | 3017 | attrs = Fcons (Fcons (Qvsize, make_fixnum_or_float (vsize / 1024)), |
| 3018 | attrs); | 3018 | attrs); |
| 3019 | attrs = Fcons (Fcons (Qrss, make_fixnum_or_float (4 * rss)), attrs); | 3019 | attrs = Fcons (Fcons (Qrss, make_fixnum_or_float (4 * rss)), attrs); |
| 3020 | telapsed = sub_emacs_time (tnow, tstart); | 3020 | telapsed = timespec_sub (tnow, tstart); |
| 3021 | attrs = Fcons (Fcons (Qetime, make_lisp_time (telapsed)), attrs); | 3021 | attrs = Fcons (Fcons (Qetime, make_lisp_time (telapsed)), attrs); |
| 3022 | us_time = time_from_jiffies (u_time + s_time, clocks_per_sec); | 3022 | us_time = time_from_jiffies (u_time + s_time, clocks_per_sec); |
| 3023 | pcpu = (EMACS_TIME_TO_DOUBLE (us_time) | 3023 | pcpu = timespectod (us_time) / timespectod (telapsed); |
| 3024 | / EMACS_TIME_TO_DOUBLE (telapsed)); | ||
| 3025 | if (pcpu > 1.0) | 3024 | if (pcpu > 1.0) |
| 3026 | pcpu = 1.0; | 3025 | pcpu = 1.0; |
| 3027 | attrs = Fcons (Fcons (Qpcpu, make_float (100 * pcpu)), attrs); | 3026 | attrs = Fcons (Fcons (Qpcpu, make_float (100 * pcpu)), attrs); |
| @@ -3239,16 +3238,16 @@ system_process_attributes (Lisp_Object pid) | |||
| 3239 | 3238 | ||
| 3240 | #elif defined __FreeBSD__ | 3239 | #elif defined __FreeBSD__ |
| 3241 | 3240 | ||
| 3242 | static EMACS_TIME | 3241 | static struct timespec |
| 3243 | timeval_to_EMACS_TIME (struct timeval t) | 3242 | timeval_to_timespec (struct timeval t) |
| 3244 | { | 3243 | { |
| 3245 | return make_emacs_time (t.tv_sec, t.tv_usec * 1000); | 3244 | return make_timespec (t.tv_sec, t.tv_usec * 1000); |
| 3246 | } | 3245 | } |
| 3247 | 3246 | ||
| 3248 | static Lisp_Object | 3247 | static Lisp_Object |
| 3249 | make_lisp_timeval (struct timeval t) | 3248 | make_lisp_timeval (struct timeval t) |
| 3250 | { | 3249 | { |
| 3251 | return make_lisp_time (timeval_to_EMACS_TIME (t)); | 3250 | return make_lisp_time (timeval_to_timespec (t)); |
| 3252 | } | 3251 | } |
| 3253 | 3252 | ||
| 3254 | Lisp_Object | 3253 | Lisp_Object |
| @@ -3263,7 +3262,7 @@ system_process_attributes (Lisp_Object pid) | |||
| 3263 | char *ttyname; | 3262 | char *ttyname; |
| 3264 | size_t len; | 3263 | size_t len; |
| 3265 | char args[MAXPATHLEN]; | 3264 | char args[MAXPATHLEN]; |
| 3266 | EMACS_TIME t, now; | 3265 | struct timespec t, now; |
| 3267 | 3266 | ||
| 3268 | int mib[4] = {CTL_KERN, KERN_PROC, KERN_PROC_PID}; | 3267 | int mib[4] = {CTL_KERN, KERN_PROC, KERN_PROC_PID}; |
| 3269 | struct kinfo_proc proc; | 3268 | struct kinfo_proc proc; |
| @@ -3350,8 +3349,8 @@ system_process_attributes (Lisp_Object pid) | |||
| 3350 | attrs); | 3349 | attrs); |
| 3351 | attrs = Fcons (Fcons (Qstime, make_lisp_timeval (proc.ki_rusage.ru_stime)), | 3350 | attrs = Fcons (Fcons (Qstime, make_lisp_timeval (proc.ki_rusage.ru_stime)), |
| 3352 | attrs); | 3351 | attrs); |
| 3353 | t = add_emacs_time (timeval_to_EMACS_TIME (proc.ki_rusage.ru_utime), | 3352 | t = timespec_add (timeval_to_timespec (proc.ki_rusage.ru_utime), |
| 3354 | timeval_to_EMACS_TIME (proc.ki_rusage.ru_stime)); | 3353 | timeval_to_timespec (proc.ki_rusage.ru_stime)); |
| 3355 | attrs = Fcons (Fcons (Qtime, make_lisp_time (t)), attrs); | 3354 | attrs = Fcons (Fcons (Qtime, make_lisp_time (t)), attrs); |
| 3356 | 3355 | ||
| 3357 | attrs = Fcons (Fcons (Qcutime, | 3356 | attrs = Fcons (Fcons (Qcutime, |
| @@ -3360,8 +3359,8 @@ system_process_attributes (Lisp_Object pid) | |||
| 3360 | attrs = Fcons (Fcons (Qcstime, | 3359 | attrs = Fcons (Fcons (Qcstime, |
| 3361 | make_lisp_timeval (proc.ki_rusage_ch.ru_utime)), | 3360 | make_lisp_timeval (proc.ki_rusage_ch.ru_utime)), |
| 3362 | attrs); | 3361 | attrs); |
| 3363 | t = add_emacs_time (timeval_to_EMACS_TIME (proc.ki_rusage_ch.ru_utime), | 3362 | t = timespec_add (timeval_to_timespec (proc.ki_rusage_ch.ru_utime), |
| 3364 | timeval_to_EMACS_TIME (proc.ki_rusage_ch.ru_stime)); | 3363 | timeval_to_timespec (proc.ki_rusage_ch.ru_stime)); |
| 3365 | attrs = Fcons (Fcons (Qctime, make_lisp_time (t)), attrs); | 3364 | attrs = Fcons (Fcons (Qctime, make_lisp_time (t)), attrs); |
| 3366 | 3365 | ||
| 3367 | attrs = Fcons (Fcons (Qthcount, make_fixnum_or_float (proc.ki_numthreads)), | 3366 | attrs = Fcons (Fcons (Qthcount, make_fixnum_or_float (proc.ki_numthreads)), |
| @@ -3373,8 +3372,8 @@ system_process_attributes (Lisp_Object pid) | |||
| 3373 | attrs = Fcons (Fcons (Qrss, make_number (proc.ki_rssize * pagesize >> 10)), | 3372 | attrs = Fcons (Fcons (Qrss, make_number (proc.ki_rssize * pagesize >> 10)), |
| 3374 | attrs); | 3373 | attrs); |
| 3375 | 3374 | ||
| 3376 | now = current_emacs_time (); | 3375 | now = current_timespec (); |
| 3377 | t = sub_emacs_time (now, timeval_to_EMACS_TIME (proc.ki_start)); | 3376 | t = timespec_sub (now, timeval_to_timespec (proc.ki_start)); |
| 3378 | attrs = Fcons (Fcons (Qetime, make_lisp_time (t)), attrs); | 3377 | attrs = Fcons (Fcons (Qetime, make_lisp_time (t)), attrs); |
| 3379 | 3378 | ||
| 3380 | len = sizeof fscale; | 3379 | len = sizeof fscale; |
diff --git a/src/systime.h b/src/systime.h index df733b290c3..b1c3d940b0e 100644 --- a/src/systime.h +++ b/src/systime.h | |||
| @@ -46,140 +46,56 @@ typedef unsigned long Time; | |||
| 46 | 46 | ||
| 47 | #include <sys/time.h> /* for 'struct timeval' */ | 47 | #include <sys/time.h> /* for 'struct timeval' */ |
| 48 | 48 | ||
| 49 | /* The type to use to represent non-negative temporal intervals. Its | 49 | /* Emacs uses struct timespec to represent nonnegative temporal intervals. |
| 50 | address can be passed as the timeout argument to the pselect system | ||
| 51 | call. */ | ||
| 52 | typedef struct timespec EMACS_TIME; | ||
| 53 | |||
| 54 | /* Resolution of EMACS_TIME time stamps (in units per second), and log | ||
| 55 | base 10 of the resolution. The log must be a positive integer. */ | ||
| 56 | enum { EMACS_TIME_RESOLUTION = 1000000000 }; | ||
| 57 | enum { LOG10_EMACS_TIME_RESOLUTION = 9 }; | ||
| 58 | |||
| 59 | /* EMACS_SECS (TIME) is the seconds component of TIME. | ||
| 60 | EMACS_NSECS (TIME) is the nanoseconds component of TIME. | ||
| 61 | emacs_secs_addr (PTIME) is the address of *PTIME's seconds component. */ | ||
| 62 | SYSTIME_INLINE time_t EMACS_SECS (EMACS_TIME t) { return t.tv_sec; } | ||
| 63 | SYSTIME_INLINE int EMACS_NSECS (EMACS_TIME t) { return t.tv_nsec; } | ||
| 64 | SYSTIME_INLINE time_t *emacs_secs_addr (EMACS_TIME *t) { return &t->tv_sec; } | ||
| 65 | |||
| 66 | /* Return an Emacs time with seconds S and nanoseconds NS. */ | ||
| 67 | SYSTIME_INLINE EMACS_TIME | ||
| 68 | make_emacs_time (time_t s, int ns) | ||
| 69 | { | ||
| 70 | EMACS_TIME r; | ||
| 71 | r.tv_sec = s; | ||
| 72 | r.tv_nsec = ns; | ||
| 73 | return r; | ||
| 74 | } | ||
| 75 | 50 | ||
| 76 | /* Return an invalid Emacs time. */ | 51 | WARNING: Since tv_sec might be an unsigned value, do not use struct |
| 77 | SYSTIME_INLINE EMACS_TIME | 52 | timespec as a general-purpose data type for adding or subtracting |
| 78 | invalid_emacs_time (void) | 53 | arbitrary time values! When computing A + B or A - B, typically A |
| 79 | { | 54 | should be an absolute time since the epoch and B a nonnegative offset. */ |
| 80 | EMACS_TIME r; | ||
| 81 | r.tv_sec = 0; | ||
| 82 | r.tv_nsec = -1; | ||
| 83 | return r; | ||
| 84 | } | ||
| 85 | |||
| 86 | /* Return current system time. */ | ||
| 87 | SYSTIME_INLINE EMACS_TIME | ||
| 88 | current_emacs_time (void) | ||
| 89 | { | ||
| 90 | EMACS_TIME r; | ||
| 91 | gettime (&r); | ||
| 92 | return r; | ||
| 93 | } | ||
| 94 | |||
| 95 | /* Return the result of adding A to B, or of subtracting B from A. | ||
| 96 | On overflow, store an extremal value: ergo, if time_t is unsigned, | ||
| 97 | return 0 if the true answer would be negative. | ||
| 98 | |||
| 99 | WARNING: These are NOT general-purpose macros for adding or | ||
| 100 | subtracting arbitrary time values! They are generally intended to | ||
| 101 | be used with their first argument an absolute time since the epoch | ||
| 102 | and the second argument a non-negative offset. Do NOT use them for | ||
| 103 | anything else. */ | ||
| 104 | SYSTIME_INLINE EMACS_TIME | ||
| 105 | add_emacs_time (EMACS_TIME a, EMACS_TIME b) | ||
| 106 | { | ||
| 107 | return timespec_add (a, b); | ||
| 108 | } | ||
| 109 | SYSTIME_INLINE EMACS_TIME | ||
| 110 | sub_emacs_time (EMACS_TIME a, EMACS_TIME b) | ||
| 111 | { | ||
| 112 | return timespec_sub (a, b); | ||
| 113 | } | ||
| 114 | 55 | ||
| 115 | /* Return the sign of the valid time stamp TIME, either -1, 0, or 1. | 56 | /* Return an invalid timespec. */ |
| 116 | Note: this can only return a negative value if time_t is a signed | 57 | SYSTIME_INLINE struct timespec |
| 117 | data type. */ | 58 | invalid_timespec (void) |
| 118 | SYSTIME_INLINE int | ||
| 119 | EMACS_TIME_SIGN (EMACS_TIME t) | ||
| 120 | { | 59 | { |
| 121 | return timespec_sign (t); | 60 | return make_timespec (0, -1); |
| 122 | } | 61 | } |
| 123 | 62 | ||
| 124 | /* Return 1 if TIME is a valid time stamp. */ | 63 | /* Return 1 if TIME is a valid timespec. This currently doesn't worry |
| 64 | about whether tv_nsec is less than TIMESPEC_RESOLUTION; leap seconds | ||
| 65 | might cause a problem if it did. */ | ||
| 125 | SYSTIME_INLINE int | 66 | SYSTIME_INLINE int |
| 126 | EMACS_TIME_VALID_P (EMACS_TIME t) | 67 | timespec_valid_p (struct timespec t) |
| 127 | { | 68 | { |
| 128 | return t.tv_nsec >= 0; | 69 | return t.tv_nsec >= 0; |
| 129 | } | 70 | } |
| 130 | 71 | ||
| 131 | /* Convert the double D to the greatest EMACS_TIME not greater than D. | 72 | /* Return current system time. */ |
| 132 | On overflow, return an extremal value; in particular, if time_t is | 73 | SYSTIME_INLINE struct timespec |
| 133 | an unsigned data type and D is negative, return zero. Return the | 74 | current_timespec (void) |
| 134 | minimum EMACS_TIME if D is not a number. */ | ||
| 135 | SYSTIME_INLINE EMACS_TIME | ||
| 136 | EMACS_TIME_FROM_DOUBLE (double d) | ||
| 137 | { | ||
| 138 | return dtotimespec (d); | ||
| 139 | } | ||
| 140 | |||
| 141 | /* Convert the Emacs time T to an approximate double value D. */ | ||
| 142 | SYSTIME_INLINE double | ||
| 143 | EMACS_TIME_TO_DOUBLE (EMACS_TIME t) | ||
| 144 | { | 75 | { |
| 145 | return timespectod (t); | 76 | struct timespec r; |
| 77 | gettime (&r); | ||
| 78 | return r; | ||
| 146 | } | 79 | } |
| 147 | 80 | ||
| 148 | /* defined in sysdep.c */ | 81 | /* defined in sysdep.c */ |
| 149 | extern int set_file_times (int, const char *, EMACS_TIME, EMACS_TIME); | 82 | extern int set_file_times (int, const char *, struct timespec, struct timespec); |
| 150 | extern struct timeval make_timeval (EMACS_TIME) ATTRIBUTE_CONST; | 83 | extern struct timeval make_timeval (struct timespec) ATTRIBUTE_CONST; |
| 151 | 84 | ||
| 152 | /* defined in keyboard.c */ | 85 | /* defined in keyboard.c */ |
| 153 | extern void set_waiting_for_input (EMACS_TIME *); | 86 | extern void set_waiting_for_input (struct timespec *); |
| 154 | 87 | ||
| 155 | /* When lisp.h is not included Lisp_Object is not defined (this can | 88 | /* When lisp.h is not included Lisp_Object is not defined (this can |
| 156 | happen when this files is used outside the src directory). | 89 | happen when this files is used outside the src directory). |
| 157 | Use GCPRO1 to determine if lisp.h was included. */ | 90 | Use GCPRO1 to determine if lisp.h was included. */ |
| 158 | #ifdef GCPRO1 | 91 | #ifdef GCPRO1 |
| 159 | /* defined in editfns.c */ | 92 | /* defined in editfns.c */ |
| 160 | extern Lisp_Object make_lisp_time (EMACS_TIME); | 93 | extern Lisp_Object make_lisp_time (struct timespec); |
| 161 | extern bool decode_time_components (Lisp_Object, Lisp_Object, Lisp_Object, | 94 | extern bool decode_time_components (Lisp_Object, Lisp_Object, Lisp_Object, |
| 162 | Lisp_Object, EMACS_TIME *, double *); | 95 | Lisp_Object, struct timespec *, double *); |
| 163 | extern EMACS_TIME lisp_time_argument (Lisp_Object); | 96 | extern struct timespec lisp_time_argument (Lisp_Object); |
| 164 | #endif | 97 | #endif |
| 165 | 98 | ||
| 166 | /* Compare times T1 and T2 for equality, inequality etc. */ | ||
| 167 | SYSTIME_INLINE int | ||
| 168 | EMACS_TIME_EQ (EMACS_TIME t1, EMACS_TIME t2) | ||
| 169 | { | ||
| 170 | return timespec_cmp (t1, t2) == 0; | ||
| 171 | } | ||
| 172 | SYSTIME_INLINE int | ||
| 173 | EMACS_TIME_LT (EMACS_TIME t1, EMACS_TIME t2) | ||
| 174 | { | ||
| 175 | return timespec_cmp (t1, t2) < 0; | ||
| 176 | } | ||
| 177 | SYSTIME_INLINE int | ||
| 178 | EMACS_TIME_LE (EMACS_TIME t1, EMACS_TIME t2) | ||
| 179 | { | ||
| 180 | return timespec_cmp (t1, t2) <= 0; | ||
| 181 | } | ||
| 182 | |||
| 183 | INLINE_HEADER_END | 99 | INLINE_HEADER_END |
| 184 | 100 | ||
| 185 | #endif /* EMACS_SYSTIME_H */ | 101 | #endif /* EMACS_SYSTIME_H */ |
| @@ -247,7 +247,7 @@ static BOOL WINAPI revert_to_self (void); | |||
| 247 | extern int sys_access (const char *, int); | 247 | extern int sys_access (const char *, int); |
| 248 | extern void *e_malloc (size_t); | 248 | extern void *e_malloc (size_t); |
| 249 | extern int sys_select (int, SELECT_TYPE *, SELECT_TYPE *, SELECT_TYPE *, | 249 | extern int sys_select (int, SELECT_TYPE *, SELECT_TYPE *, SELECT_TYPE *, |
| 250 | EMACS_TIME *, void *); | 250 | struct timespec *, void *); |
| 251 | extern int sys_dup (int); | 251 | extern int sys_dup (int); |
| 252 | 252 | ||
| 253 | 253 | ||
| @@ -7939,7 +7939,7 @@ emacs_gnutls_pull (gnutls_transport_ptr_t p, void* buf, size_t sz) | |||
| 7939 | { | 7939 | { |
| 7940 | int n, err; | 7940 | int n, err; |
| 7941 | SELECT_TYPE fdset; | 7941 | SELECT_TYPE fdset; |
| 7942 | EMACS_TIME timeout; | 7942 | struct timespec timeout; |
| 7943 | struct Lisp_Process *process = (struct Lisp_Process *)p; | 7943 | struct Lisp_Process *process = (struct Lisp_Process *)p; |
| 7944 | int fd = process->infd; | 7944 | int fd = process->infd; |
| 7945 | 7945 | ||
diff --git a/src/w32proc.c b/src/w32proc.c index 84589388cd7..54316a6f80f 100644 --- a/src/w32proc.c +++ b/src/w32proc.c | |||
| @@ -1916,7 +1916,7 @@ extern int proc_buffered_char[]; | |||
| 1916 | 1916 | ||
| 1917 | int | 1917 | int |
| 1918 | sys_select (int nfds, SELECT_TYPE *rfds, SELECT_TYPE *wfds, SELECT_TYPE *efds, | 1918 | sys_select (int nfds, SELECT_TYPE *rfds, SELECT_TYPE *wfds, SELECT_TYPE *efds, |
| 1919 | EMACS_TIME *timeout, void *ignored) | 1919 | struct timespec *timeout, void *ignored) |
| 1920 | { | 1920 | { |
| 1921 | SELECT_TYPE orfds; | 1921 | SELECT_TYPE orfds; |
| 1922 | DWORD timeout_ms, start_time; | 1922 | DWORD timeout_ms, start_time; |
diff --git a/src/xdisp.c b/src/xdisp.c index 98ff1aae1d8..46992d2f396 100644 --- a/src/xdisp.c +++ b/src/xdisp.c | |||
| @@ -29800,20 +29800,20 @@ void | |||
| 29800 | start_hourglass (void) | 29800 | start_hourglass (void) |
| 29801 | { | 29801 | { |
| 29802 | #if defined (HAVE_WINDOW_SYSTEM) | 29802 | #if defined (HAVE_WINDOW_SYSTEM) |
| 29803 | EMACS_TIME delay; | 29803 | struct timespec delay; |
| 29804 | 29804 | ||
| 29805 | cancel_hourglass (); | 29805 | cancel_hourglass (); |
| 29806 | 29806 | ||
| 29807 | if (INTEGERP (Vhourglass_delay) | 29807 | if (INTEGERP (Vhourglass_delay) |
| 29808 | && XINT (Vhourglass_delay) > 0) | 29808 | && XINT (Vhourglass_delay) > 0) |
| 29809 | delay = make_emacs_time (min (XINT (Vhourglass_delay), | 29809 | delay = make_timespec (min (XINT (Vhourglass_delay), |
| 29810 | TYPE_MAXIMUM (time_t)), | 29810 | TYPE_MAXIMUM (time_t)), |
| 29811 | 0); | 29811 | 0); |
| 29812 | else if (FLOATP (Vhourglass_delay) | 29812 | else if (FLOATP (Vhourglass_delay) |
| 29813 | && XFLOAT_DATA (Vhourglass_delay) > 0) | 29813 | && XFLOAT_DATA (Vhourglass_delay) > 0) |
| 29814 | delay = EMACS_TIME_FROM_DOUBLE (XFLOAT_DATA (Vhourglass_delay)); | 29814 | delay = dtotimespec (XFLOAT_DATA (Vhourglass_delay)); |
| 29815 | else | 29815 | else |
| 29816 | delay = make_emacs_time (DEFAULT_HOURGLASS_DELAY, 0); | 29816 | delay = make_timespec (DEFAULT_HOURGLASS_DELAY, 0); |
| 29817 | 29817 | ||
| 29818 | #ifdef HAVE_NTGUI | 29818 | #ifdef HAVE_NTGUI |
| 29819 | { | 29819 | { |
diff --git a/src/xgselect.c b/src/xgselect.c index 97f53373b63..45a34f2e0a5 100644 --- a/src/xgselect.c +++ b/src/xgselect.c | |||
| @@ -25,15 +25,16 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 25 | 25 | ||
| 26 | #include <glib.h> | 26 | #include <glib.h> |
| 27 | #include <errno.h> | 27 | #include <errno.h> |
| 28 | #include <timespec.h> | ||
| 28 | #include "frame.h" | 29 | #include "frame.h" |
| 29 | 30 | ||
| 30 | int | 31 | int |
| 31 | xg_select (int fds_lim, SELECT_TYPE *rfds, SELECT_TYPE *wfds, SELECT_TYPE *efds, | 32 | xg_select (int fds_lim, SELECT_TYPE *rfds, SELECT_TYPE *wfds, SELECT_TYPE *efds, |
| 32 | EMACS_TIME const *timeout, sigset_t const *sigmask) | 33 | struct timespec const *timeout, sigset_t const *sigmask) |
| 33 | { | 34 | { |
| 34 | SELECT_TYPE all_rfds, all_wfds; | 35 | SELECT_TYPE all_rfds, all_wfds; |
| 35 | EMACS_TIME tmo; | 36 | struct timespec tmo; |
| 36 | EMACS_TIME const *tmop = timeout; | 37 | struct timespec const *tmop = timeout; |
| 37 | 38 | ||
| 38 | GMainContext *context; | 39 | GMainContext *context; |
| 39 | int have_wfds = wfds != NULL; | 40 | int have_wfds = wfds != NULL; |
| @@ -86,9 +87,9 @@ xg_select (int fds_lim, SELECT_TYPE *rfds, SELECT_TYPE *wfds, SELECT_TYPE *efds, | |||
| 86 | 87 | ||
| 87 | if (tmo_in_millisec >= 0) | 88 | if (tmo_in_millisec >= 0) |
| 88 | { | 89 | { |
| 89 | tmo = make_emacs_time (tmo_in_millisec / 1000, | 90 | tmo = make_timespec (tmo_in_millisec / 1000, |
| 90 | 1000 * 1000 * (tmo_in_millisec % 1000)); | 91 | 1000 * 1000 * (tmo_in_millisec % 1000)); |
| 91 | if (!timeout || EMACS_TIME_LT (tmo, *timeout)) | 92 | if (!timeout || timespec_cmp (tmo, *timeout) < 0) |
| 92 | tmop = &tmo; | 93 | tmop = &tmo; |
| 93 | } | 94 | } |
| 94 | 95 | ||
diff --git a/src/xgselect.h b/src/xgselect.h index 21c8acf1016..f85c17f7190 100644 --- a/src/xgselect.h +++ b/src/xgselect.h | |||
| @@ -21,14 +21,14 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 21 | #define XGSELECT_H | 21 | #define XGSELECT_H |
| 22 | 22 | ||
| 23 | #include "lisp.h" | 23 | #include "lisp.h" |
| 24 | #include "systime.h" | 24 | #include <time.h> |
| 25 | #include "sysselect.h" | 25 | #include "sysselect.h" |
| 26 | 26 | ||
| 27 | extern int xg_select (int max_fds, | 27 | extern int xg_select (int max_fds, |
| 28 | SELECT_TYPE *rfds, | 28 | SELECT_TYPE *rfds, |
| 29 | SELECT_TYPE *wfds, | 29 | SELECT_TYPE *wfds, |
| 30 | SELECT_TYPE *efds, | 30 | SELECT_TYPE *efds, |
| 31 | EMACS_TIME const *timeout, | 31 | struct timespec const *timeout, |
| 32 | sigset_t const *sigmask); | 32 | sigset_t const *sigmask); |
| 33 | 33 | ||
| 34 | #endif /* XGSELECT_H */ | 34 | #endif /* XGSELECT_H */ |
diff --git a/src/xmenu.c b/src/xmenu.c index 95ae5393553..98473939373 100644 --- a/src/xmenu.c +++ b/src/xmenu.c | |||
| @@ -377,7 +377,7 @@ x_menu_wait_for_event (void *data) | |||
| 377 | #endif | 377 | #endif |
| 378 | ) | 378 | ) |
| 379 | { | 379 | { |
| 380 | EMACS_TIME next_time = timer_check (), *ntp; | 380 | struct timespec next_time = timer_check (), *ntp; |
| 381 | SELECT_TYPE read_fds; | 381 | SELECT_TYPE read_fds; |
| 382 | struct x_display_info *dpyinfo; | 382 | struct x_display_info *dpyinfo; |
| 383 | int n = 0; | 383 | int n = 0; |
| @@ -391,7 +391,7 @@ x_menu_wait_for_event (void *data) | |||
| 391 | XFlush (dpyinfo->display); | 391 | XFlush (dpyinfo->display); |
| 392 | } | 392 | } |
| 393 | 393 | ||
| 394 | if (! EMACS_TIME_VALID_P (next_time)) | 394 | if (! timespec_valid_p (next_time)) |
| 395 | ntp = 0; | 395 | ntp = 0; |
| 396 | else | 396 | else |
| 397 | ntp = &next_time; | 397 | ntp = &next_time; |
diff --git a/src/xterm.c b/src/xterm.c index 7014bdb9740..5a67c3b6f2f 100644 --- a/src/xterm.c +++ b/src/xterm.c | |||
| @@ -3112,22 +3112,22 @@ XTflash (struct frame *f) | |||
| 3112 | x_flush (f); | 3112 | x_flush (f); |
| 3113 | 3113 | ||
| 3114 | { | 3114 | { |
| 3115 | EMACS_TIME delay = make_emacs_time (0, 150 * 1000 * 1000); | 3115 | struct timespec delay = make_timespec (0, 150 * 1000 * 1000); |
| 3116 | EMACS_TIME wakeup = add_emacs_time (current_emacs_time (), delay); | 3116 | struct timespec wakeup = timespec_add (current_timespec (), delay); |
| 3117 | 3117 | ||
| 3118 | /* Keep waiting until past the time wakeup or any input gets | 3118 | /* Keep waiting until past the time wakeup or any input gets |
| 3119 | available. */ | 3119 | available. */ |
| 3120 | while (! detect_input_pending ()) | 3120 | while (! detect_input_pending ()) |
| 3121 | { | 3121 | { |
| 3122 | EMACS_TIME current = current_emacs_time (); | 3122 | struct timespec current = current_timespec (); |
| 3123 | EMACS_TIME timeout; | 3123 | struct timespec timeout; |
| 3124 | 3124 | ||
| 3125 | /* Break if result would not be positive. */ | 3125 | /* Break if result would not be positive. */ |
| 3126 | if (EMACS_TIME_LE (wakeup, current)) | 3126 | if (timespec_cmp (wakeup, current) <= 0) |
| 3127 | break; | 3127 | break; |
| 3128 | 3128 | ||
| 3129 | /* How long `select' should wait. */ | 3129 | /* How long `select' should wait. */ |
| 3130 | timeout = make_emacs_time (0, 10 * 1000 * 1000); | 3130 | timeout = make_timespec (0, 10 * 1000 * 1000); |
| 3131 | 3131 | ||
| 3132 | /* Try to wait that long--but we might wake up sooner. */ | 3132 | /* Try to wait that long--but we might wake up sooner. */ |
| 3133 | pselect (0, NULL, NULL, NULL, &timeout, NULL); | 3133 | pselect (0, NULL, NULL, NULL, &timeout, NULL); |
| @@ -8677,7 +8677,7 @@ x_wait_for_event (struct frame *f, int eventtype) | |||
| 8677 | int level = interrupt_input_blocked; | 8677 | int level = interrupt_input_blocked; |
| 8678 | 8678 | ||
| 8679 | SELECT_TYPE fds; | 8679 | SELECT_TYPE fds; |
| 8680 | EMACS_TIME tmo, tmo_at, time_now; | 8680 | struct timespec tmo, tmo_at, time_now; |
| 8681 | int fd = ConnectionNumber (FRAME_X_DISPLAY (f)); | 8681 | int fd = ConnectionNumber (FRAME_X_DISPLAY (f)); |
| 8682 | 8682 | ||
| 8683 | pending_event_wait.f = f; | 8683 | pending_event_wait.f = f; |
| @@ -8685,8 +8685,8 @@ x_wait_for_event (struct frame *f, int eventtype) | |||
| 8685 | 8685 | ||
| 8686 | /* Set timeout to 0.1 second. Hopefully not noticeable. | 8686 | /* Set timeout to 0.1 second. Hopefully not noticeable. |
| 8687 | Maybe it should be configurable. */ | 8687 | Maybe it should be configurable. */ |
| 8688 | tmo = make_emacs_time (0, 100 * 1000 * 1000); | 8688 | tmo = make_timespec (0, 100 * 1000 * 1000); |
| 8689 | tmo_at = add_emacs_time (current_emacs_time (), tmo); | 8689 | tmo_at = timespec_add (current_timespec (), tmo); |
| 8690 | 8690 | ||
| 8691 | while (pending_event_wait.eventtype) | 8691 | while (pending_event_wait.eventtype) |
| 8692 | { | 8692 | { |
| @@ -8699,11 +8699,11 @@ x_wait_for_event (struct frame *f, int eventtype) | |||
| 8699 | FD_ZERO (&fds); | 8699 | FD_ZERO (&fds); |
| 8700 | FD_SET (fd, &fds); | 8700 | FD_SET (fd, &fds); |
| 8701 | 8701 | ||
| 8702 | time_now = current_emacs_time (); | 8702 | time_now = current_timespec (); |
| 8703 | if (EMACS_TIME_LT (tmo_at, time_now)) | 8703 | if (timespec_cmp (tmo_at, time_now) < 0) |
| 8704 | break; | 8704 | break; |
| 8705 | 8705 | ||
| 8706 | tmo = sub_emacs_time (tmo_at, time_now); | 8706 | tmo = timespec_sub (tmo_at, time_now); |
| 8707 | if (pselect (fd + 1, &fds, NULL, NULL, &tmo, NULL) == 0) | 8707 | if (pselect (fd + 1, &fds, NULL, NULL, &tmo, NULL) == 0) |
| 8708 | break; /* Timeout */ | 8708 | break; /* Timeout */ |
| 8709 | } | 8709 | } |
| @@ -10425,7 +10425,7 @@ x_activate_timeout_atimer (void) | |||
| 10425 | block_input (); | 10425 | block_input (); |
| 10426 | if (!x_timeout_atimer_activated_flag) | 10426 | if (!x_timeout_atimer_activated_flag) |
| 10427 | { | 10427 | { |
| 10428 | EMACS_TIME interval = make_emacs_time (0, 100 * 1000 * 1000); | 10428 | struct timespec interval = make_timespec (0, 100 * 1000 * 1000); |
| 10429 | start_atimer (ATIMER_RELATIVE, interval, x_process_timeouts, 0); | 10429 | start_atimer (ATIMER_RELATIVE, interval, x_process_timeouts, 0); |
| 10430 | x_timeout_atimer_activated_flag = 1; | 10430 | x_timeout_atimer_activated_flag = 1; |
| 10431 | } | 10431 | } |