Commit ae9e757a authored by Jan Djärv's avatar Jan Djärv

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).
parent 213bd7f2
2011-08-04 Jan Djärv <jan.h.d@swipnet.se>
* configure.in (HAVE_PTHREAD): Add check for -lpthread (Bug#9216).
(HAVE_GTK_AND_PTHREAD): Remove.
2011-07-28 Alp Aker <alp.tekin.aker@gmail.com> 2011-07-28 Alp Aker <alp.tekin.aker@gmail.com>
* configure.in (HAVE_RSVG): Allow use of -lrsvg-2 for any NextStep * configure.in (HAVE_RSVG): Allow use of -lrsvg-2 for any NextStep
......
...@@ -1687,6 +1687,21 @@ dnl AC_CHECK_LIB(resolv, gethostbyname) ...@@ -1687,6 +1687,21 @@ dnl AC_CHECK_LIB(resolv, gethostbyname)
dnl FIXME replace main with a function we actually want from this library. dnl FIXME replace main with a function we actually want from this library.
AC_CHECK_LIB(Xbsd, main, LD_SWITCH_X_SITE="$LD_SWITCH_X_SITE -lXbsd") AC_CHECK_LIB(Xbsd, main, LD_SWITCH_X_SITE="$LD_SWITCH_X_SITE -lXbsd")
dnl Check if pthreads is available.
LIB_PTHREAD=
AC_CHECK_HEADERS(pthread.h)
if test "$ac_cv_header_pthread_h"; then
AC_CHECK_LIB(pthread, pthread_self, HAVE_PTHREAD=yes)
fi
if test "$HAVE_PTHREAD" = yes; then
case "${canonical}" in
*-hpux*) ;;
*) LIB_PTHREAD="-lpthread" ;;
esac
AC_DEFINE(HAVE_PTHREAD, 1, [Define to 1 if you have pthread (-lpthread).])
fi
AC_SUBST([LIB_PTHREAD])
AC_CHECK_LIB(pthreads, cma_open) AC_CHECK_LIB(pthreads, cma_open)
## Note: when using cpp in s/aix4.2.h, this definition depended on ## Note: when using cpp in s/aix4.2.h, this definition depended on
...@@ -1943,21 +1958,6 @@ if test "${HAVE_GTK}" = "yes"; then ...@@ -1943,21 +1958,6 @@ if test "${HAVE_GTK}" = "yes"; then
AC_CHECK_FUNCS(gtk_file_selection_new) AC_CHECK_FUNCS(gtk_file_selection_new)
fi fi
dnl Check if pthreads are available. Emacs only needs this when using
dnl gtk_file_chooser under Gnome.
HAVE_GTK_AND_PTHREAD=no
AC_CHECK_HEADERS(pthread.h)
if test "$ac_cv_header_pthread_h"; then
AC_CHECK_LIB(pthread, pthread_self, HAVE_GTK_AND_PTHREAD=yes)
fi
if test "$HAVE_GTK_AND_PTHREAD" = yes; then
case "${canonical}" in
*-hpux*) ;;
*) GTK_LIBS="$GTK_LIBS -lpthread" ;;
esac
AC_DEFINE(HAVE_GTK_AND_PTHREAD, 1,
[Define to 1 if you have GTK and pthread (-lpthread).])
fi
dnl Check for functions introduced in 2.14 and later. dnl Check for functions introduced in 2.14 and later.
AC_CHECK_FUNCS(gtk_widget_get_window gtk_widget_set_has_window \ AC_CHECK_FUNCS(gtk_widget_get_window gtk_widget_set_has_window \
......
2011-08-04 Jan Djärv <jan.h.d@swipnet.se>
* Makefile.in (LIB_PTHREAD): New variable.
(LIBES): Add LIB_PTHREAD (Bug#9216).
* alloc.c, emacs.c, gmalloc.c, gtkutil.c, keyboard.c, syssignal.h:
Rename HAVE_GTK_AND_PTHREAD to HAVE_PTHREAD (Bug#9216).
2011-08-04 Andreas Schwab <schwab@linux-m68k.org> 2011-08-04 Andreas Schwab <schwab@linux-m68k.org>
* regex.c (re_iswctype): Remove some redundant boolean * regex.c (re_iswctype): Remove some redundant boolean
......
...@@ -130,6 +130,9 @@ START_FILES = @START_FILES@ ...@@ -130,6 +130,9 @@ START_FILES = @START_FILES@
## -lm, or empty. ## -lm, or empty.
LIB_MATH=@LIB_MATH@ LIB_MATH=@LIB_MATH@
## -lpthreads, or empty.
LIB_PTHREAD=@LIB_PTHREAD@
LIBTIFF=@LIBTIFF@ LIBTIFF=@LIBTIFF@
LIBJPEG=@LIBJPEG@ LIBJPEG=@LIBJPEG@
LIBPNG=@LIBPNG@ LIBPNG=@LIBPNG@
...@@ -385,7 +388,7 @@ LIBES = $(LIBS) $(LIBX_BASE) $(LIBX_OTHER) $(LIBSOUND) \ ...@@ -385,7 +388,7 @@ LIBES = $(LIBS) $(LIBX_BASE) $(LIBX_OTHER) $(LIBSOUND) \
$(LIBXML2_LIBS) $(LIBGPM) $(LIBRESOLV) $(LIBS_SYSTEM) \ $(LIBXML2_LIBS) $(LIBGPM) $(LIBRESOLV) $(LIBS_SYSTEM) \
$(LIBS_TERMCAP) $(GETLOADAVG_LIBS) $(SETTINGS_LIBS) $(LIBSELINUX_LIBS) \ $(LIBS_TERMCAP) $(GETLOADAVG_LIBS) $(SETTINGS_LIBS) $(LIBSELINUX_LIBS) \
$(FREETYPE_LIBS) $(FONTCONFIG_LIBS) $(LIBOTF_LIBS) $(M17N_FLT_LIBS) \ $(FREETYPE_LIBS) $(FONTCONFIG_LIBS) $(LIBOTF_LIBS) $(M17N_FLT_LIBS) \
$(LIBGNUTLS_LIBS) $(LIB_PTHREAD_SIGMASK) \ $(LIBGNUTLS_LIBS) $(LIB_PTHREAD) $(LIB_PTHREAD_SIGMASK) \
$(LIB_GCC) $(LIB_MATH) $(LIB_STANDARD) $(LIB_GCC) $(LIB_GCC) $(LIB_MATH) $(LIB_STANDARD) $(LIB_GCC)
all: emacs$(EXEEXT) $(OTHER_FILES) all: emacs$(EXEEXT) $(OTHER_FILES)
......
...@@ -24,7 +24,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ ...@@ -24,7 +24,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#include <signal.h> #include <signal.h>
#ifdef HAVE_GTK_AND_PTHREAD #ifdef HAVE_PTHREAD
#include <pthread.h> #include <pthread.h>
#endif #endif
...@@ -84,13 +84,15 @@ extern size_t __malloc_extra_blocks; ...@@ -84,13 +84,15 @@ extern size_t __malloc_extra_blocks;
#endif /* not DOUG_LEA_MALLOC */ #endif /* not DOUG_LEA_MALLOC */
#if ! defined SYSTEM_MALLOC && ! defined SYNC_INPUT #if ! defined SYSTEM_MALLOC && ! defined SYNC_INPUT
#ifdef HAVE_GTK_AND_PTHREAD #ifdef HAVE_PTHREAD
/* When GTK uses the file chooser dialog, different backends can be loaded /* When GTK uses the file chooser dialog, different backends can be loaded
dynamically. One such a backend is the Gnome VFS backend that gets loaded dynamically. One such a backend is the Gnome VFS backend that gets loaded
if you run Gnome. That backend creates several threads and also allocates if you run Gnome. That backend creates several threads and also allocates
memory with malloc. memory with malloc.
Also, gconf and gsettings may create several threads.
If Emacs sets malloc hooks (! SYSTEM_MALLOC) and the emacs_blocked_* If Emacs sets malloc hooks (! SYSTEM_MALLOC) and the emacs_blocked_*
functions below are called from malloc, there is a chance that one functions below are called from malloc, there is a chance that one
of these threads preempts the Emacs main thread and the hook variables of these threads preempts the Emacs main thread and the hook variables
...@@ -122,12 +124,12 @@ static pthread_mutex_t alloc_mutex; ...@@ -122,12 +124,12 @@ static pthread_mutex_t alloc_mutex;
} \ } \
while (0) while (0)
#else /* ! defined HAVE_GTK_AND_PTHREAD */ #else /* ! defined HAVE_PTHREAD */
#define BLOCK_INPUT_ALLOC BLOCK_INPUT #define BLOCK_INPUT_ALLOC BLOCK_INPUT
#define UNBLOCK_INPUT_ALLOC UNBLOCK_INPUT #define UNBLOCK_INPUT_ALLOC UNBLOCK_INPUT
#endif /* ! defined HAVE_GTK_AND_PTHREAD */ #endif /* ! defined HAVE_PTHREAD */
#endif /* ! defined SYSTEM_MALLOC && ! defined SYNC_INPUT */ #endif /* ! defined SYSTEM_MALLOC && ! defined SYNC_INPUT */
/* Mark, unmark, query mark bit of a Lisp string. S must be a pointer /* 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,7 +1267,7 @@ emacs_blocked_realloc (void *ptr, size_t size, const void *ptr2)
} }
#ifdef HAVE_GTK_AND_PTHREAD #ifdef HAVE_PTHREAD
/* Called from Fdump_emacs so that when the dumped Emacs starts, it has a /* Called from Fdump_emacs so that when the dumped Emacs starts, it has a
normal malloc. Some thread implementations need this as they call normal malloc. Some thread implementations need this as they call
malloc before main. The pthread_self call in BLOCK_INPUT_ALLOC then malloc before main. The pthread_self call in BLOCK_INPUT_ALLOC then
...@@ -1278,7 +1280,7 @@ reset_malloc_hooks (void) ...@@ -1278,7 +1280,7 @@ reset_malloc_hooks (void)
__malloc_hook = old_malloc_hook; __malloc_hook = old_malloc_hook;
__realloc_hook = old_realloc_hook; __realloc_hook = old_realloc_hook;
} }
#endif /* HAVE_GTK_AND_PTHREAD */ #endif /* HAVE_PTHREAD */
/* Called from main to set up malloc to use our hooks. */ /* Called from main to set up malloc to use our hooks. */
...@@ -1286,7 +1288,7 @@ reset_malloc_hooks (void) ...@@ -1286,7 +1288,7 @@ reset_malloc_hooks (void)
void void
uninterrupt_malloc (void) uninterrupt_malloc (void)
{ {
#ifdef HAVE_GTK_AND_PTHREAD #ifdef HAVE_PTHREAD
#ifdef DOUG_LEA_MALLOC #ifdef DOUG_LEA_MALLOC
pthread_mutexattr_t attr; pthread_mutexattr_t attr;
...@@ -1300,7 +1302,7 @@ uninterrupt_malloc (void) ...@@ -1300,7 +1302,7 @@ uninterrupt_malloc (void)
and the bundled gmalloc.c doesn't require it. */ and the bundled gmalloc.c doesn't require it. */
pthread_mutex_init (&alloc_mutex, NULL); pthread_mutex_init (&alloc_mutex, NULL);
#endif /* !DOUG_LEA_MALLOC */ #endif /* !DOUG_LEA_MALLOC */
#endif /* HAVE_GTK_AND_PTHREAD */ #endif /* HAVE_PTHREAD */
if (__free_hook != emacs_blocked_free) if (__free_hook != emacs_blocked_free)
old_free_hook = __free_hook; old_free_hook = __free_hook;
......
...@@ -1120,7 +1120,7 @@ Using an Emacs configured with --with-x-toolkit=lucid does not have this problem ...@@ -1120,7 +1120,7 @@ Using an Emacs configured with --with-x-toolkit=lucid does not have this problem
#if defined (USG5) && defined (INTERRUPT_INPUT) #if defined (USG5) && defined (INTERRUPT_INPUT)
setpgrp (); setpgrp ();
#endif #endif
#if defined (HAVE_GTK_AND_PTHREAD) && !defined (SYSTEM_MALLOC) && !defined (DOUG_LEA_MALLOC) #if defined (HAVE_PTHREAD) && !defined (SYSTEM_MALLOC) && !defined (DOUG_LEA_MALLOC)
{ {
extern void malloc_enable_thread (void); extern void malloc_enable_thread (void);
...@@ -2185,7 +2185,7 @@ You must run Emacs in batch mode in order to dump it. */) ...@@ -2185,7 +2185,7 @@ You must run Emacs in batch mode in order to dump it. */)
memory_warnings (my_edata, malloc_warning); memory_warnings (my_edata, malloc_warning);
} }
#endif /* not WINDOWSNT */ #endif /* not WINDOWSNT */
#if defined (HAVE_GTK_AND_PTHREAD) && !defined SYNC_INPUT #if defined (HAVE_PTHREAD) && !defined SYNC_INPUT
/* Pthread may call malloc before main, and then we will get an endless /* Pthread may call malloc before main, and then we will get an endless
loop, because pthread_self (see alloc.c) calls malloc the first time loop, because pthread_self (see alloc.c) calls malloc the first time
it is called on some systems. */ it is called on some systems. */
......
...@@ -37,7 +37,7 @@ Fifth Floor, Boston, MA 02110-1301, USA. ...@@ -37,7 +37,7 @@ Fifth Floor, Boston, MA 02110-1301, USA.
#include <config.h> #include <config.h>
#endif #endif
#ifdef HAVE_GTK_AND_PTHREAD #ifdef HAVE_PTHREAD
#define USE_PTHREAD #define USE_PTHREAD
#endif #endif
......
...@@ -1907,12 +1907,12 @@ xg_get_file_name (FRAME_PTR f, ...@@ -1907,12 +1907,12 @@ xg_get_file_name (FRAME_PTR f,
int filesel_done = 0; int filesel_done = 0;
xg_get_file_func func; xg_get_file_func func;
#if defined (HAVE_GTK_AND_PTHREAD) && defined (__SIGRTMIN) #if defined (HAVE_PTHREAD) && defined (__SIGRTMIN)
/* I really don't know why this is needed, but without this the GLIBC add on /* I really don't know why this is needed, but without this the GLIBC add on
library linuxthreads hangs when the Gnome file chooser backend creates library linuxthreads hangs when the Gnome file chooser backend creates
threads. */ threads. */
sigblock (sigmask (__SIGRTMIN)); sigblock (sigmask (__SIGRTMIN));
#endif /* HAVE_GTK_AND_PTHREAD */ #endif /* HAVE_PTHREAD */
#ifdef HAVE_GTK_FILE_SELECTION_NEW #ifdef HAVE_GTK_FILE_SELECTION_NEW
...@@ -1932,7 +1932,7 @@ xg_get_file_name (FRAME_PTR f, ...@@ -1932,7 +1932,7 @@ xg_get_file_name (FRAME_PTR f,
filesel_done = xg_dialog_run (f, w); filesel_done = xg_dialog_run (f, w);
#if defined (HAVE_GTK_AND_PTHREAD) && defined (__SIGRTMIN) #if defined (HAVE_PTHREAD) && defined (__SIGRTMIN)
sigunblock (sigmask (__SIGRTMIN)); sigunblock (sigmask (__SIGRTMIN));
#endif #endif
...@@ -1960,9 +1960,9 @@ xg_get_font_name (FRAME_PTR f, const char *default_name) ...@@ -1960,9 +1960,9 @@ xg_get_font_name (FRAME_PTR f, const char *default_name)
char *fontname = NULL; char *fontname = NULL;
int done = 0; int done = 0;
#if defined (HAVE_GTK_AND_PTHREAD) && defined (__SIGRTMIN) #if defined (HAVE_PTHREAD) && defined (__SIGRTMIN)
sigblock (sigmask (__SIGRTMIN)); sigblock (sigmask (__SIGRTMIN));
#endif /* HAVE_GTK_AND_PTHREAD */ #endif /* HAVE_PTHREAD */
w = gtk_font_selection_dialog_new ("Pick a font"); w = gtk_font_selection_dialog_new ("Pick a font");
if (!default_name) if (!default_name)
...@@ -1974,7 +1974,7 @@ xg_get_font_name (FRAME_PTR f, const char *default_name) ...@@ -1974,7 +1974,7 @@ xg_get_font_name (FRAME_PTR f, const char *default_name)
done = xg_dialog_run (f, w); done = xg_dialog_run (f, w);
#if defined (HAVE_GTK_AND_PTHREAD) && defined (__SIGRTMIN) #if defined (HAVE_PTHREAD) && defined (__SIGRTMIN)
sigunblock (sigmask (__SIGRTMIN)); sigunblock (sigmask (__SIGRTMIN));
#endif #endif
......
...@@ -44,7 +44,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ ...@@ -44,7 +44,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#include "process.h" #include "process.h"
#include <errno.h> #include <errno.h>
#ifdef HAVE_GTK_AND_PTHREAD #ifdef HAVE_PTHREAD
#include <pthread.h> #include <pthread.h>
#endif #endif
#ifdef MSDOS #ifdef MSDOS
......
...@@ -18,7 +18,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ ...@@ -18,7 +18,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
extern void init_signals (void); extern void init_signals (void);
#if defined (HAVE_GTK_AND_PTHREAD) || defined (HAVE_NS) #ifdef HAVE_PTHREAD
#include <pthread.h> #include <pthread.h>
/* If defined, asynchronous signals delivered to a non-main thread are /* If defined, asynchronous signals delivered to a non-main thread are
forwarded to the main thread. */ forwarded to the main thread. */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment