diff options
| author | Jan Djärv | 2004-12-15 21:40:41 +0000 |
|---|---|---|
| committer | Jan Djärv | 2004-12-15 21:40:41 +0000 |
| commit | 333f1b6f78ea3923fd49c8bb7f4d4aef39549591 (patch) | |
| tree | 9f8044dff23e460bb11e8aa324cec148e1ca89b0 /src/alloc.c | |
| parent | fecad3f6597e12724d2329354905a99450347d0c (diff) | |
| download | emacs-333f1b6f78ea3923fd49c8bb7f4d4aef39549591.tar.gz emacs-333f1b6f78ea3923fd49c8bb7f4d4aef39549591.zip | |
* syssignal.h: Declare main_thread.
(SIGNAL_THREAD_CHECK): New macro.
* keyboard.c (input_available_signal): Move thread checking code
to macro SIGNAL_THREAD_CHECK and call that macro.
(interrupt_signal): Call SIGNAL_THREAD_CHECK.
* alloc.c (uninterrupt_malloc): Move main_thread to emacs.c.
* emacs.c: Define main_thread.
(main): Initialize main_thread.
(handle_USR1_signal, handle_USR2_signal, fatal_error_signal)
(memory_warning_signal): Call SIGNAL_THREAD_CHECK.
* floatfns.c (float_error): Call SIGNAL_THREAD_CHECK.
* dispnew.c (window_change_signal): Call SIGNAL_THREAD_CHECK.
* sysdep.c (select_alarm): Call SIGNAL_THREAD_CHECK.
* process.c (send_process_trap, sigchld_handler): Call
SIGNAL_THREAD_CHECK.
* data.c (arith_error): Call SIGNAL_THREAD_CHECK.
* atimer.c (alarm_signal_handler): Call SIGNAL_THREAD_CHECK.
Diffstat (limited to 'src/alloc.c')
| -rw-r--r-- | src/alloc.c | 5 |
1 files changed, 1 insertions, 4 deletions
diff --git a/src/alloc.c b/src/alloc.c index 0ea389117ba..5038fdfce10 100644 --- a/src/alloc.c +++ b/src/alloc.c | |||
| @@ -99,7 +99,7 @@ extern __malloc_size_t __malloc_extra_blocks; | |||
| 99 | If Emacs sets malloc hooks (! SYSTEM_MALLOC) and the emacs_blocked_* | 99 | If Emacs sets malloc hooks (! SYSTEM_MALLOC) and the emacs_blocked_* |
| 100 | functions below are called from malloc, there is a chance that one | 100 | functions below are called from malloc, there is a chance that one |
| 101 | of these threads preempts the Emacs main thread and the hook variables | 101 | of these threads preempts the Emacs main thread and the hook variables |
| 102 | end up in a inconsistent state. So we have a mutex to prevent that (note | 102 | end up in an inconsistent state. So we have a mutex to prevent that (note |
| 103 | that the backend handles concurrent access to malloc within its own threads | 103 | that the backend handles concurrent access to malloc within its own threads |
| 104 | but Emacs code running in the main thread is not included in that control). | 104 | but Emacs code running in the main thread is not included in that control). |
| 105 | 105 | ||
| @@ -109,7 +109,6 @@ extern __malloc_size_t __malloc_extra_blocks; | |||
| 109 | To prevent that, we only call BLOCK/UNBLOCK from the main thread. */ | 109 | To prevent that, we only call BLOCK/UNBLOCK from the main thread. */ |
| 110 | 110 | ||
| 111 | static pthread_mutex_t alloc_mutex; | 111 | static pthread_mutex_t alloc_mutex; |
| 112 | pthread_t main_thread; | ||
| 113 | 112 | ||
| 114 | #define BLOCK_INPUT_ALLOC \ | 113 | #define BLOCK_INPUT_ALLOC \ |
| 115 | do \ | 114 | do \ |
| @@ -1310,8 +1309,6 @@ uninterrupt_malloc () | |||
| 1310 | pthread_mutexattr_init (&attr); | 1309 | pthread_mutexattr_init (&attr); |
| 1311 | pthread_mutexattr_settype (&attr, PTHREAD_MUTEX_RECURSIVE); | 1310 | pthread_mutexattr_settype (&attr, PTHREAD_MUTEX_RECURSIVE); |
| 1312 | pthread_mutex_init (&alloc_mutex, &attr); | 1311 | pthread_mutex_init (&alloc_mutex, &attr); |
| 1313 | |||
| 1314 | main_thread = pthread_self (); | ||
| 1315 | #endif /* HAVE_GTK_AND_PTHREAD */ | 1312 | #endif /* HAVE_GTK_AND_PTHREAD */ |
| 1316 | 1313 | ||
| 1317 | if (__free_hook != emacs_blocked_free) | 1314 | if (__free_hook != emacs_blocked_free) |