comparison src/process.c @ 39973:579177964efa

Avoid (most) uses of XCAR/XCDR as lvalues, for flexibility in experimenting with lisp system changes.
author Ken Raeburn <raeburn@raeburn.org>
date Tue, 16 Oct 2001 09:09:51 +0000
parents 4ca5cbe5610d
children 6b389fb978bc
comparison
equal deleted inserted replaced
39972:b2479b43184b 39973:579177964efa
2365 EMACS_TIME timeout, end_time; 2365 EMACS_TIME timeout, end_time;
2366 SELECT_TYPE Atemp; 2366 SELECT_TYPE Atemp;
2367 int wait_channel = -1; 2367 int wait_channel = -1;
2368 struct Lisp_Process *wait_proc = 0; 2368 struct Lisp_Process *wait_proc = 0;
2369 int got_some_input = 0; 2369 int got_some_input = 0;
2370 Lisp_Object *wait_for_cell = 0; 2370 /* Either nil or a cons cell, the car of which is of interest and
2371 may be changed outside of this routine. */
2372 Lisp_Object wait_for_cell = Qnil;
2371 2373
2372 FD_ZERO (&Available); 2374 FD_ZERO (&Available);
2373 2375
2374 /* If read_kbd is a process to watch, set wait_proc and wait_channel 2376 /* If read_kbd is a process to watch, set wait_proc and wait_channel
2375 accordingly. */ 2377 accordingly. */
2381 } 2383 }
2382 2384
2383 /* If waiting for non-nil in a cell, record where. */ 2385 /* If waiting for non-nil in a cell, record where. */
2384 if (CONSP (read_kbd)) 2386 if (CONSP (read_kbd))
2385 { 2387 {
2386 wait_for_cell = &XCAR (read_kbd); 2388 wait_for_cell = read_kbd;
2387 XSETFASTINT (read_kbd, 0); 2389 XSETFASTINT (read_kbd, 0);
2388 } 2390 }
2389 2391
2390 waiting_for_user_input_p = XINT (read_kbd); 2392 waiting_for_user_input_p = XINT (read_kbd);
2391 2393
2415 Otherwise, do pending quit if requested. */ 2417 Otherwise, do pending quit if requested. */
2416 if (XINT (read_kbd) >= 0) 2418 if (XINT (read_kbd) >= 0)
2417 QUIT; 2419 QUIT;
2418 2420
2419 /* Exit now if the cell we're waiting for became non-nil. */ 2421 /* Exit now if the cell we're waiting for became non-nil. */
2420 if (wait_for_cell && ! NILP (*wait_for_cell)) 2422 if (! NILP (wait_for_cell) && ! NILP (XCAR (wait_for_cell)))
2421 break; 2423 break;
2422 2424
2423 /* Compute time from now till when time limit is up */ 2425 /* Compute time from now till when time limit is up */
2424 /* Exit if already run out */ 2426 /* Exit if already run out */
2425 if (time_limit == -1) 2427 if (time_limit == -1)
2444 2446
2445 /* Normally we run timers here. 2447 /* Normally we run timers here.
2446 But not if wait_for_cell; in those cases, 2448 But not if wait_for_cell; in those cases,
2447 the wait is supposed to be short, 2449 the wait is supposed to be short,
2448 and those callers cannot handle running arbitrary Lisp code here. */ 2450 and those callers cannot handle running arbitrary Lisp code here. */
2449 if (! wait_for_cell) 2451 if (NILP (wait_for_cell))
2450 { 2452 {
2451 EMACS_TIME timer_delay; 2453 EMACS_TIME timer_delay;
2452 2454
2453 do 2455 do
2454 { 2456 {
2565 break; 2567 break;
2566 } 2568 }
2567 2569
2568 /* Wait till there is something to do */ 2570 /* Wait till there is something to do */
2569 2571
2570 if (wait_for_cell) 2572 if (!NILP (wait_for_cell))
2571 Available = non_process_wait_mask; 2573 Available = non_process_wait_mask;
2572 else if (! XINT (read_kbd)) 2574 else if (! XINT (read_kbd))
2573 Available = non_keyboard_wait_mask; 2575 Available = non_keyboard_wait_mask;
2574 else 2576 else
2575 Available = input_wait_mask; 2577 Available = input_wait_mask;
2721 break; 2723 break;
2722 #endif 2724 #endif
2723 } 2725 }
2724 2726
2725 /* Exit now if the cell we're waiting for became non-nil. */ 2727 /* Exit now if the cell we're waiting for became non-nil. */
2726 if (wait_for_cell && ! NILP (*wait_for_cell)) 2728 if (! NILP (wait_for_cell) && ! NILP (XCAR (wait_for_cell)))
2727 break; 2729 break;
2728 2730
2729 #ifdef SIGIO 2731 #ifdef SIGIO
2730 /* If we think we have keyboard input waiting, but didn't get SIGIO, 2732 /* If we think we have keyboard input waiting, but didn't get SIGIO,
2731 go read it. This can happen with X on BSD after logging out. 2733 go read it. This can happen with X on BSD after logging out.
2740 if (! wait_proc) 2742 if (! wait_proc)
2741 got_some_input |= nfds > 0; 2743 got_some_input |= nfds > 0;
2742 2744
2743 /* If checking input just got us a size-change event from X, 2745 /* If checking input just got us a size-change event from X,
2744 obey it now if we should. */ 2746 obey it now if we should. */
2745 if (XINT (read_kbd) || wait_for_cell) 2747 if (XINT (read_kbd) || ! NILP (wait_for_cell))
2746 do_pending_window_change (0); 2748 do_pending_window_change (0);
2747 2749
2748 /* Check for data from a process. */ 2750 /* Check for data from a process. */
2749 /* Really FIRST_PROC_DESC should be 0 on Unix, 2751 /* Really FIRST_PROC_DESC should be 0 on Unix,
2750 but this is safer in the short run. */ 2752 but this is safer in the short run. */
4766 { 4768 {
4767 register int nfds; 4769 register int nfds;
4768 EMACS_TIME end_time, timeout; 4770 EMACS_TIME end_time, timeout;
4769 SELECT_TYPE waitchannels; 4771 SELECT_TYPE waitchannels;
4770 int xerrno; 4772 int xerrno;
4771 Lisp_Object *wait_for_cell = 0; 4773 /* Either nil or a cons cell, the car of which is of interest and
4774 may be changed outside of this routine. */
4775 Lisp_Object wait_for_cell = Qnil;
4772 4776
4773 /* If waiting for non-nil in a cell, record where. */ 4777 /* If waiting for non-nil in a cell, record where. */
4774 if (CONSP (read_kbd)) 4778 if (CONSP (read_kbd))
4775 { 4779 {
4776 wait_for_cell = &XCAR (read_kbd); 4780 wait_for_cell = read_kbd;
4777 XSETFASTINT (read_kbd, 0); 4781 XSETFASTINT (read_kbd, 0);
4778 } 4782 }
4779 4783
4780 /* What does time_limit really mean? */ 4784 /* What does time_limit really mean? */
4781 if (time_limit || microsecs) 4785 if (time_limit || microsecs)
4798 Otherwise, do pending quit if requested. */ 4802 Otherwise, do pending quit if requested. */
4799 if (XINT (read_kbd) >= 0) 4803 if (XINT (read_kbd) >= 0)
4800 QUIT; 4804 QUIT;
4801 4805
4802 /* Exit now if the cell we're waiting for became non-nil. */ 4806 /* Exit now if the cell we're waiting for became non-nil. */
4803 if (wait_for_cell && ! NILP (*wait_for_cell)) 4807 if (! NILP (wait_for_cell) && ! NILP (XCAR (wait_for_cell)))
4804 break; 4808 break;
4805 4809
4806 /* Compute time from now till when time limit is up */ 4810 /* Compute time from now till when time limit is up */
4807 /* Exit if already run out */ 4811 /* Exit if already run out */
4808 if (time_limit == -1) 4812 if (time_limit == -1)
4827 4831
4828 /* If our caller will not immediately handle keyboard events, 4832 /* If our caller will not immediately handle keyboard events,
4829 run timer events directly. 4833 run timer events directly.
4830 (Callers that will immediately read keyboard events 4834 (Callers that will immediately read keyboard events
4831 call timer_delay on their own.) */ 4835 call timer_delay on their own.) */
4832 if (! wait_for_cell) 4836 if (NILP (wait_for_cell))
4833 { 4837 {
4834 EMACS_TIME timer_delay; 4838 EMACS_TIME timer_delay;
4835 4839
4836 do 4840 do
4837 { 4841 {
4868 if (XINT (read_kbd) < 0) 4872 if (XINT (read_kbd) < 0)
4869 set_waiting_for_input (&timeout); 4873 set_waiting_for_input (&timeout);
4870 4874
4871 /* Wait till there is something to do. */ 4875 /* Wait till there is something to do. */
4872 4876
4873 if (! XINT (read_kbd) && wait_for_cell == 0) 4877 if (! XINT (read_kbd) && NILP (wait_for_cell))
4874 FD_ZERO (&waitchannels); 4878 FD_ZERO (&waitchannels);
4875 else 4879 else
4876 FD_SET (0, &waitchannels); 4880 FD_SET (0, &waitchannels);
4877 4881
4878 /* If a frame has been newly mapped and needs updating, 4882 /* If a frame has been newly mapped and needs updating,
4944 but don't run any timers. 4948 but don't run any timers.
4945 ??? (It seems wrong to me to check for keyboard 4949 ??? (It seems wrong to me to check for keyboard
4946 input at all when wait_for_cell, but the code 4950 input at all when wait_for_cell, but the code
4947 has been this way since July 1994. 4951 has been this way since July 1994.
4948 Try changing this after version 19.31.) */ 4952 Try changing this after version 19.31.) */
4949 if (wait_for_cell 4953 if (! NILP (wait_for_cell)
4950 && detect_input_pending ()) 4954 && detect_input_pending ())
4951 { 4955 {
4952 swallow_events (do_display); 4956 swallow_events (do_display);
4953 if (detect_input_pending ()) 4957 if (detect_input_pending ())
4954 break; 4958 break;
4955 } 4959 }
4956 4960
4957 /* Exit now if the cell we're waiting for became non-nil. */ 4961 /* Exit now if the cell we're waiting for became non-nil. */
4958 if (wait_for_cell && ! NILP (*wait_for_cell)) 4962 if (! NILP (wait_for_cell) && ! NILP (XCAR (wait_for_cell)))
4959 break; 4963 break;
4960 } 4964 }
4961 4965
4962 start_polling (); 4966 start_polling ();
4963 4967