summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile.in1
-rwxr-xr-xconfigure64
-rw-r--r--configure.ac11
-rw-r--r--include/Makefile.in1
-rw-r--r--include/lcms2.h5
-rw-r--r--src/Makefile.in1
-rw-r--r--src/cmserr.c119
-rw-r--r--src/cmsio0.c5
-rw-r--r--testbed/Makefile.in1
-rw-r--r--utils/jpgicc/Makefile.in1
-rw-r--r--utils/linkicc/Makefile.in1
-rw-r--r--utils/psicc/Makefile.in1
-rw-r--r--utils/tificc/Makefile.in1
-rw-r--r--utils/transicc/Makefile.in1
14 files changed, 206 insertions, 7 deletions
diff --git a/Makefile.in b/Makefile.in
index b97d38e..b2a78e5 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -208,6 +208,7 @@ LIBTOOL = @LIBTOOL@
LIBTOOL_DEPS = @LIBTOOL_DEPS@
LIB_JPEG = @LIB_JPEG@
LIB_MATH = @LIB_MATH@
+LIB_PTHREAD = @LIB_PTHREAD@
LIB_TIFF = @LIB_TIFF@
LIB_ZLIB = @LIB_ZLIB@
LIPO = @LIPO@
diff --git a/configure b/configure
index e9218e9..338a72d 100755
--- a/configure
+++ b/configure
@@ -644,6 +644,7 @@ HasZLIB_TRUE
LIB_JPEG
HasJPEG_FALSE
HasJPEG_TRUE
+LIB_PTHREAD
LIB_MATH
inline
MAINT
@@ -15979,6 +15980,67 @@ LIBS="$LIB_MATH $LIBS"
#
+# Find pthread library
+#
+LIB_PTHREAD=''
+for ac_header in pthread.h
+do :
+ ac_fn_c_check_header_mongrel "$LINENO" "pthread.h" "ac_cv_header_pthread_h" "$ac_includes_default"
+if test "x$ac_cv_header_pthread_h" = xyes; then :
+ cat >>confdefs.h <<_ACEOF
+#define HAVE_PTHREAD_H 1
+_ACEOF
+
+else
+ as_fn_error $? "pthread.h required" "$LINENO" 5
+fi
+
+done
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for pthread_create in -lpthread" >&5
+$as_echo_n "checking for pthread_create in -lpthread... " >&6; }
+if ${ac_cv_lib_pthread_pthread_create+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ ac_check_lib_save_LIBS=$LIBS
+LIBS="-lpthread $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+/* Override any GCC internal prototype to avoid an error.
+ Use char because int might match the return type of a GCC
+ builtin and then its argument prototype would still apply. */
+#ifdef __cplusplus
+extern "C"
+#endif
+char pthread_create ();
+int
+main ()
+{
+return pthread_create ();
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+ ac_cv_lib_pthread_pthread_create=yes
+else
+ ac_cv_lib_pthread_pthread_create=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_pthread_pthread_create" >&5
+$as_echo "$ac_cv_lib_pthread_pthread_create" >&6; }
+if test "x$ac_cv_lib_pthread_pthread_create" = xyes; then :
+ LIB_PTHREAD="-lpthread"
+fi
+
+LIBS="$LIB_PTHREAD $LIBS"
+
+
+#
# Check for JPEG
#
have_jpeg='no'
@@ -16662,7 +16724,7 @@ fi
# Libraries that the LCMS library depends on
-LCMS_LIB_DEPLIBS="$LIB_MATH"
+LCMS_LIB_DEPLIBS="$LIB_MATH $LIB_PTHREAD"
LCMS_LIB_DEPLIBS=`echo $LCMS_LIB_DEPLIBS | sed -e 's/ */ /g'`
diff --git a/configure.ac b/configure.ac
index 777a962..70efb9e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -134,6 +134,15 @@ LIBS="$LIB_MATH $LIBS"
AC_SUBST(LIB_MATH)
#
+# Find pthread library
+#
+LIB_PTHREAD=''
+AC_CHECK_HEADERS(pthread.h,, [AC_MSG_ERROR([pthread.h required])])
+AC_CHECK_LIB(pthread,pthread_create,LIB_PTHREAD="-lpthread",,)
+LIBS="$LIB_PTHREAD $LIBS"
+AC_SUBST(LIB_PTHREAD)
+
+#
# Check for JPEG
#
have_jpeg='no'
@@ -277,7 +286,7 @@ AM_CONDITIONAL(HasTIFF, test "$have_tiff" = 'yes')
AC_SUBST(LIB_TIFF)
# Libraries that the LCMS library depends on
-LCMS_LIB_DEPLIBS="$LIB_MATH"
+LCMS_LIB_DEPLIBS="$LIB_MATH $LIB_PTHREAD"
LCMS_LIB_DEPLIBS=`echo $LCMS_LIB_DEPLIBS | sed -e 's/ */ /g'`
AC_SUBST(LCMS_LIB_DEPLIBS)
diff --git a/include/Makefile.in b/include/Makefile.in
index 741f30c..7874c99 100644
--- a/include/Makefile.in
+++ b/include/Makefile.in
@@ -152,6 +152,7 @@ LIBTOOL = @LIBTOOL@
LIBTOOL_DEPS = @LIBTOOL_DEPS@
LIB_JPEG = @LIB_JPEG@
LIB_MATH = @LIB_MATH@
+LIB_PTHREAD = @LIB_PTHREAD@
LIB_TIFF = @LIB_TIFF@
LIB_ZLIB = @LIB_ZLIB@
LIPO = @LIPO@
diff --git a/include/lcms2.h b/include/lcms2.h
index 5295890..c595506 100644
--- a/include/lcms2.h
+++ b/include/lcms2.h
@@ -23,7 +23,7 @@
//
//---------------------------------------------------------------------------------
//
-// Version 2.6rc1
+// Version 2.6rc2
//
#ifndef _lcms2_H
@@ -55,6 +55,9 @@
// Uncomment to get rid of the tables for "half" float support
// #define CMS_NO_HALF_SUPPORT 1
+// Uncomment to get rif of pthreads/windows dependency
+// #define CMS_NO_PTHREADS 1
+
// ********** End of configuration toggles ******************************
// Needed for streams
diff --git a/src/Makefile.in b/src/Makefile.in
index 158fc01..69887c2 100644
--- a/src/Makefile.in
+++ b/src/Makefile.in
@@ -175,6 +175,7 @@ LIBTOOL = @LIBTOOL@
LIBTOOL_DEPS = @LIBTOOL_DEPS@
LIB_JPEG = @LIB_JPEG@
LIB_MATH = @LIB_MATH@
+LIB_PTHREAD = @LIB_PTHREAD@
LIB_TIFF = @LIB_TIFF@
LIB_ZLIB = @LIB_ZLIB@
LIPO = @LIPO@
diff --git a/src/cmserr.c b/src/cmserr.c
index 4bfc0a7..ba0a07e 100644
--- a/src/cmserr.c
+++ b/src/cmserr.c
@@ -532,14 +532,125 @@ void _cmsTagSignature2String(char String[5], cmsTagSignature sig)
//--------------------------------------------------------------------------------------------------
+#ifndef CMS_NO_PTHREADS
+
+#ifdef CMS_IS_WINDOWS_
+
+// Windows funtions
+#define WIN32_LEAN_AND_MEAN 1
+#include <Windows.h>
+
+static
+void* defMtxCreate(cmsContext id)
+{
+ cmsUNUSED_PARAMETER(id);
+ return (void*) CreateMutex( NULL, FALSE, NULL);
+}
+
+static
+void defMtxDestroy(cmsContext id, void* mtx)
+{
+ cmsUNUSED_PARAMETER(id);
+ CloseHandle((HANDLE) mtx);
+}
+
+static
+cmsBool defMtxLock(cmsContext id, void* mtx)
+{
+ cmsUNUSED_PARAMETER(id);
+ WaitForSingleObject((HANDLE) mtx, INFINITE);
+ return TRUE;
+}
+
+static
+void defMtxUnlock(cmsContext id, void* mtx)
+{
+ cmsUNUSED_PARAMETER(id);
+ ReleaseMutex((HANDLE) mtx);
+}
+
+#else
+
+// Rest of the wide world
+#include <pthread.h>
+
+static
+void* defMtxCreate(cmsContext id)
+{
+ pthread_mutex_t* ptr_mutex = _cmsMalloc(id, sizeof(pthread_mutex_t));
+
+ *ptr_mutex = PTHREAD_MUTEX_INITIALIZER;
+ if (pthread_mutex_init(ptr_mutex, NULL) != 0) {
+ return NULL;
+ }
+
+ return (void*) ptr_mutex;
+}
+
+static
+void defMtxDestroy(cmsContext id, void* mtx)
+{
+ pthread_mutex_destroy((pthread_mutex_t *) mtx);
+ _cmsFree(id, mtx);
+}
+
+static
+cmsBool defMtxLock(cmsContext id, void* mtx)
+{
+ cmsUNUSED_PARAMETER(id);
+ return pthread_mutex_lock((pthread_mutex_t *) mtx) == 0;
+}
+
+static
+void defMtxUnlock(cmsContext id, void* mtx)
+{
+ cmsUNUSED_PARAMETER(id);
+ pthread_mutex_unlock((pthread_mutex_t *) mtx);
+}
+
+#endif
+#else
+
+// Multithreading locking is disabled
+static
+void* defMtxCreate(cmsContext id)
+{
+ return NULL;
+}
+
+static
+void defMtxDestroy(cmsContext id, void* mtx)
+{
+ cmsUNUSED_PARAMETER(id);
+ cmsUNUSED_PARAMETER(mtx);
+}
+
+static
+cmsBool defMtxLock(cmsContext id, void* mtx)
+{
+ cmsUNUSED_PARAMETER(id);
+ cmsUNUSED_PARAMETER(mtx);
+
+ return TRUE;
+}
+
+static
+void defMtxUnlock(cmsContext id, void* mtx)
+{
+ cmsUNUSED_PARAMETER(id);
+ cmsUNUSED_PARAMETER(mtx);
+}
+
+#endif
+
// Pointers to memory manager functions in Context0
-_cmsMutexPluginChunkType _cmsMutexPluginChunk = { NULL, NULL, NULL, NULL };
+_cmsMutexPluginChunkType _cmsMutexPluginChunk = { defMtxCreate, defMtxDestroy, defMtxLock, defMtxUnlock };
// Allocate and init mutex container.
void _cmsAllocMutexPluginChunk(struct _cmsContext_struct* ctx,
const struct _cmsContext_struct* src)
{
- static _cmsMutexPluginChunkType MutexChunk = { NULL, NULL, NULL, NULL };
+ static _cmsMutexPluginChunkType MutexChunk = {defMtxCreate, defMtxDestroy, defMtxLock, defMtxUnlock };
void* from;
if (src != NULL) {
@@ -573,9 +684,9 @@ cmsBool _cmsRegisterMutexPlugin(cmsContext ContextID, cmsPluginBase* Data)
Plugin ->LockMutexPtr == NULL || Plugin ->UnlockMutexPtr == NULL) return FALSE;
- ctx->CreateMutexPtr = Plugin->CreateMutexPtr;
+ ctx->CreateMutexPtr = Plugin->CreateMutexPtr;
ctx->DestroyMutexPtr = Plugin ->DestroyMutexPtr;
- ctx ->LockMutexPtr = Plugin ->LockMutexPtr;
+ ctx ->LockMutexPtr = Plugin ->LockMutexPtr;
ctx ->UnlockMutexPtr = Plugin ->UnlockMutexPtr;
// All is ok
diff --git a/src/cmsio0.c b/src/cmsio0.c
index 0bb156f..4449acd 100644
--- a/src/cmsio0.c
+++ b/src/cmsio0.c
@@ -1709,6 +1709,7 @@ cmsInt32Number CMSEXPORT cmsReadRawTag(cmsHPROFILE hProfile, cmsTagSignature sig
if (!Icc ->IOhandler ->Seek(Icc ->IOhandler, Offset)) goto Error;
if (!Icc ->IOhandler ->Read(Icc ->IOhandler, data, 1, TagSize)) goto Error;
+ _cmsUnlockMutex(Icc->ContextID, Icc ->UsrMutex);
return TagSize;
}
@@ -1738,7 +1739,11 @@ cmsInt32Number CMSEXPORT cmsReadRawTag(cmsHPROFILE hProfile, cmsTagSignature sig
// Already readed, or previously set by cmsWriteTag(). We need to serialize that
// data to raw in order to maintain consistency.
+
+ _cmsUnlockMutex(Icc->ContextID, Icc ->UsrMutex);
Object = cmsReadTag(hProfile, sig);
+ if (!_cmsLockMutex(Icc->ContextID, Icc ->UsrMutex)) return 0;
+
if (Object == NULL) goto Error;
// Now we need to serialize to a memory block: just use a memory iohandler
diff --git a/testbed/Makefile.in b/testbed/Makefile.in
index 8c0f64c..c88cf3e 100644
--- a/testbed/Makefile.in
+++ b/testbed/Makefile.in
@@ -142,6 +142,7 @@ LIBTOOL = @LIBTOOL@
LIBTOOL_DEPS = @LIBTOOL_DEPS@
LIB_JPEG = @LIB_JPEG@
LIB_MATH = @LIB_MATH@
+LIB_PTHREAD = @LIB_PTHREAD@
LIB_TIFF = @LIB_TIFF@
LIB_ZLIB = @LIB_ZLIB@
LIPO = @LIPO@
diff --git a/utils/jpgicc/Makefile.in b/utils/jpgicc/Makefile.in
index 11fe27b..bac463d 100644
--- a/utils/jpgicc/Makefile.in
+++ b/utils/jpgicc/Makefile.in
@@ -176,6 +176,7 @@ LIBTOOL = @LIBTOOL@
LIBTOOL_DEPS = @LIBTOOL_DEPS@
LIB_JPEG = @LIB_JPEG@
LIB_MATH = @LIB_MATH@
+LIB_PTHREAD = @LIB_PTHREAD@
LIB_TIFF = @LIB_TIFF@
LIB_ZLIB = @LIB_ZLIB@
LIPO = @LIPO@
diff --git a/utils/linkicc/Makefile.in b/utils/linkicc/Makefile.in
index 86433a7..7076552 100644
--- a/utils/linkicc/Makefile.in
+++ b/utils/linkicc/Makefile.in
@@ -146,6 +146,7 @@ LIBTOOL = @LIBTOOL@
LIBTOOL_DEPS = @LIBTOOL_DEPS@
LIB_JPEG = @LIB_JPEG@
LIB_MATH = @LIB_MATH@
+LIB_PTHREAD = @LIB_PTHREAD@
LIB_TIFF = @LIB_TIFF@
LIB_ZLIB = @LIB_ZLIB@
LIPO = @LIPO@
diff --git a/utils/psicc/Makefile.in b/utils/psicc/Makefile.in
index f67cfcd..b750097 100644
--- a/utils/psicc/Makefile.in
+++ b/utils/psicc/Makefile.in
@@ -145,6 +145,7 @@ LIBTOOL = @LIBTOOL@
LIBTOOL_DEPS = @LIBTOOL_DEPS@
LIB_JPEG = @LIB_JPEG@
LIB_MATH = @LIB_MATH@
+LIB_PTHREAD = @LIB_PTHREAD@
LIB_TIFF = @LIB_TIFF@
LIB_ZLIB = @LIB_ZLIB@
LIPO = @LIPO@
diff --git a/utils/tificc/Makefile.in b/utils/tificc/Makefile.in
index 4e33298..b01ef0c 100644
--- a/utils/tificc/Makefile.in
+++ b/utils/tificc/Makefile.in
@@ -175,6 +175,7 @@ LIBTOOL = @LIBTOOL@
LIBTOOL_DEPS = @LIBTOOL_DEPS@
LIB_JPEG = @LIB_JPEG@
LIB_MATH = @LIB_MATH@
+LIB_PTHREAD = @LIB_PTHREAD@
LIB_TIFF = @LIB_TIFF@
LIB_ZLIB = @LIB_ZLIB@
LIPO = @LIPO@
diff --git a/utils/transicc/Makefile.in b/utils/transicc/Makefile.in
index 55cbcd6..594b215 100644
--- a/utils/transicc/Makefile.in
+++ b/utils/transicc/Makefile.in
@@ -146,6 +146,7 @@ LIBTOOL = @LIBTOOL@
LIBTOOL_DEPS = @LIBTOOL_DEPS@
LIB_JPEG = @LIB_JPEG@
LIB_MATH = @LIB_MATH@
+LIB_PTHREAD = @LIB_PTHREAD@
LIB_TIFF = @LIB_TIFF@
LIB_ZLIB = @LIB_ZLIB@
LIPO = @LIPO@