Commit 9511753a authored by Sven Neumann's avatar Sven Neumann Committed by Sven Neumann

check for gthread-2.0 unless the --disable-mp option is given.

2005-02-13  Sven Neumann  <sven@gimp.org>

	* configure.in: check for gthread-2.0 unless the --disable-mp
	option is given.

	* app/app_procs.c (app_libs_init): call g_thread_init().

	* app/base/pixel-processor.c: ported to GThread.

	* app/Makefile.am
	* app/*/Makefile.am: use @GTHREAD_CFLAGS@.
parent ccb2441a
2005-02-13 Sven Neumann <sven@gimp.org>
* configure.in: check for gthread-2.0 unless the --disable-mp
option is given.
* app/app_procs.c (app_libs_init): call g_thread_init().
* app/base/pixel-processor.c: ported to GThread.
* app/Makefile.am
* app/*/Makefile.am: use @GTHREAD_CFLAGS@.
2005-02-13 Sven Neumann <sven@gimp.org>
* libgimp/gimpprogress.c (gimp_progress_install): fixed typos in
......
......@@ -8,6 +8,7 @@ libgimpmodule = $(top_builddir)/libgimpmodule/libgimpmodule-$(GIMP_API_VERSION).
libgimpwidgets = $(top_builddir)/libgimpwidgets/libgimpwidgets-$(GIMP_API_VERSION).la
libgimpthumb = $(top_builddir)/libgimpthumb/libgimpthumb-$(GIMP_API_VERSION).la
SUBDIRS = \
paint-funcs \
composite \
......@@ -78,8 +79,7 @@ endif
AM_CPPFLAGS = \
-DG_LOG_DOMAIN=\"Gimp\" \
-DGIMP_APP_GLUE_COMPILATION \
@GIMP_THREAD_FLAGS@ \
@GIMP_MP_FLAGS@
@GTHREAD_CFLAGS@
INCLUDES = \
-I$(top_srcdir) \
......@@ -122,8 +122,7 @@ gimp_2_3_LDADD = \
$(PANGOFT2_LIBS) \
$(FONTCONFIG_LIBS) \
$(FREETYPE_LIBS) \
$(GIMP_THREAD_LIBS) \
$(GIMP_MP_LIBS) \
$(GTHREAD_LIBS) \
$(RT_LIBS) \
$(INTLLIBS) \
$(GIMPICONRC)
......@@ -167,8 +166,7 @@ gimp_console_2_3_LDADD = \
$(PANGOFT2_LIBS) \
$(FONTCONFIG_LIBS) \
$(FREETYPE_LIBS) \
$(GIMP_THREAD_LIBS) \
$(GIMP_MP_LIBS) \
$(GTHREAD_LIBS) \
$(RT_LIBS) \
$(INTLLIBS) \
$(GIMPICONRC)
......
......@@ -146,8 +146,7 @@ EXTRA_DIST = \
AM_CPPFLAGS = \
-DG_LOG_DOMAIN=\"Gimp-Actions\" \
@GIMP_THREAD_FLAGS@ \
@GIMP_MP_FLAGS@
@GTHREAD_CFLAGS@
INCLUDES = \
-I$(top_builddir) \
......
......@@ -79,6 +79,10 @@ void
app_libs_init (GOptionContext *context,
gboolean no_interface)
{
#ifdef ENABLE_MP
g_thread_init (NULL);
#endif
if (no_interface)
{
g_type_init ();
......
......@@ -55,8 +55,7 @@ libappbase_a_SOURCES = \
AM_CPPFLAGS = \
-DG_LOG_DOMAIN=\"Gimp-Base\" \
@GIMP_THREAD_FLAGS@ \
@GIMP_MP_FLAGS@
@GTHREAD_CFLAGS@
AM_CCASFLAGS = \
-I$(top_builddir) \
......
......@@ -22,7 +22,6 @@
#ifdef ENABLE_MP
#include <string.h>
#include <pthread.h>
#endif
#include <glib-object.h>
......@@ -69,8 +68,8 @@ struct _PixelProcessor
PixelRegionIterator *PRI;
#ifdef ENABLE_MP
pthread_mutex_t mutex;
gint nthreads;
GMutex *mutex;
gint num_threads;
#endif
gint num_regions;
......@@ -79,25 +78,25 @@ struct _PixelProcessor
#ifdef ENABLE_MP
static void *
static void
do_parallel_regions (PixelProcessor *processor)
{
PixelRegion tr[4];
gint n_tiles = 0;
gint i;
pthread_mutex_lock (&processor->mutex);
g_mutex_lock (processor->mutex);
if (processor->nthreads != 0 && processor->PRI)
if (processor->num_threads != 0 && processor->PRI)
processor->PRI = pixel_regions_process (processor->PRI);
if (processor->PRI == NULL)
{
pthread_mutex_unlock (&processor->mutex);
return NULL;
g_mutex_unlock (processor->mutex);
return;
}
processor->nthreads++;
processor->num_threads++;
do
{
......@@ -109,7 +108,7 @@ do_parallel_regions (PixelProcessor *processor)
tile_lock (tr[i].curtile);
}
pthread_mutex_unlock (&processor->mutex);
g_mutex_unlock (processor->mutex);
n_tiles++;
switch(processor->num_regions)
......@@ -146,7 +145,7 @@ do_parallel_regions (PixelProcessor *processor)
break;
}
pthread_mutex_lock (&processor->mutex);
g_mutex_lock (processor->mutex);
for (i = 0; i < processor->num_regions; i++)
if (processor->regions[i])
......@@ -159,19 +158,17 @@ do_parallel_regions (PixelProcessor *processor)
while (processor->PRI &&
(processor->PRI = pixel_regions_process (processor->PRI)));
processor->nthreads--;
processor->num_threads--;
pthread_mutex_unlock (&processor->mutex);
return NULL;
g_mutex_unlock (processor->mutex);
}
#endif
/* do_parallel_regions_single is just like do_parallel_regions
* except that all the mutex and tile locks have been removed
*
* If we are processing with only a single thread we don't need to do the
* mutex locks etc. and aditional tile locks even if we were
* If we are processing with only a single thread we don't need to do
* the mutex locks etc. and aditional tile locks even if we were
* configured --with-mp
*/
......@@ -220,7 +217,7 @@ do_parallel_regions_single (PixelProcessor *processor)
return NULL;
}
#define MAX_THREADS 30
#define MAX_THREADS 16
static void
pixel_regions_do_parallel (PixelProcessor *processor)
......@@ -235,29 +232,29 @@ pixel_regions_do_parallel (PixelProcessor *processor)
if (nthreads > 1)
{
GThread *threads[MAX_THREADS];
gint i;
pthread_t threads[MAX_THREADS];
pthread_attr_t pthread_attr;
pthread_attr_init (&pthread_attr);
for (i = 0; i < nthreads; i++)
{
pthread_create (&threads[i], &pthread_attr,
(void *(*)(void *)) do_parallel_regions,
processor);
GError *error = NULL;
threads[i] = g_thread_create ((GThreadFunc) do_parallel_regions,
processor,
TRUE, &error);
if (! threads[i])
{
g_warning ("cannot create thread: %s\n", error->message);
g_clear_error (&error);
}
}
for (i = 0; i < nthreads; i++)
{
gint ret = pthread_join (threads[i], NULL);
if (ret)
g_printerr ("pixel_regions_do_parallel: "
"pthread_join returned: %d\n", ret);
g_thread_join (threads[i]);
}
if (processor->nthreads != 0)
if (processor->num_threads != 0)
g_printerr ("pixel_regions_do_prarallel: we lost a thread\n");
}
else
......@@ -322,14 +319,14 @@ pixel_regions_process_parallel_valist (PixelProcessorFunc func,
processor.num_regions = num_regions;
#ifdef ENABLE_MP
pthread_mutex_init (&processor.mutex, NULL);
processor.nthreads = 0;
processor.mutex = g_mutex_new ();
processor.num_threads = 0;
#endif
pixel_regions_do_parallel (&processor);
#ifdef ENABLE_MP
pthread_mutex_destroy (&processor.mutex);
g_mutex_free (processor.mutex);
#endif
}
......
......@@ -4,8 +4,7 @@ libgimpcolor = $(top_builddir)/libgimpcolor/libgimpcolor-$(GIMP_API_VERSION).la
AM_CPPFLAGS = \
-DG_LOG_DOMAIN=\"Gimp-Composite\" \
@GIMP_THREAD_FLAGS@ \
@GIMP_MP_FLAGS@
@GTHREAD_CFLAGS@
AM_CCASFLAGS = \
-I$(top_builddir) \
......
......@@ -38,8 +38,7 @@ libappconfig_a_SOURCES = \
AM_CPPFLAGS = \
-DG_LOG_DOMAIN=\"Gimp-Config\" \
@GIMP_THREAD_FLAGS@ \
@GIMP_MP_FLAGS@
@GTHREAD_CFLAGS@
INCLUDES = \
-I$(top_srcdir) \
......
......@@ -3,8 +3,7 @@
AM_CPPFLAGS = \
-DG_LOG_DOMAIN=\"Gimp-Core\" \
-DGIMP_COMPILATION \
@GIMP_THREAD_FLAGS@ \
@GIMP_MP_FLAGS@
@GTHREAD_CFLAGS@
INCLUDES = \
-I$(top_srcdir) \
......
......@@ -2,8 +2,7 @@
AM_CPPFLAGS = \
-DG_LOG_DOMAIN=\"Gimp-Dialogs\" \
@GIMP_THREAD_FLAGS@ \
@GIMP_MP_FLAGS@
@GTHREAD_CFLAGS@
INCLUDES = \
-I$(top_builddir) \
......
## Process this file with automake to produce Makefile.in
AM_CPPFLAGS = \
-DG_LOG_DOMAIN=\"Gimp-Display\" \
@GIMP_THREAD_FLAGS@ \
@GIMP_MP_FLAGS@
INCLUDES = \
-I$(top_srcdir) \
-I$(top_srcdir)/app \
$(GTK_CFLAGS) \
-I$(includedir)
noinst_LIBRARIES = libappdisplay.a
libappdisplay_a_sources = \
......@@ -79,6 +68,16 @@ libappdisplay_a_SOURCES = \
$(libappdisplay_a_built_sources) \
$(libappdisplay_a_sources)
AM_CPPFLAGS = \
-DG_LOG_DOMAIN=\"Gimp-Display\" \
@GTHREAD_CFLAGS@
INCLUDES = \
-I$(top_srcdir) \
-I$(top_srcdir)/app \
$(GTK_CFLAGS) \
-I$(includedir)
EXTRA_DIST = makefile.msc
#
......
......@@ -16,8 +16,7 @@ libappfile_a_SOURCES = \
AM_CPPFLAGS = \
-DG_LOG_DOMAIN=\"Gimp-File\" \
@GIMP_THREAD_FLAGS@ \
@GIMP_MP_FLAGS@
@GTHREAD_CFLAGS@
INCLUDES = \
-I$(top_srcdir) \
......
## Process this file with automake to produce Makefile.in
AM_CPPFLAGS = \
-DG_LOG_DOMAIN=\"Gimp-GUI\" \
@GTHREAD_CFLAGS@
INCLUDES = \
-I$(top_builddir) \
-I$(top_srcdir) \
-I$(top_builddir)/app \
-I$(top_srcdir)/app \
$(GTK_CFLAGS) \
-I$(includedir)
noinst_LIBRARIES = libappgui.a
libappgui_a_SOURCES = \
......@@ -18,16 +30,3 @@ libappgui_a_SOURCES = \
themes.h
EXTRA_DIST = makefile.msc
AM_CPPFLAGS = \
-DG_LOG_DOMAIN=\"Gimp-GUI\" \
@GIMP_THREAD_FLAGS@ \
@GIMP_MP_FLAGS@
INCLUDES = \
-I$(top_builddir) \
-I$(top_srcdir) \
-I$(top_builddir)/app \
-I$(top_srcdir)/app \
$(GTK_CFLAGS) \
-I$(includedir)
......@@ -27,8 +27,7 @@ EXTRA_DIST = \
AM_CPPFLAGS = \
-DG_LOG_DOMAIN=\"Gimp-Menus\" \
@GIMP_THREAD_FLAGS@ \
@GIMP_MP_FLAGS@
@GTHREAD_CFLAGS@
INCLUDES = \
-I$(top_builddir) \
......
......@@ -18,8 +18,7 @@ INCLUDES = \
AM_CPPFLAGS = \
-DG_LOG_DOMAIN=\"Gimp-Paint-Funcs\" \
@GIMP_THREAD_FLAGS@ \
@GIMP_MP_FLAGS@
@GTHREAD_CFLAGS@
AM_CCASFLAGS = \
-I$(top_builddir) \
......
......@@ -2,8 +2,7 @@
AM_CPPFLAGS = \
-DG_LOG_DOMAIN=\"Gimp-Paint\" \
@GIMP_THREAD_FLAGS@ \
@GIMP_MP_FLAGS@
@GTHREAD_CFLAGS@
INCLUDES = \
-I$(top_builddir) \
......
......@@ -56,8 +56,7 @@ libapppdb_a_SOURCES = \
AM_CPPFLAGS = \
-DG_LOG_DOMAIN=\"Gimp-PDB\" \
@GIMP_THREAD_FLAGS@ \
@GIMP_MP_FLAGS@
@GTHREAD_CFLAGS@
INCLUDES = \
-I$(top_srcdir) \
......
......@@ -2,8 +2,7 @@
AM_CPPFLAGS = \
-DG_LOG_DOMAIN=\"Gimp-Plug-In\" \
@GIMP_THREAD_FLAGS@ \
@GIMP_MP_FLAGS@
@GTHREAD_CFLAGS@
INCLUDES = \
-I$(top_srcdir) \
......
......@@ -2,8 +2,7 @@
AM_CPPFLAGS = \
-DG_LOG_DOMAIN=\"Gimp-Text\" \
@GIMP_THREAD_FLAGS@ \
@GIMP_MP_FLAGS@
@GTHREAD_CFLAGS@
INCLUDES = \
-I$(top_srcdir) \
......
......@@ -152,8 +152,7 @@ libapptools_a_SOURCES = $(libapptools_a_built_sources) $(libapptools_a_sources)
AM_CPPFLAGS = \
-DG_LOG_DOMAIN=\"Gimp-Tools\" \
@GIMP_THREAD_FLAGS@ \
@GIMP_MP_FLAGS@
@GTHREAD_CFLAGS@
INCLUDES = \
-I$(top_srcdir) \
......
......@@ -2,8 +2,7 @@
AM_CPPFLAGS = \
-DG_LOG_DOMAIN=\"Gimp-Vectors\" \
@GIMP_THREAD_FLAGS@ \
@GIMP_MP_FLAGS@
@GTHREAD_CFLAGS@
INCLUDES = \
-I$(top_srcdir) \
......
......@@ -2,8 +2,7 @@
AM_CPPFLAGS = \
-DG_LOG_DOMAIN=\"Gimp-Widgets\" \
@GIMP_THREAD_FLAGS@ \
@GIMP_MP_FLAGS@
@GTHREAD_CFLAGS@
INCLUDES = \
-I$(top_builddir) \
......
......@@ -19,8 +19,7 @@ libappxcf_a_SOURCES = \
AM_CPPFLAGS = \
-DG_LOG_DOMAIN=\"Gimp-XCF\" \
@GIMP_THREAD_FLAGS@ \
@GIMP_MP_FLAGS@
@GTHREAD_CFLAGS@
INCLUDES = \
-I$(top_srcdir) \
......
......@@ -814,27 +814,15 @@ dnl GIMP_THREAD_LIBS="-lpthreads"
dnl GIMP_THREAD_FLAGS="-D_REENTRANT -D_THREAD_SAFE"]))
dnl fi
AC_SUBST(GIMP_THREAD_FLAGS)
AC_SUBST(GIMP_THREAD_LIBS)
AC_ARG_ENABLE(mp, [ --enable-mp support multiple processors (default=yes)])
AC_ARG_ENABLE(mp, [ --disable-mp disable support for multiple processors])
if test "x$enable_mp" != "xno"; then
AC_CHECK_LIB(pthread, pthread_attr_init,
PKG_CHECK_MODULES(GTHREAD, gthread-2.0,
[AC_DEFINE(ENABLE_MP, 1,
[Define to 1 to enable support for multiple processors.])
GIMP_MP_LIBS="-lpthread"
GIMP_MP_FLAGS="-D_REENTRANT"],
# AIX has libpthreads, cause they're special. Special friends (TM)
AC_CHECK_LIB(pthreads, pthread_attr_init,
[AC_DEFINE(ENABLE_MP)
GIMP_MP_LIBS="-lpthreads"
GIMP_MP_FLAGS="-D_REENTRANT -D_THREAD_SAFE"]))
[Define to 1 to enable support for multiple processors.])]
)
fi
AC_SUBST(GIMP_MP_FLAGS)
AC_SUBST(GIMP_MP_LIBS)
################################
# Some plug-ins are X11 specific
......
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