Mercurial > emacs
comparison src/keyboard.c @ 58818:f8cddae7d959
* gtkutil.c: Include signal.h and syssignal.h.
(xg_get_file_name): Block and unblock __SIGRTMIN if defined.
* alloc.c: If HAVE_GTK_AND_PTHREAD, include pthread.h,
new variables main_thread and alloc_mutex,
define (UN)BLOCK_INPUT_ALLOC to use alloc_mutex to protect
emacs_blocked_* calls and only do (UN)BLOCK_INPUT in the main thread.
If not HAVE_GTK_AND_PTHREAD, (UN)BLOCK_INPUT_ALLOC is the same as
(UN)BLOCK_INPUT.
(emacs_blocked_free, emacs_blocked_malloc)
(emacs_blocked_realloc): Use (UN)BLOCK_INPUT_ALLOC.
(uninterrupt_malloc): Initialize main_thread and alloc_mutex.
(reset_malloc_hooks): New function.
* lisp.h: Declare reset_malloc_hooks.
* emacs.c (Fdump_emacs): Call reset_malloc_hooks.
* keyboard.c: Conditionally include pthread.h
(handle_async_inpu, input_available_signalt): If not in the main
thread, block signal, send signal to main thread and return.
author | Jan Djärv <jan.h.d@swipnet.se> |
---|---|
date | Tue, 07 Dec 2004 08:25:43 +0000 |
parents | 95d38c47c806 |
children | 9f7c2511d457 549734260e34 |
comparison
equal
deleted
inserted
replaced
58817:65f1b18b7f66 | 58818:f8cddae7d959 |
---|---|
43 #include "systime.h" | 43 #include "systime.h" |
44 #include "atimer.h" | 44 #include "atimer.h" |
45 #include <setjmp.h> | 45 #include <setjmp.h> |
46 #include <errno.h> | 46 #include <errno.h> |
47 | 47 |
48 #ifdef HAVE_GTK_AND_PTHREAD | |
49 #include <pthread.h> | |
50 #endif | |
48 #ifdef MSDOS | 51 #ifdef MSDOS |
49 #include "msdos.h" | 52 #include "msdos.h" |
50 #include <time.h> | 53 #include <time.h> |
51 #else /* not MSDOS */ | 54 #else /* not MSDOS */ |
52 #ifndef VMS | 55 #ifndef VMS |
6775 handle_async_input () | 6778 handle_async_input () |
6776 { | 6779 { |
6777 #ifdef BSD4_1 | 6780 #ifdef BSD4_1 |
6778 extern int select_alarmed; | 6781 extern int select_alarmed; |
6779 #endif | 6782 #endif |
6783 #ifdef HAVE_GTK_AND_PTHREAD | |
6784 extern pthread_t main_thread; | |
6785 if (pthread_self () != main_thread) | |
6786 { | |
6787 /* POSIX says any thread can receive the signal. On GNU/Linux that is | |
6788 not true, but for other systems (FreeBSD at least) it is. So direct | |
6789 the signal to the correct thread and block it from this thread. */ | |
6790 #ifdef SIGIO | |
6791 sigset_t new_mask; | |
6792 | |
6793 sigemptyset (&new_mask); | |
6794 sigaddset (&new_mask, SIGIO); | |
6795 pthread_sigmask (SIG_BLOCK, &new_mask, 0); | |
6796 pthread_kill (main_thread, SIGIO); | |
6797 #endif | |
6798 return; | |
6799 } | |
6800 #endif | |
6801 | |
6780 interrupt_input_pending = 0; | 6802 interrupt_input_pending = 0; |
6781 | 6803 |
6782 while (1) | 6804 while (1) |
6783 { | 6805 { |
6784 int nread; | 6806 int nread; |
6802 input_available_signal (signo) | 6824 input_available_signal (signo) |
6803 int signo; | 6825 int signo; |
6804 { | 6826 { |
6805 /* Must preserve main program's value of errno. */ | 6827 /* Must preserve main program's value of errno. */ |
6806 int old_errno = errno; | 6828 int old_errno = errno; |
6807 | 6829 #ifdef HAVE_GTK_AND_PTHREAD |
6830 extern pthread_t main_thread; | |
6831 if (pthread_self () != main_thread) | |
6832 { | |
6833 /* POSIX says any thread can receive the signal. On GNU/Linux that is | |
6834 not true, but for other systems (FreeBSD at least) it is. So direct | |
6835 the signal to the correct thread and block it from this thread. */ | |
6836 sigset_t new_mask; | |
6837 | |
6838 sigemptyset (&new_mask); | |
6839 sigaddset (&new_mask, SIGIO); | |
6840 pthread_sigmask (SIG_BLOCK, &new_mask, 0); | |
6841 pthread_kill (main_thread, SIGIO); | |
6842 return; | |
6843 } | |
6844 #endif /* HAVE_GTK_AND_PTHREAD */ | |
6808 #if defined (USG) && !defined (POSIX_SIGNALS) | 6845 #if defined (USG) && !defined (POSIX_SIGNALS) |
6809 /* USG systems forget handlers when they are used; | 6846 /* USG systems forget handlers when they are used; |
6810 must reestablish each time */ | 6847 must reestablish each time */ |
6811 signal (signo, input_available_signal); | 6848 signal (signo, input_available_signal); |
6812 #endif /* USG */ | 6849 #endif /* USG */ |