diff options
| author | Glenn Morris | 2014-08-14 21:34:06 -0700 |
|---|---|---|
| committer | Glenn Morris | 2014-08-14 21:34:06 -0700 |
| commit | ed30c57cc9cdcf8ddc169f4b042146db9b3b7179 (patch) | |
| tree | 30e07052f35dcfb7c4616a30c8e9bdebb8a3526c /src/gmalloc.c | |
| parent | b9558683e3339fb95ff9cad1ced705f525d86d7a (diff) | |
| parent | 315865d31dde9f0771f96a98a4562bd282aa21ea (diff) | |
| download | emacs-ed30c57cc9cdcf8ddc169f4b042146db9b3b7179.tar.gz emacs-ed30c57cc9cdcf8ddc169f4b042146db9b3b7179.zip | |
Merge from emacs-24; up to 2014-06-29T18:32:35Z!michael.albinus@gmx.de
Diffstat (limited to 'src/gmalloc.c')
| -rw-r--r-- | src/gmalloc.c | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/src/gmalloc.c b/src/gmalloc.c index ab1dfd07db2..27965e37539 100644 --- a/src/gmalloc.c +++ b/src/gmalloc.c | |||
| @@ -490,8 +490,18 @@ register_heapinfo (void) | |||
| 490 | } | 490 | } |
| 491 | 491 | ||
| 492 | #ifdef USE_PTHREAD | 492 | #ifdef USE_PTHREAD |
| 493 | /* On Cygwin prior to 1.7.31, pthread_mutexes were ERRORCHECK mutexes | ||
| 494 | by default. When the default changed to NORMAL in Cygwin-1.7.31, | ||
| 495 | deadlocks occurred (bug#18222). As a temporary workaround, we | ||
| 496 | explicitly set the mutexes to be of ERRORCHECK type, restoring the | ||
| 497 | previous behavior. */ | ||
| 498 | #ifdef CYGWIN | ||
| 499 | pthread_mutex_t _malloc_mutex = PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP; | ||
| 500 | pthread_mutex_t _aligned_blocks_mutex = PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP; | ||
| 501 | #else /* not CYGWIN */ | ||
| 493 | pthread_mutex_t _malloc_mutex = PTHREAD_MUTEX_INITIALIZER; | 502 | pthread_mutex_t _malloc_mutex = PTHREAD_MUTEX_INITIALIZER; |
| 494 | pthread_mutex_t _aligned_blocks_mutex = PTHREAD_MUTEX_INITIALIZER; | 503 | pthread_mutex_t _aligned_blocks_mutex = PTHREAD_MUTEX_INITIALIZER; |
| 504 | #endif /* not CYGWIN */ | ||
| 495 | int _malloc_thread_enabled_p; | 505 | int _malloc_thread_enabled_p; |
| 496 | 506 | ||
| 497 | static void | 507 | static void |
| @@ -526,14 +536,23 @@ malloc_enable_thread (void) | |||
| 526 | initialized mutexes when they are used first. To avoid such a | 536 | initialized mutexes when they are used first. To avoid such a |
| 527 | situation, we initialize mutexes here while their use is | 537 | situation, we initialize mutexes here while their use is |
| 528 | disabled in malloc etc. */ | 538 | disabled in malloc etc. */ |
| 539 | #ifdef CYGWIN | ||
| 540 | /* Use ERRORCHECK mutexes; see comment above. */ | ||
| 541 | pthread_mutexattr_t attr; | ||
| 542 | pthread_mutexattr_init (&attr); | ||
| 543 | pthread_mutexattr_settype (&attr, PTHREAD_MUTEX_ERRORCHECK); | ||
| 544 | pthread_mutex_init (&_malloc_mutex, &attr); | ||
| 545 | pthread_mutex_init (&_aligned_blocks_mutex, &attr); | ||
| 546 | #else /* not CYGWIN */ | ||
| 529 | pthread_mutex_init (&_malloc_mutex, NULL); | 547 | pthread_mutex_init (&_malloc_mutex, NULL); |
| 530 | pthread_mutex_init (&_aligned_blocks_mutex, NULL); | 548 | pthread_mutex_init (&_aligned_blocks_mutex, NULL); |
| 549 | #endif /* not CYGWIN */ | ||
| 531 | pthread_atfork (malloc_atfork_handler_prepare, | 550 | pthread_atfork (malloc_atfork_handler_prepare, |
| 532 | malloc_atfork_handler_parent, | 551 | malloc_atfork_handler_parent, |
| 533 | malloc_atfork_handler_child); | 552 | malloc_atfork_handler_child); |
| 534 | _malloc_thread_enabled_p = 1; | 553 | _malloc_thread_enabled_p = 1; |
| 535 | } | 554 | } |
| 536 | #endif | 555 | #endif /* USE_PTHREAD */ |
| 537 | 556 | ||
| 538 | static void | 557 | static void |
| 539 | malloc_initialize_1 (void) | 558 | malloc_initialize_1 (void) |