aboutsummaryrefslogtreecommitdiffstats
path: root/src/alloc.c
diff options
context:
space:
mode:
authorJan Djärv2011-08-04 19:04:39 +0200
committerJan Djärv2011-08-04 19:04:39 +0200
commitae9e757af16bd39c21496430f66bcca2a47b4835 (patch)
treec442ffcf54a7946841d42365b4f426200a5f3cb1 /src/alloc.c
parent213bd7f2f126e8f69cbb9be274ea99581937f193 (diff)
downloademacs-ae9e757af16bd39c21496430f66bcca2a47b4835.tar.gz
emacs-ae9e757af16bd39c21496430f66bcca2a47b4835.zip
Check for pthread and use it if found.
* configure.in (HAVE_PTHREAD): Add check for -lpthread. (HAVE_GTK_AND_PTHREAD): Remove. * src/Makefile.in (LIB_PTHREAD): New variable. (LIBES): Add LIB_PTHREAD (Bug#9216). * src/alloc.c, src/emacs.c, src/gmalloc.c, src/gtkutil.c, src/keyboard.c, src/syssignal.h: Rename HAVE_GTK_AND_PTHREAD to HAVE_PTHREAD (Bug#9216).
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 b96fc1f0642..36ad645612d 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
@@ -84,13 +84,15 @@ extern size_t __malloc_extra_blocks;
84#endif /* not DOUG_LEA_MALLOC */ 84#endif /* not DOUG_LEA_MALLOC */
85 85
86#if ! defined SYSTEM_MALLOC && ! defined SYNC_INPUT 86#if ! defined SYSTEM_MALLOC && ! defined SYNC_INPUT
87#ifdef HAVE_GTK_AND_PTHREAD 87#ifdef HAVE_PTHREAD
88 88
89/* When GTK uses the file chooser dialog, different backends can be loaded 89/* When GTK uses the file chooser dialog, different backends can be loaded
90 dynamically. One such a backend is the Gnome VFS backend that gets loaded 90 dynamically. One such a backend is the Gnome VFS backend that gets loaded
91 if you run Gnome. That backend creates several threads and also allocates 91 if you run Gnome. That backend creates several threads and also allocates
92 memory with malloc. 92 memory with malloc.
93 93
94 Also, gconf and gsettings may create several threads.
95
94 If Emacs sets malloc hooks (! SYSTEM_MALLOC) and the emacs_blocked_* 96 If Emacs sets malloc hooks (! SYSTEM_MALLOC) and the emacs_blocked_*
95 functions below are called from malloc, there is a chance that one 97 functions below are called from malloc, there is a chance that one
96 of these threads preempts the Emacs main thread and the hook variables 98 of these threads preempts the Emacs main thread and the hook variables
@@ -122,12 +124,12 @@ static pthread_mutex_t alloc_mutex;
122 } \ 124 } \
123 while (0) 125 while (0)
124 126
125#else /* ! defined HAVE_GTK_AND_PTHREAD */ 127#else /* ! defined HAVE_PTHREAD */
126 128
127#define BLOCK_INPUT_ALLOC BLOCK_INPUT 129#define BLOCK_INPUT_ALLOC BLOCK_INPUT
128#define UNBLOCK_INPUT_ALLOC UNBLOCK_INPUT 130#define UNBLOCK_INPUT_ALLOC UNBLOCK_INPUT
129 131
130#endif /* ! defined HAVE_GTK_AND_PTHREAD */ 132#endif /* ! defined HAVE_PTHREAD */
131#endif /* ! defined SYSTEM_MALLOC && ! defined SYNC_INPUT */ 133#endif /* ! defined SYSTEM_MALLOC && ! defined SYNC_INPUT */
132 134
133/* Mark, unmark, query mark bit of a Lisp string. S must be a pointer 135/* Mark, unmark, query mark bit of a Lisp string. S must be a pointer
@@ -1265,7 +1267,7 @@ emacs_blocked_realloc (void *ptr, size_t size, const void *ptr2)
1265} 1267}
1266 1268
1267 1269
1268#ifdef HAVE_GTK_AND_PTHREAD 1270#ifdef HAVE_PTHREAD
1269/* Called from Fdump_emacs so that when the dumped Emacs starts, it has a 1271/* Called from Fdump_emacs so that when the dumped Emacs starts, it has a
1270 normal malloc. Some thread implementations need this as they call 1272 normal malloc. Some thread implementations need this as they call
1271 malloc before main. The pthread_self call in BLOCK_INPUT_ALLOC then 1273 malloc before main. The pthread_self call in BLOCK_INPUT_ALLOC then
@@ -1278,7 +1280,7 @@ reset_malloc_hooks (void)
1278 __malloc_hook = old_malloc_hook; 1280 __malloc_hook = old_malloc_hook;
1279 __realloc_hook = old_realloc_hook; 1281 __realloc_hook = old_realloc_hook;
1280} 1282}
1281#endif /* HAVE_GTK_AND_PTHREAD */ 1283#endif /* HAVE_PTHREAD */
1282 1284
1283 1285
1284/* Called from main to set up malloc to use our hooks. */ 1286/* Called from main to set up malloc to use our hooks. */
@@ -1286,7 +1288,7 @@ reset_malloc_hooks (void)
1286void 1288void
1287uninterrupt_malloc (void) 1289uninterrupt_malloc (void)
1288{ 1290{
1289#ifdef HAVE_GTK_AND_PTHREAD 1291#ifdef HAVE_PTHREAD
1290#ifdef DOUG_LEA_MALLOC 1292#ifdef DOUG_LEA_MALLOC
1291 pthread_mutexattr_t attr; 1293 pthread_mutexattr_t attr;
1292 1294
@@ -1300,7 +1302,7 @@ uninterrupt_malloc (void)
1300 and the bundled gmalloc.c doesn't require it. */ 1302 and the bundled gmalloc.c doesn't require it. */
1301 pthread_mutex_init (&alloc_mutex, NULL); 1303 pthread_mutex_init (&alloc_mutex, NULL);
1302#endif /* !DOUG_LEA_MALLOC */ 1304#endif /* !DOUG_LEA_MALLOC */
1303#endif /* HAVE_GTK_AND_PTHREAD */ 1305#endif /* HAVE_PTHREAD */
1304 1306
1305 if (__free_hook != emacs_blocked_free) 1307 if (__free_hook != emacs_blocked_free)
1306 old_free_hook = __free_hook; 1308 old_free_hook = __free_hook;