aboutsummaryrefslogtreecommitdiffstats
path: root/src/process.c
diff options
context:
space:
mode:
authorPaul Eggert2012-07-10 16:24:36 -0700
committerPaul Eggert2012-07-10 16:24:36 -0700
commite9a9ae0350689d352c2bdfa3af0eb722f587b966 (patch)
tree10ed0298079b06838a525f0a4df780d7600e13fe /src/process.c
parentffacb12679a1e001981c2e0f690b327eda652d04 (diff)
downloademacs-e9a9ae0350689d352c2bdfa3af0eb722f587b966.tar.gz
emacs-e9a9ae0350689d352c2bdfa3af0eb722f587b966.zip
EMACS_TIME simplification (Bug#11875).
This replaces macros (which typically do not work in GDB) with functions, typedefs and enums, making the code easier to debug. The functional style also makes code easier to read and maintain. * lib-src/profile.c (TV2): Remove no-longer-needed static var. * src/systime.h: Include <sys/time.h> on all hosts, not just if WINDOWSNT, since 'struct timeval' is needed in general. (EMACS_TIME): Now a typedef, not a macro. (EMACS_TIME_RESOLUTION, LOG10_EMACS_TIME_RESOLUTION): Now constants, not macros. (EMACS_SECS, EMACS_NSECS, EMACS_TIME_SIGN, EMACS_TIME_VALID_P) (EMACS_TIME_FROM_DOUBLE, EMACS_TIME_TO_DOUBLE, EMACS_TIME_EQ) (EMACS_TIME_NE, EMACS_TIME_GT, EMACS_TIME_GE, EMACS_TIME_LT) (EMACS_TIME_LE): Now functions, not macros. (EMACS_SET_SECS, EMACS_SET_NSECS, EMACS_SET_SECS_NSECS) (EMACS_SET_USECS, EMACS_SET_SECS_USECS): Remove these macros, which are not functions. All uses rewritten to use: (make_emacs_time): New function. (EMACS_SECS_ADDR, EMACS_SET_INVALID_TIME, EMACS_GET_TIME) (EMACS_ADD_TIME, EMACS_SUB_TIME): Remove these macros, which are not functions. All uses rewritten to use the following, respectively: (emacs_secs_addr, invalid_emacs_time, get_emacs_time) (add_emacs_time, sub_emacs_time): New functions. * src/atimer.c: Don't include <sys/time.h>, as "systime.h" does this. * src/fileio.c (Fcopy_file): * src/xterm.c (XTflash): Get the current time closer to when it's used. * src/makefile.w32-in ($(BLD)/atimer.$(O)): Update dependencies.
Diffstat (limited to 'src/process.c')
-rw-r--r--src/process.c41
1 files changed, 19 insertions, 22 deletions
diff --git a/src/process.c b/src/process.c
index 79100eb7a2c..98a47eca7ae 100644
--- a/src/process.c
+++ b/src/process.c
@@ -1851,10 +1851,9 @@ create_process (Lisp_Object process, char **new_argv, Lisp_Object current_dir)
1851 So have an interrupt jar it loose. */ 1851 So have an interrupt jar it loose. */
1852 { 1852 {
1853 struct atimer *timer; 1853 struct atimer *timer;
1854 EMACS_TIME offset; 1854 EMACS_TIME offset = make_emacs_time (1, 0);
1855 1855
1856 stop_polling (); 1856 stop_polling ();
1857 EMACS_SET_SECS_USECS (offset, 1, 0);
1858 timer = start_atimer (ATIMER_RELATIVE, offset, create_process_1, 0); 1857 timer = start_atimer (ATIMER_RELATIVE, offset, create_process_1, 0);
1859 1858
1860 if (forkin >= 0) 1859 if (forkin >= 0)
@@ -4311,9 +4310,8 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd,
4311 compute the absolute time to return at. */ 4310 compute the absolute time to return at. */
4312 if (time_limit || 0 < nsecs) 4311 if (time_limit || 0 < nsecs)
4313 { 4312 {
4314 EMACS_GET_TIME (end_time); 4313 timeout = make_emacs_time (time_limit, nsecs);
4315 EMACS_SET_SECS_NSECS (timeout, time_limit, nsecs); 4314 end_time = add_emacs_time (current_emacs_time (), timeout);
4316 EMACS_ADD_TIME (end_time, end_time, timeout);
4317 } 4315 }
4318 4316
4319 while (1) 4317 while (1)
@@ -4342,18 +4340,18 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd,
4342 gobble output available now 4340 gobble output available now
4343 but don't wait at all. */ 4341 but don't wait at all. */
4344 4342
4345 EMACS_SET_SECS_USECS (timeout, 0, 0); 4343 timeout = make_emacs_time (0, 0);
4346 } 4344 }
4347 else if (time_limit || 0 < nsecs) 4345 else if (time_limit || 0 < nsecs)
4348 { 4346 {
4349 EMACS_GET_TIME (timeout); 4347 EMACS_TIME now = current_emacs_time ();
4350 if (EMACS_TIME_LE (end_time, timeout)) 4348 if (EMACS_TIME_LE (end_time, now))
4351 break; 4349 break;
4352 EMACS_SUB_TIME (timeout, end_time, timeout); 4350 timeout = sub_emacs_time (end_time, now);
4353 } 4351 }
4354 else 4352 else
4355 { 4353 {
4356 EMACS_SET_SECS_USECS (timeout, 100000, 0); 4354 timeout = make_emacs_time (100000, 0);
4357 } 4355 }
4358 4356
4359 /* Normally we run timers here. 4357 /* Normally we run timers here.
@@ -4438,7 +4436,7 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd,
4438 Atemp = input_wait_mask; 4436 Atemp = input_wait_mask;
4439 Ctemp = write_mask; 4437 Ctemp = write_mask;
4440 4438
4441 EMACS_SET_SECS_USECS (timeout, 0, 0); 4439 timeout = make_emacs_time (0, 0);
4442 if ((pselect (max (max_process_desc, max_input_desc) + 1, 4440 if ((pselect (max (max_process_desc, max_input_desc) + 1,
4443 &Atemp, 4441 &Atemp,
4444#ifdef NON_BLOCKING_CONNECT 4442#ifdef NON_BLOCKING_CONNECT
@@ -4590,7 +4588,7 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd,
4590 nsecs = XPROCESS (proc)->read_output_delay; 4588 nsecs = XPROCESS (proc)->read_output_delay;
4591 } 4589 }
4592 } 4590 }
4593 EMACS_SET_SECS_NSECS (timeout, 0, nsecs); 4591 timeout = make_emacs_time (0, nsecs);
4594 process_output_skip = 0; 4592 process_output_skip = 0;
4595 } 4593 }
4596#endif 4594#endif
@@ -6426,7 +6424,7 @@ sigchld_handler (int signo)
6426 /* Tell wait_reading_process_output that it needs to wake up and 6424 /* Tell wait_reading_process_output that it needs to wake up and
6427 look around. */ 6425 look around. */
6428 if (input_available_clear_time) 6426 if (input_available_clear_time)
6429 EMACS_SET_SECS_USECS (*input_available_clear_time, 0, 0); 6427 *input_available_clear_time = make_emacs_time (0, 0);
6430 } 6428 }
6431 6429
6432 /* There was no asynchronous process found for that pid: we have 6430 /* There was no asynchronous process found for that pid: we have
@@ -6444,7 +6442,7 @@ sigchld_handler (int signo)
6444 /* Tell wait_reading_process_output that it needs to wake up and 6442 /* Tell wait_reading_process_output that it needs to wake up and
6445 look around. */ 6443 look around. */
6446 if (input_available_clear_time) 6444 if (input_available_clear_time)
6447 EMACS_SET_SECS_USECS (*input_available_clear_time, 0, 0); 6445 *input_available_clear_time = make_emacs_time (0, 0);
6448 } 6446 }
6449 6447
6450 sigchld_end_of_loop: 6448 sigchld_end_of_loop:
@@ -6857,9 +6855,8 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd,
6857 /* What does time_limit really mean? */ 6855 /* What does time_limit really mean? */
6858 if (time_limit || 0 < nsecs) 6856 if (time_limit || 0 < nsecs)
6859 { 6857 {
6860 EMACS_GET_TIME (end_time); 6858 timeout = make_emacs_time (time_limit, nsecs);
6861 EMACS_SET_SECS_NSECS (timeout, time_limit, nsecs); 6859 end_time = add_emacs_time (current_emacs_time (), timeout);
6862 EMACS_ADD_TIME (end_time, end_time, timeout);
6863 } 6860 }
6864 6861
6865 /* Turn off periodic alarms (in case they are in use) 6862 /* Turn off periodic alarms (in case they are in use)
@@ -6892,18 +6889,18 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd,
6892 gobble output available now 6889 gobble output available now
6893 but don't wait at all. */ 6890 but don't wait at all. */
6894 6891
6895 EMACS_SET_SECS_USECS (timeout, 0, 0); 6892 timeout = make_emacs_time (0, 0);
6896 } 6893 }
6897 else if (time_limit || 0 < nsecs) 6894 else if (time_limit || 0 < nsecs)
6898 { 6895 {
6899 EMACS_GET_TIME (timeout); 6896 EMACS_TIME now = current_emacs_time ();
6900 if (EMACS_TIME_LE (end_time, timeout)) 6897 if (EMACS_TIME_LE (end_time, now))
6901 break; 6898 break;
6902 EMACS_SUB_TIME (timeout, end_time, timeout); 6899 timeout = sub_emacs_time (end_time, now);
6903 } 6900 }
6904 else 6901 else
6905 { 6902 {
6906 EMACS_SET_SECS_USECS (timeout, 100000, 0); 6903 timeout = make_emacs_time (100000, 0);
6907 } 6904 }
6908 6905
6909 /* If our caller will not immediately handle keyboard events, 6906 /* If our caller will not immediately handle keyboard events,