all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "Jan Djärv" <jan.h.d@swipnet.se>
To: YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
Cc: "Herbert J. Skuhra" <h.skuhra@gmail.com>, emacs-devel@gnu.org
Subject: Re: emacs-unicode-2 bootstrap on FreeBSD (temacs coredump)
Date: Wed, 01 Aug 2007 13:53:57 +0200	[thread overview]
Message-ID: <46B07455.4000504@swipnet.se> (raw)
In-Reply-To: <wlps27h6y0.wl%mituharu@math.s.chiba-u.ac.jp>



YAMAMOTO Mitsuharu skrev:
>>>>>> On Wed, 01 Aug 2007 19:07:47 +0900, YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp> said:
> 
>> It might be possible to call pthread_mutex_init for all malloc
>> mutexes at the (non-thread-safe) initialization stage with
>> temporarily disabling the use of the mutexes.
> 
> Could you try if this works?  As usual, I can't test it myself.

I think we should call LOCK/UNLOCK on them also just to be sure.
You never know what those BDS guys are up to :-)

	Jan D.

> 
> 				     YAMAMOTO Mitsuharu
> 				mituharu@math.s.chiba-u.ac.jp
> 
> Index: src/gmalloc.c
> ===================================================================
> RCS file: /cvsroot/emacs/emacs/src/gmalloc.c,v
> retrieving revision 1.24
> diff -c -p -r1.24 gmalloc.c
> *** src/gmalloc.c	29 Jul 2007 10:12:21 -0000	1.24
> --- src/gmalloc.c	1 Aug 2007 10:35:05 -0000
> *************** extern void _free_internal_nolock PP ((_
> *** 242,249 ****
>   
>   #ifdef USE_PTHREAD
>   extern pthread_mutex_t _malloc_mutex, _aligned_blocks_mutex;
> ! #define LOCK()     pthread_mutex_lock (&_malloc_mutex)
> ! #define UNLOCK()   pthread_mutex_unlock (&_malloc_mutex)
>   #define LOCK_ALIGNED_BLOCKS()     pthread_mutex_lock (&_aligned_blocks_mutex)
>   #define UNLOCK_ALIGNED_BLOCKS()   pthread_mutex_unlock (&_aligned_blocks_mutex)
>   #else
> --- 242,256 ----
>   
>   #ifdef USE_PTHREAD
>   extern pthread_mutex_t _malloc_mutex, _aligned_blocks_mutex;
> ! extern int _malloc_mutex_disabled_p;
> ! #define LOCK() \
> !   do { \
> !     if (!_malloc_mutex_disabled_p) pthread_mutex_lock (&_malloc_mutex); \
> !   } while (0)
> ! #define UNLOCK() \
> !   do { \
> !     if (!_malloc_mutex_disabled_p) pthread_mutex_unlock (&_malloc_mutex); \
> !   } while (0)
>   #define LOCK_ALIGNED_BLOCKS()     pthread_mutex_lock (&_aligned_blocks_mutex)
>   #define UNLOCK_ALIGNED_BLOCKS()   pthread_mutex_unlock (&_aligned_blocks_mutex)
>   #else
> *************** register_heapinfo ()
> *** 563,568 ****
> --- 570,576 ----
>   #ifdef USE_PTHREAD
>   pthread_mutex_t _malloc_mutex = PTHREAD_MUTEX_INITIALIZER;
>   pthread_mutex_t _aligned_blocks_mutex = PTHREAD_MUTEX_INITIALIZER;
> + int _malloc_mutex_disabled_p;
>   #endif
>   
>   static void
> *************** __malloc_initialize ()
> *** 617,622 ****
> --- 625,641 ----
>   
>     malloc_initialize_1 ();
>   
> +   /* Some pthread implementations call malloc for statically
> +      initialized mutexes when they are used first.  To avoid such a
> +      situation, we initialize mutexes here with temporarily disabling
> +      the use of mutexes.  */
> + #ifdef USE_PTHREAD
> +   _malloc_mutex_disabled_p = 1;
> +   pthread_mutex_init (&_malloc_mutex, NULL);
> +   pthread_mutex_init (&_aligned_blocks_mutex, NULL);
> +   _malloc_mutex_disabled_p = 0;
> + #endif
> + 
>     return __malloc_initialized;
>   }
>   
> 
> 
> _______________________________________________
> Emacs-devel mailing list
> Emacs-devel@gnu.org
> http://lists.gnu.org/mailman/listinfo/emacs-devel

  reply	other threads:[~2007-08-01 11:53 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-07-27 16:05 emacs-unicode-2 bootstrap on FreeBSD (temacs coredump) Damien Deville
2007-07-29 10:13 ` Jan Djärv
2007-07-31 19:09   ` Herbert J. Skuhra
2007-08-01  8:46     ` YAMAMOTO Mitsuharu
2007-08-01  9:20       ` Jan Djärv
2007-08-01  9:35         ` YAMAMOTO Mitsuharu
2007-08-01 10:07           ` YAMAMOTO Mitsuharu
2007-08-01 10:42             ` YAMAMOTO Mitsuharu
2007-08-01 11:53               ` Jan Djärv [this message]
2007-08-01 11:54                 ` Jan Djärv
2007-08-01 14:38                   ` Miles Bader
2007-08-01 18:27               ` Jan D.
2007-08-06  8:47                 ` YAMAMOTO Mitsuharu
2007-08-06 10:04                   ` YAMAMOTO Mitsuharu
2007-08-06 18:17                     ` Herbert J. Skuhra
2007-08-06 21:09                       ` Ryan Yeske
2007-08-07  8:05                         ` Jan Djärv
2007-08-07  9:22                           ` YAMAMOTO Mitsuharu
2007-08-01 11:52             ` Jan Djärv

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=46B07455.4000504@swipnet.se \
    --to=jan.h.d@swipnet.se \
    --cc=emacs-devel@gnu.org \
    --cc=h.skuhra@gmail.com \
    --cc=mituharu@math.s.chiba-u.ac.jp \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.