Mercurial > hg > xemacs-beta
comparison src/signal.c @ 771:943eaba38521
[xemacs-hg @ 2002-03-13 08:51:24 by ben]
The big ben-mule-21-5 check-in!
Various files were added and deleted. See CHANGES-ben-mule.
There are still some test suite failures. No crashes, though.
Many of the failures have to do with problems in the test suite itself
rather than in the actual code. I'll be addressing these in the next
day or so -- none of the test suite failures are at all critical.
Meanwhile I'll be trying to address the biggest issues -- i.e. build
or run failures, which will almost certainly happen on various platforms.
All comments should be sent to ben@xemacs.org -- use a Cc: if necessary
when sending to mailing lists. There will be pre- and post- tags,
something like
pre-ben-mule-21-5-merge-in, and
post-ben-mule-21-5-merge-in.
author | ben |
---|---|
date | Wed, 13 Mar 2002 08:54:06 +0000 |
parents | af57a77cbc92 |
children | a5954632b187 |
comparison
equal
deleted
inserted
replaced
770:336a418893b5 | 771:943eaba38521 |
---|---|
181 handle_async_timeout_signal (void) | 181 handle_async_timeout_signal (void) |
182 { | 182 { |
183 int interval_id; | 183 int interval_id; |
184 int wakeup_id; | 184 int wakeup_id; |
185 Lisp_Object fun, arg; | 185 Lisp_Object fun, arg; |
186 /* Avoid any possibility of GC during QUIT */ | |
187 int specco = begin_gc_forbidden (); | |
186 | 188 |
187 /* No checks for Vinhibit_quit here or anywhere else in this file!!! | 189 /* No checks for Vinhibit_quit here or anywhere else in this file!!! |
188 Otherwise critical quit will not work right. | 190 Otherwise critical quit will not work right. |
189 The only check for Vinhibit_quit is in QUIT itself. */ | 191 The only check for Vinhibit_quit is in QUIT itself. |
192 | |
193 (#### ???? I don't quite understand this comment.) */ | |
190 interval_id = pop_low_level_timeout (&async_timer_queue, 0); | 194 interval_id = pop_low_level_timeout (&async_timer_queue, 0); |
191 | 195 |
192 reset_interval_timer (); | 196 reset_interval_timer (); |
193 if (async_timeout_happened_while_emacs_was_blocking) | 197 if (async_timeout_happened_while_emacs_was_blocking) |
194 { | 198 { |
211 /* call1 GC-protects its arguments */ | 215 /* call1 GC-protects its arguments */ |
212 call1_trapping_errors ("Error in asynchronous timeout callback", | 216 call1_trapping_errors ("Error in asynchronous timeout callback", |
213 fun, arg); | 217 fun, arg); |
214 | 218 |
215 waiting_for_user_input_p = 0; | 219 waiting_for_user_input_p = 0; |
220 | |
221 unbind_to (specco); | |
216 } | 222 } |
217 | 223 |
218 /* The following two functions are the external interface onto | 224 /* The following two functions are the external interface onto |
219 creating/deleting asynchronous interval timeouts, and are | 225 creating/deleting asynchronous interval timeouts, and are |
220 called by event-stream.c. We call back to event-stream.c using | 226 called by event-stream.c. We call back to event-stream.c using |
408 race-condition reasons as above. */ | 414 race-condition reasons as above. */ |
409 interrupts_slowed_down--; | 415 interrupts_slowed_down--; |
410 } | 416 } |
411 } | 417 } |
412 | 418 |
413 /* Cheesy but workable implementation of sleep() that doesn't | |
414 interfere with our periodic timers. */ | |
415 | |
416 void | |
417 emacs_sleep (int secs) | |
418 { | |
419 stop_interrupts (); | |
420 sleep (secs); | |
421 start_interrupts (); | |
422 } | |
423 | |
424 | 419 |
425 /**********************************************************************/ | 420 /**********************************************************************/ |
426 /* The mechanism that drives it all */ | 421 /* The mechanism that drives it all */ |
427 /**********************************************************************/ | 422 /**********************************************************************/ |
428 | 423 |
430 a signal) */ | 425 a signal) */ |
431 | 426 |
432 int | 427 int |
433 check_what_happened (void) | 428 check_what_happened (void) |
434 { | 429 { |
430 /* No GC can happen anywhere here. handle_async_timeout_signal() | |
431 prevents GC (from asynch timeout handler), so does check_quit() | |
432 (from processing a message such as WM_INITMENU as a result of | |
433 draining the message queue). establish_slow_interrupt_timer() is | |
434 too low-level to do anything that might invoke QUIT or call Lisp | |
435 code. */ | |
435 something_happened = 0; | 436 something_happened = 0; |
436 if (async_timeout_happened) | 437 if (async_timeout_happened) |
437 { | 438 { |
438 async_timeout_happened = 0; | 439 async_timeout_happened = 0; |
439 handle_async_timeout_signal (); | 440 handle_async_timeout_signal (); |
636 { | 637 { |
637 dont_check_for_quit = XINT (val); | 638 dont_check_for_quit = XINT (val); |
638 return Qnil; | 639 return Qnil; |
639 } | 640 } |
640 | 641 |
641 void | 642 /* Defer all checking or processing of C-g. You can do this, for example, |
643 if you want to read C-g's as events. (In that case, you should set | |
644 Vquit_flag to Qnil just before you unbind, because it typically gets set | |
645 as a result of reading C-g.) */ | |
646 | |
647 int | |
642 begin_dont_check_for_quit (void) | 648 begin_dont_check_for_quit (void) |
643 { | 649 { |
650 int depth = specpdl_depth (); | |
651 /* As an optimization in QUIT_FLAG_SAYS_SHOULD_QUIT, we bind inhibit-quit | |
652 to t -- it has to be checked anyway, and by doing this, we only need | |
653 to check dont_check_for_quit when quit-flag == `critical', which is | |
654 rare. */ | |
644 specbind (Qinhibit_quit, Qt); | 655 specbind (Qinhibit_quit, Qt); |
645 record_unwind_protect (restore_dont_check_for_quit, | 656 record_unwind_protect (restore_dont_check_for_quit, |
646 make_int (dont_check_for_quit)); | 657 make_int (dont_check_for_quit)); |
647 dont_check_for_quit = 1; | 658 dont_check_for_quit = 1; |
659 | |
660 return depth; | |
648 } | 661 } |
649 | 662 |
650 /* The effect of this function is to set Vquit_flag if the user pressed | 663 /* The effect of this function is to set Vquit_flag if the user pressed |
651 ^G and discard the ^G, so as to not notice the same ^G again. */ | 664 ^G and discard the ^G, so as to not notice the same ^G again. */ |
652 int | 665 int |
660 | 673 |
661 (2) when we are reading events, and want to read the C-g | 674 (2) when we are reading events, and want to read the C-g |
662 as an event. The normal check for quit will discard the C-g, | 675 as an event. The normal check for quit will discard the C-g, |
663 which would be bad. | 676 which would be bad. |
664 | 677 |
665 #### C-g is still often read as quit, e.g. if you type C-x C-g | 678 [[#### C-g is still often read as quit, e.g. if you type C-x C-g (the |
666 (the C-g happens during the sit-for in maybe_echo_keys(); even | 679 C-g happens during the sit-for in maybe_echo_keys(); even if we |
667 if we attempt to inhibit quit here, there is still a check | 680 attempt to inhibit quit here, there is still a check later on for |
668 later on for QUIT. To fix this properly requires a fairly | 681 QUIT. To fix this properly requires a fairly substantial overhaul of |
669 substantial overhaul of the quit-checking code, which is | 682 the quit-checking code, which is probably not worth it.)]] not true, |
670 probably not worth it.) | 683 we just have to always do dont_check_for_quit around all code that |
684 reads events. my stderr-proc ws already does this. | |
671 | 685 |
672 We should *not* conditionalize on Vinhibit_quit, or | 686 We should *not* conditionalize on Vinhibit_quit, or |
673 critical-quit (Control-Shift-G) won't work right. */ | 687 critical-quit (Control-Shift-G) won't work right. */ |
674 | 688 |
689 /* WARNING: Even calling check_quit(), without actually dispatching | |
690 a quit signal, can result in arbitrary Lisp code getting executed | |
691 -- at least under Windows. (Not to mention obvious Lisp | |
692 invocations like asynchronous timer callbacks.) Here's a sample | |
693 stack trace to demonstrate: | |
694 | |
695 NTDLL! DbgBreakPoint@0 address 0x77f9eea9 | |
696 assert_failed(const char * 0x012d036c, int 4596, const char * 0x012d0354) line 3478 | |
697 re_match_2_internal(re_pattern_buffer * 0x012d6780, const unsigned char * 0x00000000, int 0, const unsigned char * 0x022f9328, int 34, int 0, re_registers * 0x012d53d0 search_regs, int 34) line 4596 + 41 bytes | |
698 re_search_2(re_pattern_buffer * 0x012d6780, const char * 0x00000000, int 0, const char * 0x022f9328, int 34, int 0, int 34, re_registers * 0x012d53d0 search_regs, int 34) line 4269 + 37 bytes | |
699 re_search(re_pattern_buffer * 0x012d6780, const char * 0x022f9328, int 34, int 0, int 34, re_registers * 0x012d53d0 search_regs) line 4031 + 37 bytes | |
700 string_match_1(long 31222628, long 30282164, long 28377092, buffer * 0x022fde00, int 0) line 413 + 69 bytes | |
701 Fstring_match(long 31222628, long 30282164, long 28377092, long 28377092) line 436 + 34 bytes | |
702 Ffuncall(int 3, long * 0x008297f8) line 3488 + 168 bytes | |
703 execute_optimized_program(const unsigned char * 0x020ddc50, int 6, long * 0x020ddf50) line 744 + 16 bytes | |
704 funcall_compiled_function(long 34407748, int 1, long * 0x00829aec) line 516 + 53 bytes | |
705 Ffuncall(int 2, long * 0x00829ae8) line 3523 + 17 bytes | |
706 execute_optimized_program(const unsigned char * 0x020ddc90, int 4, long * 0x020ddf90) line 744 + 16 bytes | |
707 funcall_compiled_function(long 34407720, int 1, long * 0x00829e28) line 516 + 53 bytes | |
708 Ffuncall(int 2, long * 0x00829e24) line 3523 + 17 bytes | |
709 mapcar1(long 15, long * 0x00829e48, long 34447820, long 34187868) line 2929 + 11 bytes | |
710 Fmapcar(long 34447820, long 34187868) line 3035 + 21 bytes | |
711 Ffuncall(int 3, long * 0x00829f20) line 3488 + 93 bytes | |
712 execute_optimized_program(const unsigned char * 0x020c2b70, int 7, long * 0x020dd010) line 744 + 16 bytes | |
713 funcall_compiled_function(long 34407580, int 2, long * 0x0082a210) line 516 + 53 bytes | |
714 Ffuncall(int 3, long * 0x0082a20c) line 3523 + 17 bytes | |
715 execute_optimized_program(const unsigned char * 0x020cf810, int 6, long * 0x020cfb10) line 744 + 16 bytes | |
716 funcall_compiled_function(long 34407524, int 0, long * 0x0082a580) line 516 + 53 bytes | |
717 Ffuncall(int 1, long * 0x0082a57c) line 3523 + 17 bytes | |
718 run_hook_with_args_in_buffer(buffer * 0x022fde00, int 1, long * 0x0082a57c, int 0) line 3980 + 13 bytes | |
719 run_hook_with_args(int 1, long * 0x0082a57c, int 0) line 3993 + 23 bytes | |
720 Frun_hooks(int 1, long * 0x0082a57c) line 3847 + 19 bytes | |
721 run_hook(long 34447484) line 4094 + 11 bytes | |
722 unsafe_handle_wm_initmenu_1(frame * 0x01dbb000) line 736 + 11 bytes | |
723 unsafe_handle_wm_initmenu(long 28377092) line 807 + 11 bytes | |
724 condition_case_1(long 28377116, long (long)* 0x0101c827 unsafe_handle_wm_initmenu(long), long 28377092, long (long, long)* 0x01005fa4 mswindows_modal_loop_error_handler(long, long), long 28377092) line 1692 + 7 bytes | |
725 mswindows_protect_modal_loop(long (long)* 0x0101c827 unsafe_handle_wm_initmenu(long), long 28377092) line 1194 + 32 bytes | |
726 mswindows_handle_wm_initmenu(HMENU__ * 0x00010199, frame * 0x01dbb000) line 826 + 17 bytes | |
727 mswindows_wnd_proc(HWND__ * 0x000501da, unsigned int 278, unsigned int 65945, long 0) line 3089 + 31 bytes | |
728 USER32! UserCallWinProc@20 + 24 bytes | |
729 USER32! DispatchClientMessage@20 + 47 bytes | |
730 USER32! __fnDWORD@4 + 34 bytes | |
731 NTDLL! KiUserCallbackDispatcher@12 + 19 bytes | |
732 USER32! DispatchClientMessage@20 address 0x77e163cc | |
733 USER32! DefWindowProcW@16 + 34 bytes | |
734 qxeDefWindowProc(HWND__ * 0x000501da, unsigned int 274, unsigned int 61696, long 98) line 1188 + 22 bytes | |
735 mswindows_wnd_proc(HWND__ * 0x000501da, unsigned int 274, unsigned int 61696, long 98) line 3362 + 21 bytes | |
736 USER32! UserCallWinProc@20 + 24 bytes | |
737 USER32! DispatchClientMessage@20 + 47 bytes | |
738 USER32! __fnDWORD@4 + 34 bytes | |
739 NTDLL! KiUserCallbackDispatcher@12 + 19 bytes | |
740 USER32! DispatchClientMessage@20 address 0x77e163cc | |
741 USER32! DefWindowProcW@16 + 34 bytes | |
742 qxeDefWindowProc(HWND__ * 0x000501da, unsigned int 262, unsigned int 98, long 540016641) line 1188 + 22 bytes | |
743 mswindows_wnd_proc(HWND__ * 0x000501da, unsigned int 262, unsigned int 98, long 540016641) line 3362 + 21 bytes | |
744 USER32! UserCallWinProc@20 + 24 bytes | |
745 USER32! DispatchMessageWorker@8 + 244 bytes | |
746 USER32! DispatchMessageW@4 + 11 bytes | |
747 qxeDispatchMessage(const tagMSG * 0x0082c684 {msg=0x00000106 wp=0x00000062 lp=0x20300001}) line 989 + 10 bytes | |
748 mswindows_drain_windows_queue() line 1345 + 9 bytes | |
749 emacs_mswindows_quit_p() line 3947 | |
750 event_stream_quit_p() line 666 | |
751 check_quit() line 686 | |
752 check_what_happened() line 437 | |
753 re_match_2_internal(re_pattern_buffer * 0x012d5a18, const unsigned char * 0x00000000, int 0, const unsigned char * 0x02235000, int 23486, int 14645, re_registers * 0x012d53d0 search_regs, int 23486) line 4717 + 14 bytes | |
754 re_search_2(re_pattern_buffer * 0x012d5a18, const char * 0x02235000, int 23486, const char * 0x0223b38e, int 0, int 14645, int 8841, re_registers * 0x012d53d0 search_regs, int 23486) line 4269 + 37 bytes | |
755 search_buffer(buffer * 0x022fde00, long 29077572, long 13789, long 23487, long 1, int 1, long 28377092, long 28377092, int 0) line 1224 + 89 bytes | |
756 search_command(long 29077572, long 46975, long 28377116, long 28377092, long 28377092, int 1, int 1, int 0) line 1054 + 151 bytes | |
757 Fre_search_forward(long 29077572, long 46975, long 28377116, long 28377092, long 28377092) line 2147 + 31 bytes | |
758 Ffuncall(int 4, long * 0x0082ceb0) line 3488 + 216 bytes | |
759 execute_optimized_program(const unsigned char * 0x02047810, int 13, long * 0x02080c10) line 744 + 16 bytes | |
760 funcall_compiled_function(long 34187208, int 3, long * 0x0082d1b8) line 516 + 53 bytes | |
761 Ffuncall(int 4, long * 0x0082d1b4) line 3523 + 17 bytes | |
762 execute_optimized_program(const unsigned char * 0x01e96a10, int 6, long * 0x020ae510) line 744 + 16 bytes | |
763 funcall_compiled_function(long 34186676, int 3, long * 0x0082d4a0) line 516 + 53 bytes | |
764 Ffuncall(int 4, long * 0x0082d49c) line 3523 + 17 bytes | |
765 execute_optimized_program(const unsigned char * 0x02156b50, int 4, long * 0x020c2db0) line 744 + 16 bytes | |
766 funcall_compiled_function(long 34186564, int 2, long * 0x0082d780) line 516 + 53 bytes | |
767 Ffuncall(int 3, long * 0x0082d77c) line 3523 + 17 bytes | |
768 execute_optimized_program(const unsigned char * 0x0082d964, int 3, long * 0x020c2d70) line 744 + 16 bytes | |
769 Fbyte_code(long 29405156, long 34352480, long 7) line 2392 + 38 bytes | |
770 Feval(long 34354440) line 3290 + 187 bytes | |
771 condition_case_1(long 34354572, long (long)* 0x01087232 Feval(long), long 34354440, long (long, long)* 0x01084764 run_condition_case_handlers(long, long), long 28377092) line 1692 + 7 bytes | |
772 condition_case_3(long 34354440, long 28377092, long 34354572) line 1779 + 27 bytes | |
773 execute_rare_opcode(long * 0x0082dc7c, const unsigned char * 0x01b090af, int 143) line 1269 + 19 bytes | |
774 execute_optimized_program(const unsigned char * 0x01b09090, int 6, long * 0x020ae590) line 654 + 17 bytes | |
775 funcall_compiled_function(long 34186620, int 0, long * 0x0082df68) line 516 + 53 bytes | |
776 Ffuncall(int 1, long * 0x0082df64) line 3523 + 17 bytes | |
777 execute_optimized_program(const unsigned char * 0x02195470, int 1, long * 0x020c2df0) line 744 + 16 bytes | |
778 funcall_compiled_function(long 34186508, int 0, long * 0x0082e23c) line 516 + 53 bytes | |
779 Ffuncall(int 1, long * 0x0082e238) line 3523 + 17 bytes | |
780 execute_optimized_program(const unsigned char * 0x01e5d410, int 6, long * 0x0207d410) line 744 + 16 bytes | |
781 funcall_compiled_function(long 34186312, int 1, long * 0x0082e524) line 516 + 53 bytes | |
782 Ffuncall(int 2, long * 0x0082e520) line 3523 + 17 bytes | |
783 execute_optimized_program(const unsigned char * 0x02108fb0, int 2, long * 0x020c2e30) line 744 + 16 bytes | |
784 funcall_compiled_function(long 34186340, int 0, long * 0x0082e7fc) line 516 + 53 bytes | |
785 Ffuncall(int 1, long * 0x0082e7f8) line 3523 + 17 bytes | |
786 execute_optimized_program(const unsigned char * 0x020fe150, int 2, long * 0x01e6f510) line 744 + 16 bytes | |
787 funcall_compiled_function(long 31008124, int 0, long * 0x0082ebd8) line 516 + 53 bytes | |
788 Ffuncall(int 1, long * 0x0082ebd4) line 3523 + 17 bytes | |
789 run_hook_with_args_in_buffer(buffer * 0x022fde00, int 1, long * 0x0082ebd4, int 0) line 3980 + 13 bytes | |
790 run_hook_with_args(int 1, long * 0x0082ebd4, int 0) line 3993 + 23 bytes | |
791 Frun_hooks(int 1, long * 0x0082ebd4) line 3847 + 19 bytes | |
792 Ffuncall(int 2, long * 0x0082ebd0) line 3509 + 14 bytes | |
793 execute_optimized_program(const unsigned char * 0x01ef2210, int 5, long * 0x01da8e10) line 744 + 16 bytes | |
794 funcall_compiled_function(long 31020440, int 2, long * 0x0082eeb8) line 516 + 53 bytes | |
795 Ffuncall(int 3, long * 0x0082eeb4) line 3523 + 17 bytes | |
796 execute_optimized_program(const unsigned char * 0x0082f09c, int 3, long * 0x01d89390) line 744 + 16 bytes | |
797 Fbyte_code(long 31102388, long 30970752, long 7) line 2392 + 38 bytes | |
798 Feval(long 31087568) line 3290 + 187 bytes | |
799 condition_case_1(long 30961240, long (long)* 0x01087232 Feval(long), long 31087568, long (long, long)* 0x01084764 run_condition_case_handlers(long, long), long 28510180) line 1692 + 7 bytes | |
800 condition_case_3(long 31087568, long 28510180, long 30961240) line 1779 + 27 bytes | |
801 execute_rare_opcode(long * 0x0082f450, const unsigned char * 0x01ef23ec, int 143) line 1269 + 19 bytes | |
802 execute_optimized_program(const unsigned char * 0x01ef2310, int 6, long * 0x01da8f10) line 654 + 17 bytes | |
803 funcall_compiled_function(long 31020412, int 1, long * 0x0082f740) line 516 + 53 bytes | |
804 Ffuncall(int 2, long * 0x0082f73c) line 3523 + 17 bytes | |
805 execute_optimized_program(const unsigned char * 0x020fe650, int 3, long * 0x01d8c490) line 744 + 16 bytes | |
806 funcall_compiled_function(long 31020020, int 2, long * 0x0082fa14) line 516 + 53 bytes | |
807 Ffuncall(int 3, long * 0x0082fa10) line 3523 + 17 bytes | |
808 Fcall_interactively(long 29685180, long 28377092, long 28377092) line 1008 + 22 bytes | |
809 Fcommand_execute(long 29685180, long 28377092, long 28377092) line 2929 + 17 bytes | |
810 execute_command_event(command_builder * 0x01be1900, long 36626492) line 4048 + 25 bytes | |
811 Fdispatch_event(long 36626492) line 4341 + 70 bytes | |
812 Fcommand_loop_1() line 582 + 9 bytes | |
813 command_loop_1(long 28377092) line 495 | |
814 condition_case_1(long 28377188, long (long)* 0x01064fb9 command_loop_1(long), long 28377092, long (long, long)* 0x010649d0 cmd_error(long, long), long 28377092) line 1692 + 7 bytes | |
815 command_loop_3() line 256 + 35 bytes | |
816 command_loop_2(long 28377092) line 269 | |
817 internal_catch(long 28457612, long (long)* 0x01064b20 command_loop_2(long), long 28377092, int * volatile 0x00000000) line 1317 + 7 bytes | |
818 initial_command_loop(long 28377092) line 305 + 25 bytes | |
819 STACK_TRACE_EYE_CATCHER(int 1, char * * 0x01b63ff0, char * * 0x01ca5300, int 0) line 2501 | |
820 main(int 1, char * * 0x01b63ff0, char * * 0x01ca5300) line 2938 | |
821 XEMACS! mainCRTStartup + 180 bytes | |
822 _start() line 171 | |
823 KERNEL32! BaseProcessStart@4 + 115547 bytes | |
824 | |
825 */ | |
826 | |
675 if (dont_check_for_quit) | 827 if (dont_check_for_quit) |
676 return 0; | 828 return 0; |
677 | 829 |
678 if (quit_check_signal_happened) | 830 if (quit_check_signal_happened) |
679 { | 831 { |
832 /* Since arbitrary Lisp code may be executed, GC might happen, | |
833 which would majorly fuck a lot of things, e.g. re_match() | |
834 [string gets relocated] and lots of other code that's not | |
835 prepared to handle GC in QUIT. */ | |
836 int specdepth = begin_gc_forbidden (); | |
680 quit_check_signal_happened = 0; | 837 quit_check_signal_happened = 0; |
681 event_stream_quit_p (); | 838 event_stream_quit_p (); |
839 unbind_to (specdepth); | |
682 return 1; | 840 return 1; |
683 } | 841 } |
684 else | 842 else |
685 return 0; | 843 return 0; |
686 } | 844 } |