aboutsummaryrefslogtreecommitdiffstats
path: root/src/alloc.c
diff options
context:
space:
mode:
authorPaul Eggert2011-08-04 19:19:34 -0700
committerPaul Eggert2011-08-04 19:19:34 -0700
commit0e51f7172bd1ab8b9c1bb52598afb5017e19b9c3 (patch)
tree5f09676e1b87f3f274a60fe79728f84a3d0c9a9b /src/alloc.c
parent0065d05491ce5981ea20896bb26d21dcd31e6769 (diff)
parente504613cc63d2a3925c546177a04637e25a1a4ae (diff)
downloademacs-0e51f7172bd1ab8b9c1bb52598afb5017e19b9c3.tar.gz
emacs-0e51f7172bd1ab8b9c1bb52598afb5017e19b9c3.zip
Merge from trunk.
Diffstat (limited to 'src/alloc.c')
-rw-r--r--src/alloc.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/src/alloc.c b/src/alloc.c
index a1af0df11f0..2d256800466 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -24,7 +24,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
24 24
25#include <signal.h> 25#include <signal.h>
26 26
27#ifdef HAVE_GTK_AND_PTHREAD 27#ifdef HAVE_PTHREAD
28#include <pthread.h> 28#include <pthread.h>
29#endif 29#endif
30 30
@@ -85,13 +85,15 @@ extern size_t __malloc_extra_blocks;
85#endif /* not DOUG_LEA_MALLOC */ 85#endif /* not DOUG_LEA_MALLOC */
86 86
87#if ! defined SYSTEM_MALLOC && ! defined SYNC_INPUT 87#if ! defined SYSTEM_MALLOC && ! defined SYNC_INPUT
88#ifdef HAVE_GTK_AND_PTHREAD 88#ifdef HAVE_PTHREAD
89 89
90/* When GTK uses the file chooser dialog, different backends can be loaded 90/* When GTK uses the file chooser dialog, different backends can be loaded
91 dynamically. One such a backend is the Gnome VFS backend that gets loaded 91 dynamically. One such a backend is the Gnome VFS backend that gets loaded
92 if you run Gnome. That backend creates several threads and also allocates 92 if you run Gnome. That backend creates several threads and also allocates
93 memory with malloc. 93 memory with malloc.
94 94
95 Also, gconf and gsettings may create several threads.
96
95 If Emacs sets malloc hooks (! SYSTEM_MALLOC) and the emacs_blocked_* 97 If Emacs sets malloc hooks (! SYSTEM_MALLOC) and the emacs_blocked_*
96 functions below are called from malloc, there is a chance that one 98 functions below are called from malloc, there is a chance that one
97 of these threads preempts the Emacs main thread and the hook variables 99 of these threads preempts the Emacs main thread and the hook variables
@@ -123,12 +125,12 @@ static pthread_mutex_t alloc_mutex;
123 } \ 125 } \
124 while (0) 126 while (0)
125 127
126#else /* ! defined HAVE_GTK_AND_PTHREAD */ 128#else /* ! defined HAVE_PTHREAD */
127 129
128#define BLOCK_INPUT_ALLOC BLOCK_INPUT 130#define BLOCK_INPUT_ALLOC BLOCK_INPUT
129#define UNBLOCK_INPUT_ALLOC UNBLOCK_INPUT 131#define UNBLOCK_INPUT_ALLOC UNBLOCK_INPUT
130 132
131#endif /* ! defined HAVE_GTK_AND_PTHREAD */ 133#endif /* ! defined HAVE_PTHREAD */
132#endif /* ! defined SYSTEM_MALLOC && ! defined SYNC_INPUT */ 134#endif /* ! defined SYSTEM_MALLOC && ! defined SYNC_INPUT */
133 135
134/* Mark, unmark, query mark bit of a Lisp string. S must be a pointer 136/* Mark, unmark, query mark bit of a Lisp string. S must be a pointer
@@ -1353,7 +1355,7 @@ emacs_blocked_realloc (void *ptr, size_t size, const void *ptr2)
1353} 1355}
1354 1356
1355 1357
1356#ifdef HAVE_GTK_AND_PTHREAD 1358#ifdef HAVE_PTHREAD
1357/* Called from Fdump_emacs so that when the dumped Emacs starts, it has a 1359/* Called from Fdump_emacs so that when the dumped Emacs starts, it has a
1358 normal malloc. Some thread implementations need this as they call 1360 normal malloc. Some thread implementations need this as they call
1359 malloc before main. The pthread_self call in BLOCK_INPUT_ALLOC then 1361 malloc before main. The pthread_self call in BLOCK_INPUT_ALLOC then
@@ -1366,7 +1368,7 @@ reset_malloc_hooks (void)
1366 __malloc_hook = old_malloc_hook; 1368 __malloc_hook = old_malloc_hook;
1367 __realloc_hook = old_realloc_hook; 1369 __realloc_hook = old_realloc_hook;
1368} 1370}
1369#endif /* HAVE_GTK_AND_PTHREAD */ 1371#endif /* HAVE_PTHREAD */
1370 1372
1371 1373
1372/* Called from main to set up malloc to use our hooks. */ 1374/* Called from main to set up malloc to use our hooks. */
@@ -1374,7 +1376,7 @@ reset_malloc_hooks (void)
1374void 1376void
1375uninterrupt_malloc (void) 1377uninterrupt_malloc (void)
1376{ 1378{
1377#ifdef HAVE_GTK_AND_PTHREAD 1379#ifdef HAVE_PTHREAD
1378#ifdef DOUG_LEA_MALLOC 1380#ifdef DOUG_LEA_MALLOC
1379 pthread_mutexattr_t attr; 1381 pthread_mutexattr_t attr;
1380 1382
@@ -1388,7 +1390,7 @@ uninterrupt_malloc (void)
1388 and the bundled gmalloc.c doesn't require it. */ 1390 and the bundled gmalloc.c doesn't require it. */
1389 pthread_mutex_init (&alloc_mutex, NULL); 1391 pthread_mutex_init (&alloc_mutex, NULL);
1390#endif /* !DOUG_LEA_MALLOC */ 1392#endif /* !DOUG_LEA_MALLOC */
1391#endif /* HAVE_GTK_AND_PTHREAD */ 1393#endif /* HAVE_PTHREAD */
1392 1394
1393 if (__free_hook != emacs_blocked_free) 1395 if (__free_hook != emacs_blocked_free)
1394 old_free_hook = __free_hook; 1396 old_free_hook = __free_hook;