aboutsummaryrefslogtreecommitdiffstats
path: root/src/gmalloc.c
diff options
context:
space:
mode:
authorGlenn Morris2014-08-14 21:34:06 -0700
committerGlenn Morris2014-08-14 21:34:06 -0700
commited30c57cc9cdcf8ddc169f4b042146db9b3b7179 (patch)
tree30e07052f35dcfb7c4616a30c8e9bdebb8a3526c /src/gmalloc.c
parentb9558683e3339fb95ff9cad1ced705f525d86d7a (diff)
parent315865d31dde9f0771f96a98a4562bd282aa21ea (diff)
downloademacs-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.c21
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
499pthread_mutex_t _malloc_mutex = PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP;
500pthread_mutex_t _aligned_blocks_mutex = PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP;
501#else /* not CYGWIN */
493pthread_mutex_t _malloc_mutex = PTHREAD_MUTEX_INITIALIZER; 502pthread_mutex_t _malloc_mutex = PTHREAD_MUTEX_INITIALIZER;
494pthread_mutex_t _aligned_blocks_mutex = PTHREAD_MUTEX_INITIALIZER; 503pthread_mutex_t _aligned_blocks_mutex = PTHREAD_MUTEX_INITIALIZER;
504#endif /* not CYGWIN */
495int _malloc_thread_enabled_p; 505int _malloc_thread_enabled_p;
496 506
497static void 507static 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
538static void 557static void
539malloc_initialize_1 (void) 558malloc_initialize_1 (void)