You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by rl...@apache.org on 2018/03/10 21:07:56 UTC
svn commit: r1826421 - in /xerces/c/trunk: ./ cmake/ doc/ m4/ scripts/ src/
src/xercesc/util/ src/xercesc/util/MutexManagers/
Author: rleigh
Date: Sat Mar 10 21:07:56 2018
New Revision: 1826421
URL: http://svn.apache.org/viewvc?rev=1826421&view=rev
Log:
StdMutexMgr: Add C++11 mutex manager
Added:
xerces/c/trunk/m4/cxx_have_std_thread.m4
xerces/c/trunk/src/xercesc/util/MutexManagers/StdMutexMgr.cpp
xerces/c/trunk/src/xercesc/util/MutexManagers/StdMutexMgr.hpp
Modified:
xerces/c/trunk/.appveyor.yml
xerces/c/trunk/.travis.yml
xerces/c/trunk/cmake/XercesMutexMgrSelection.cmake
xerces/c/trunk/config.h.cmake.in
xerces/c/trunk/doc/build.xml
xerces/c/trunk/m4/xerces_mutexmgr_selection.m4
xerces/c/trunk/scripts/ci-travis
xerces/c/trunk/src/CMakeLists.txt
xerces/c/trunk/src/Makefile.am
xerces/c/trunk/src/xercesc/util/PlatformUtils.cpp
Modified: xerces/c/trunk/.appveyor.yml
URL: http://svn.apache.org/viewvc/xerces/c/trunk/.appveyor.yml?rev=1826421&r1=1826420&r2=1826421&view=diff
==============================================================================
--- xerces/c/trunk/.appveyor.yml (original)
+++ xerces/c/trunk/.appveyor.yml Sat Mar 10 21:07:56 2018
@@ -43,6 +43,7 @@ environment:
netaccessor: curl
msgloader: inmemory
transcoder: iconv
+ mutexmanager: posix
xmlch: uint16_t
- compiler: cygwin
configuration: Debug
@@ -52,6 +53,7 @@ environment:
netaccessor:
msgloader:
transcoder:
+ mutexmanager: standard
xmlch: char16_t
- compiler: mingw
configuration: Release
@@ -61,6 +63,7 @@ environment:
netaccessor:
msgloader:
transcoder: windows
+ mutexmanager: windows
xmlch: wchar_t
- compiler: mingw
configuration: Debug
@@ -70,6 +73,7 @@ environment:
netaccessor:
msgloader:
transcoder: iconv
+ mutexmanager:
xmlch: uint16_t
- compiler: vc14
configuration: Release
@@ -79,6 +83,7 @@ environment:
netaccessor:
msgloader: icu
transcoder: windows
+ mutexmanager: windows
xmlch: wchar_t
mfc: ON
- compiler: vc14
@@ -89,6 +94,7 @@ environment:
netaccessor: winsock
msgloader: inmemory
transcoder: icu
+ mutexmanager: standard
xmlch: char16_t
mfc: OFF
@@ -127,6 +133,7 @@ before_build:
- if NOT [%netaccessor%] == [] set "AV_CMAKE_ARGS=%AV_CMAKE_ARGS% -Dnetwork-accessor=%netaccessor%"
- if NOT [%msgloader%] == [] set "AV_CMAKE_ARGS=%AV_CMAKE_ARGS% -Dmessage-loader=%msgloader%"
- if NOT [%transcoder%] == [] set "AV_CMAKE_ARGS=%AV_CMAKE_ARGS% -Dtranscoder=%transcoder%"
+ - if NOT [%mutexmanager%] == [] set "AV_CMAKE_ARGS=%AV_CMAKE_ARGS% -Dmutex-manager=%mutexmanager%"
- if NOT [%xmlch%] == [] set "AV_CMAKE_ARGS=%AV_CMAKE_ARGS% -Dxmlch-type=%xmlch%"
- if NOT [%mfc%] == [] set "AV_CMAKE_ARGS=%AV_CMAKE_ARGS% -Dmfc-debug=%mfc%"
- set "AV_XERCES_CMAKE_SOURCE=%AV_XERCES_SOURCE%"
Modified: xerces/c/trunk/.travis.yml
URL: http://svn.apache.org/viewvc/xerces/c/trunk/.travis.yml?rev=1826421&r1=1826420&r2=1826421&view=diff
==============================================================================
--- xerces/c/trunk/.travis.yml (original)
+++ xerces/c/trunk/.travis.yml Sat Mar 10 21:07:56 2018
@@ -31,12 +31,12 @@ os:
env:
matrix:
- - BUILD=autoconf TYPE=Release NETWORK=ON NETACCESSOR=curl MSGLOADER=inmemory TRANSCODER=iconv XMLCH=char16_t
+ - BUILD=autoconf TYPE=Release MUTEXMGR=posix NETWORK=ON NETACCESSOR=curl MSGLOADER=inmemory TRANSCODER=iconv XMLCH=char16_t
- BUILD=cmake TOOL="Unix Makefiles" TYPE=Debug NETWORK=ON NETACCESSOR=curl MSGLOADER=icu TRANSCODER=iconv XMLCH=uint16_t
- - BUILD=cmake TOOL="Ninja" TYPE=Release NETWORK=ON NETACCESSOR=socket MSGLOADER=inmemory TRANSCODER=icu XMLCH=char16_t
+ - BUILD=cmake TOOL="Ninja" TYPE=Release MUTEXMGR=posix NETWORK=ON NETACCESSOR=socket MSGLOADER=inmemory TRANSCODER=icu XMLCH=char16_t
- BUILD=autoconf TYPE=Debug NETWORK=ON MSGLOADER=iconv XMLCH=uint16_t
- - BUILD=cmake TOOL="Unix Makefiles" TYPE=Release NETWORK=ON
- - BUILD=cmake TOOL="Ninja" TYPE=Debug
+ - BUILD=cmake TOOL="Unix Makefiles" MUTEXMGR=standard TYPE=Release NETWORK=ON
+ - BUILD=cmake TOOL="Ninja" TYPE=Debug MUTEXMGR=nothreads
- BUILD=cmake TOOL="Ninja" TYPE=Debug NETACCESSOR=cfurl TRANSCODER=macosunicodeconverter XMLCH=uint16_t
matrix:
@@ -47,13 +47,13 @@ matrix:
- os: osx
env: BUILD=cmake TOOL="Unix Makefiles" TYPE=Debug NETWORK=ON NETACCESSOR=curl MSGLOADER=icu TRANSCODER=iconv XMLCH=uint16_t
- os: osx
- env: BUILD=cmake TOOL="Ninja" TYPE=Release NETWORK=ON NETACCESSOR=socket MSGLOADER=inmemory TRANSCODER=icu XMLCH=char16_t
+ env: BUILD=cmake TOOL="Ninja" TYPE=Release MUTEXMGR=posix NETWORK=ON NETACCESSOR=socket MSGLOADER=inmemory TRANSCODER=icu XMLCH=char16_t
- os: osx
env: BUILD=autoconf TYPE=Debug NETWORK=ON MSGLOADER=iconv XMLCH=uint16_t
- os: osx
- env: BUILD=cmake TOOL="Unix Makefiles" TYPE=Release NETWORK=ON
+ env: BUILD=cmake TOOL="Unix Makefiles" MUTEXMGR=standard TYPE=Release NETWORK=ON
- os: osx
- env: BUILD=cmake TOOL="Ninja" TYPE=Debug
+ env: BUILD=cmake TOOL="Ninja" TYPE=Debug MUTEXMGR=nothreads
script:
- - ./scripts/ci-travis "$BUILD" "$TOOL" "$TYPE" "$NETWORK" "$NETACCESSOR" "$MSGLOADER" "$TRANSCODER" "$XMLCH"
+ - ./scripts/ci-travis "$BUILD" "$TOOL" "$TYPE" "$MUTEXMGR" "$NETWORK" "$NETACCESSOR" "$MSGLOADER" "$TRANSCODER" "$XMLCH"
Modified: xerces/c/trunk/cmake/XercesMutexMgrSelection.cmake
URL: http://svn.apache.org/viewvc/xerces/c/trunk/cmake/XercesMutexMgrSelection.cmake?rev=1826421&r1=1826420&r2=1826421&view=diff
==============================================================================
--- xerces/c/trunk/cmake/XercesMutexMgrSelection.cmake (original)
+++ xerces/c/trunk/cmake/XercesMutexMgrSelection.cmake Sat Mar 10 21:07:56 2018
@@ -21,16 +21,60 @@
option(threads "Threading support" ON)
+include(CheckCXXSourceCompiles)
+
+find_package(Threads REQUIRED)
+
+function(thread_test outvar)
+ set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})
+
+ check_cxx_source_compiles(
+"#include <thread>
+#include <mutex>
+#include <iostream>
+
+namespace
+{
+
+ std::mutex m1;
+ std::recursive_mutex m2;
+
+ void
+ threadmain()
+ {
+ std::lock_guard<std::mutex> lock1(m1);
+ std::lock_guard<std::recursive_mutex> lock2(m2);
+ std::cout << \"In thread\" << std::endl;
+ }
+
+}
+
+int main() {
+ std::thread foo(threadmain);
+ foo.join();
+
+ return 0;
+}"
+${outvar})
+
+ set(${outvar} ${${outvar}} PARENT_SCOPE)
+endfunction(thread_test)
+
if(threads)
set(THREADS_PREFER_PTHREAD_FLAG ON)
add_definitions(-D_THREAD_SAFE=1)
find_package(Threads)
+ thread_test(XERCES_HAVE_STD_THREAD)
+ if(XERCES_HAVE_STD_THREAD)
+ list(APPEND mutexmgrs standard)
+ endif()
+
if(TARGET Threads::Threads)
if(WIN32)
list(APPEND mutexmgrs windows)
else()
- list(APPEND mutexmgrs POSIX)
+ list(APPEND mutexmgrs posix)
set(HAVE_PTHREAD 1)
endif()
endif()
@@ -49,10 +93,13 @@ if(mutexmgr_found EQUAL -1)
message(FATAL_ERROR "${mutexmgr} mutexmgr unavailable")
endif()
+set(XERCES_USE_MUTEXMGR_STD 0)
set(XERCES_USE_MUTEXMGR_POSIX 0)
set(XERCES_USE_MUTEXMGR_WINDOWS 0)
set(XERCES_USE_MUTEXMGR_NOTHREAD 0)
-if(mutexmgr STREQUAL "POSIX")
+if(mutexmgr STREQUAL "standard")
+ set(XERCES_USE_MUTEXMGR_STD 1)
+elseif(mutexmgr STREQUAL "posix")
set(XERCES_USE_MUTEXMGR_POSIX 1)
elseif(mutexmgr STREQUAL "windows")
set(XERCES_USE_MUTEXMGR_WINDOWS 1)
Modified: xerces/c/trunk/config.h.cmake.in
URL: http://svn.apache.org/viewvc/xerces/c/trunk/config.h.cmake.in?rev=1826421&r1=1826420&r2=1826421&view=diff
==============================================================================
--- xerces/c/trunk/config.h.cmake.in (original)
+++ xerces/c/trunk/config.h.cmake.in Sat Mar 10 21:07:56 2018
@@ -448,6 +448,9 @@
/* Define to use the NoThread mutex mgr */
#cmakedefine XERCES_USE_MUTEXMGR_NOTHREAD 1
+/* Define to use the C++11 standard mutex mgr */
+#cmakedefine XERCES_USE_MUTEXMGR_STD 1
+
/* Define to use the POSIX mutex mgr */
#cmakedefine XERCES_USE_MUTEXMGR_POSIX 1
Modified: xerces/c/trunk/doc/build.xml
URL: http://svn.apache.org/viewvc/xerces/c/trunk/doc/build.xml?rev=1826421&r1=1826420&r2=1826421&view=diff
==============================================================================
--- xerces/c/trunk/doc/build.xml (original)
+++ xerces/c/trunk/doc/build.xml Sat Mar 10 21:07:56 2018
@@ -178,7 +178,31 @@
<p>Thread support is enabled by default and can be disabled
with the <code>-Dthreads:BOOL=OFF</code> option. If disabled,
it will not be possible to select a mutex manager other than
- <code>nothreads</code>.</p>
+ <code>nothreads</code>. If enabled, one of the following
+ mutex managers may be selected:</p>
+
+ <table>
+ <tr>
+ <th>Option</th>
+ <th>Description</th>
+ </tr>
+ <tr>
+ <td><code>-Dmutex-manager=standard</code></td>
+ <td>Use Standard C++ mutex (requires a C++11 compiler)</td>
+ </tr>
+ <tr>
+ <td><code>-Dmutex-manager=posix</code></td>
+ <td>Use POSIX threads (pthreads) mutex (only on UNIX and Cygwin)</td>
+ </tr>
+ <tr>
+ <td><code>-Dmutex-manager=windows</code></td>
+ <td>Use Windows threads mutex (Windows and MinGW only)</td>
+ </tr>
+ <tr>
+ <td><code>-Dmutex-manager=nothreads</code></td>
+ <td>Use dummy implementation (default if threading is disabled)</td>
+ </tr>
+ </table>
<p>Shared libraries are built by default. You can use the
<code>-DBUILD_SHARED_LIBS:BOOL=OFF</code> option to build
@@ -434,7 +458,33 @@
</table>
<p>Thread support is enabled by default and can be disabled with the
- <code>--disable-threads</code> option.</p>
+ <code>--disable-threads</code> option. If disabled,
+ it will not be possible to select a mutex manager other than
+ <code>nothreads</code>. If enabled, one of the following
+ mutex managers may be selected:</p>
+
+ <table>
+ <tr>
+ <th>Option</th>
+ <th>Description</th>
+ </tr>
+ <tr>
+ <td><code>--enable-mutexmgr-standard</code></td>
+ <td>Use Standard C++ mutex (requires a C++11 compiler)</td>
+ </tr>
+ <tr>
+ <td><code>--enable-mutexmgr-posix</code></td>
+ <td>Use POSIX threads (pthreads) mutex (only on UNIX and Cygwin)</td>
+ </tr>
+ <tr>
+ <td><code>--enable-mutexmgr-windows</code></td>
+ <td>Use Windows threads mutex (Windows and MinGW only)</td>
+ </tr>
+ <tr>
+ <td><code>--enable-mutexmgr-nothreads</code></td>
+ <td>Use dummy implementation (default if threading is disabled)</td>
+ </tr>
+ </table>
<p>By default <code>configure</code> selects both shared and static
libraries. You can use the <code>--disable-shared</code> and
Added: xerces/c/trunk/m4/cxx_have_std_thread.m4
URL: http://svn.apache.org/viewvc/xerces/c/trunk/m4/cxx_have_std_thread.m4?rev=1826421&view=auto
==============================================================================
--- xerces/c/trunk/m4/cxx_have_std_thread.m4 (added)
+++ xerces/c/trunk/m4/cxx_have_std_thread.m4 Sat Mar 10 21:07:56 2018
@@ -0,0 +1,50 @@
+dnl @synopsis AC_CXX_HAVE_STD_THREAD
+dnl
+dnl If the compiler supports ISO C++11 <thread> and <mutex>, define
+dnl HAVE_STD_THREAD.
+dnl
+dnl @category Cxx
+dnl @author Roger Leigh
+dnl @author Roger Leigh <rl...@codelibre.net>
+dnl @version 2017-06-09
+dnl @license AllPermissive
+
+AC_DEFUN([AC_CXX_HAVE_STD_THREAD],
+[AC_CACHE_CHECK(whether the compiler supports ISO C++11 <thread> and <mutex>,
+ac_cv_cxx_have_std_thread,
+[AC_REQUIRE([AC_CXX_HAVE_NAMESPACES])
+ AC_REQUIRE([ACX_PTHREAD])
+ AC_LANG_SAVE
+ AC_LANG_CPLUSPLUS
+ save_CFLAGS="$CFLAGS"
+ CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
+ AC_TRY_COMPILE([#include <thread>
+#include <mutex>
+#include <iostream>
+
+namespace
+{
+
+ std::mutex m1;
+ std::recursive_mutex m2;
+
+ void
+ threadmain()
+ {
+ std::lock_guard<std::mutex> lock1(m1);
+ std::lock_guard<std::recursive_mutex> lock2(m2);
+ std::cout << "In thread" << std::endl;
+ }
+
+}
+],[std::thread foo(threadmain);
+ foo.join();
+return 0;],
+ ac_cv_cxx_have_std_thread=yes, ac_cv_cxx_have_std_thread=no)
+ CFLAGS="$save_CFLAGS"
+ AC_LANG_RESTORE
+])
+if test "$ac_cv_cxx_have_std_thread" = yes; then
+ AC_DEFINE(HAVE_STD_THREAD,,[define if the compiler supports ISO C++11 <thread> and <mutex>])
+fi
+])
Modified: xerces/c/trunk/m4/xerces_mutexmgr_selection.m4
URL: http://svn.apache.org/viewvc/xerces/c/trunk/m4/xerces_mutexmgr_selection.m4?rev=1826421&r1=1826420&r2=1826421&view=diff
==============================================================================
--- xerces/c/trunk/m4/xerces_mutexmgr_selection.m4 (original)
+++ xerces/c/trunk/m4/xerces_mutexmgr_selection.m4 Sat Mar 10 21:07:56 2018
@@ -11,60 +11,178 @@ dnl $Id$
AC_DEFUN([XERCES_MUTEXMGR_SELECTION],
[
- AC_REQUIRE([XERCES_NO_THREADS])
+
+ ######################################################
+ # Test for availability of each mutex manager on this host.
+ # For each mutex manager that's available, and hasn't been
+ # disabled, add it to our list. If the mutex manager has been
+ # explicitly "enable"d, then vote for it strongly, in upper
+ # case.
+ ######################################################
+
+ ml_list=
+
+ AC_REQUIRE([XERCES_NO_THREADS])
AC_REQUIRE([ACX_PTHREAD])
-
- AC_MSG_CHECKING([for which Mutex Manager to use])
- mutexmgr=
-
- # If no threads is specified, use the NoThread Mutex Mgr
- AS_IF([test x$xerces_cv_no_threads = xyes],
- [
- mutexmgr=NoThreads
- AC_DEFINE([XERCES_USE_MUTEXMGR_NOTHREAD], 1, [Define to use the NoThread mutex mgr])
+ AC_REQUIRE([AC_CXX_HAVE_STD_THREAD])
+
+ # Use Standard C++11 threads if available
+ list_add=
+ AC_MSG_CHECKING([whether we can support the Standard C++11 threads-based MutexMgr])
+ AS_IF([test x$xerces_cv_no_threads = xno && test x$ac_cv_cxx_have_std_thread = xyes], [
+ AC_ARG_ENABLE([mutexmgr-standard],
+ AS_HELP_STRING([--enable-mutexmgr-standard],
+ [Enable Standard C++11 threads mutex manager support]),
+ [AS_IF([test x"$enableval" = xyes],
+ [list_add=STANDARD])],
+ [list_add=standard])
+ ])
+ AS_IF([test x"$list_add" != x],
+ [mm_list="$mm_list -$list_add-"; AC_MSG_RESULT(yes)],
+ [AC_MSG_RESULT(no)]
+ )
+
+ # Check for OS-specific mutex managers
+ case $host_os in
+ windows* | mingw*)
+ # Native Windows threads
+ list_add=
+ AC_MSG_CHECKING([whether we can support the Windows threads-based MutexMgr])
+ AS_IF([test x$xerces_cv_no_threads = xno], [
+ AC_ARG_ENABLE([mutexmgr-windows],
+ AS_HELP_STRING([--enable-mutexmgr-windows],
+ [Enable Windows mutex manager support]),
+ [AS_IF([test x"$enableval" = xyes],
+ [list_add=WINDOWS])],
+ [list_add=windows])
])
-
- # Platform specific checks
- AS_IF([test -z "$mutexmgr"],
- [
+ AS_IF([test x"$list_add" != x],
+ [mm_list="$mm_list -$list_add-"; AC_MSG_RESULT(yes)],
+ [AC_MSG_RESULT(no)]
+ )
+ break
+ ;;
+ *)
+ # Native POSIX threads
+ list_add=
+ AC_MSG_CHECKING([whether we can support the POSIX threads (pthreads)-based MutexMgr])
+ AS_IF([test x$xerces_cv_no_threads = xno], [
+ AC_ARG_ENABLE([mutexmgr-posix],
+ AS_HELP_STRING([--enable-mutexmgr-posix],
+ [Enable POSIX mutex manager support]),
+ [AS_IF([test x"$enableval" = xyes],
+ [list_add=POSIX])],
+ [list_add=posix])
+ ])
+ AS_IF([test x"$list_add" != x],
+ [mm_list="$mm_list -$list_add-"; AC_MSG_RESULT(yes)],
+ [AC_MSG_RESULT(no)]
+ )
+ break
+ ;;
+ esac
+
+ # If no threads is specified, use the NoThread Mutex Mgr
+ list_add=
+ AC_MSG_CHECKING([whether we can support the NoThreads MutexMgr])
+ AC_ARG_ENABLE([mutexmgr-nothreads],
+ AS_HELP_STRING([--enable-mutexmgr-nothreads],
+ [Enable NoThreads mutex manager support (no threading)]),
+ [AS_IF([test x"$enableval" = xyes],
+ [list_add=NOTHREADS])],
+ [list_add=nothreads])
+ AS_IF([test x"$list_add" != x],
+ [mm_list="$mm_list -$list_add-"; AC_MSG_RESULT(yes)],
+ [AC_MSG_RESULT(no)]
+ )
+
+
+ ######################################################
+ # Determine which mutex manager to use.
+ #
+ # We do this in two passes. Mutex managers that have been
+ # enabled with "yes", and which start out in upper case, get
+ # the top priority on the first pass. On the second pass, we
+ # consider those which are simply available, but which were
+ # not "disable"d (these won't even be in our list).
+ ######################################################
+ mutexmgr=
+ az_lower=abcdefghijklmnopqrstuvwxyz
+ az_upper=ABCDEFGHIJKLMNOPQRSTUVWXYZ
+ AC_MSG_CHECKING([for which mutex manager to use (choices:$mm_list)])
+ for i in 1 2; do
+ # Swap upper/lower case in the mm_list. Cannot use tr ranges
+ # because of the portability issues.
+ #
+ mm_list=`echo $mm_list | tr "$az_lower$az_upper" "$az_upper$az_lower"`
+
+ # Check for each mutexmgr, in implicit rank order
+ case $mm_list in
+ *-standard-*)
+ mutexmgr=standard;
+ AC_DEFINE([XERCES_USE_MUTEXMGR_STD], 1, [Define to use the C++ standard mutex mgr (requires C++11)])
+
case $host_os in
- windows* | cygwin* | mingw*)
- mutexmgr=Windows;
- AC_DEFINE([XERCES_USE_MUTEXMGR_WINDOWS], 1, [Define to use the Windows mutex mgr])
-
- case $host_os in
- mingw*)
- CXXFLAGS="${CXXFLAGS} -mthreads"
- ;;
- esac
-
+ mingw*)
+ CXXFLAGS="${CXXFLAGS} -mthreads"
;;
esac
- ])
-
- # Fall back to using posix mutex id we can
- AS_IF([test -z "$mutexmgr" && test x$acx_pthread_ok = xyes],
- [
+ if test "$acx_pthread_ok" = yes; then
+ LIBS="${LIBS} ${PTHREAD_LIBS}"
+ CXXFLAGS="${CXXFLAGS} ${PTHREAD_CFLAGS}"
+ fi
+ break
+ ;;
+
+ *-posix-*)
mutexmgr=POSIX;
AC_DEFINE([XERCES_USE_MUTEXMGR_POSIX], 1, [Define to use the POSIX mutex mgr])
-
+
# Set additional flags for link and compile
LIBS="${LIBS} ${PTHREAD_LIBS}"
CXXFLAGS="${CXXFLAGS} ${PTHREAD_CFLAGS}"
- ])
-
- # If we still didn't find a mutex package, bail
- AS_IF([test -z "$mutexmgr"],
- [AC_MSG_ERROR([Xerces cannot function without mutex support. You may want to --disable-threads.])])
+ break
+ ;;
+
+ *-windows-*)
+ mutexmgr=Windows;
+ AC_DEFINE([XERCES_USE_MUTEXMGR_WINDOWS], 1, [Define to use the Windows mutex mgr])
+
+ case $host_os in
+ mingw*)
+ CXXFLAGS="${CXXFLAGS} -mthreads"
+ ;;
+ esac
+ break
+ ;;
+
+ *-nothreads-*)
+ mutexmgr=NoThreads
+ AC_DEFINE([XERCES_USE_MUTEXMGR_NOTHREAD], 1, [Define to use the NoThread mutex mgr])
+ break
+ ;;
+
+ *)
+ AS_IF([test $i -eq 2], [
+ AC_MSG_RESULT([Xerces cannot function without mutex support. You may want to --disable-threads.])
+ ]
+ )
+ ;;
+
+ esac
+ done
+
+ if test x"$mutexmgr" != x; then
+ AC_MSG_RESULT($mutexmgr)
+ fi
- AC_MSG_RESULT($mutexmgr)
-
# Define the auto-make conditionals which determine what actually gets compiled
# Note that these macros can't be executed conditionally, which is why they're here, not above.
AM_CONDITIONAL([XERCES_USE_MUTEXMGR_NOTHREAD], [test x"$mutexmgr" = xNoThreads])
+ AM_CONDITIONAL([XERCES_USE_MUTEXMGR_STD], [test x"$mutexmgr" = xstandard])
AM_CONDITIONAL([XERCES_USE_MUTEXMGR_POSIX], [test x"$mutexmgr" = xPOSIX])
AM_CONDITIONAL([XERCES_USE_MUTEXMGR_WINDOWS], [test x"$mutexmgr" = xWindows])
-
+
]
)
Modified: xerces/c/trunk/scripts/ci-travis
URL: http://svn.apache.org/viewvc/xerces/c/trunk/scripts/ci-travis?rev=1826421&r1=1826420&r2=1826421&view=diff
==============================================================================
--- xerces/c/trunk/scripts/ci-travis (original)
+++ xerces/c/trunk/scripts/ci-travis Sat Mar 10 21:07:56 2018
@@ -9,14 +9,22 @@ set -x
autoconf_build()
{
opts=""
- # network
+ # mutexmgr
case "$3" in
+ standard) opts="$opts --enable-mutexmgr-standard" ;;
+ posix) opts="$opts --enable-mutexmgr-posix" ;;
+ windows) opts="$opts --enable-mutexmgr-windows" ;;
+ nothreads) opts="$opts --enable-mutexmgr-nothreads" ;;
+ esac
+
+ # network
+ case "$4" in
ON) opts="$opts --enable-network" ;;
*) opts="$opts --disable-network" ;;
esac
# netaccessor
- case "$4" in
+ case "$5" in
curl) opts="$opts --enable-netaccessor-curl" ;;
socket) opts="$opts --enable-netaccessor-socket" ;;
cfurl) opts="$opts --enable-netaccessor-cfurl" ;;
@@ -24,14 +32,14 @@ autoconf_build()
esac
# msgloader
- case "$5" in
+ case "$6" in
inmemory) opts="$opts --enable-msgloader-inmemory" ;;
icu) opts="$opts --enable-msgloader-icu" ;;
iconv) opts="$opts --enable-msgloader-iconv" ;;
esac
# transcoder
- case "$6" in
+ case "$7" in
# Testing on Linux, it's always GNU iconv
iconv) opts="$opts --enable-transcoder-gnuiconv" ;;
gnuiconv) opts="$opts --enable-transcoder-gnuiconv" ;;
@@ -41,7 +49,7 @@ autoconf_build()
esac
# msgloader
- case "$7" in
+ case "$8" in
char16_t) opts="$opts --enable-xmlch-char16_t" ;;
uint16_t) opts="$opts --enable-xmlch-uint16_t" ;;
esac
@@ -113,19 +121,22 @@ cmake_build()
{
opts=""
if [ -n "$3" ]; then
- opts="$opts -Dnetwork:BOOL=$3"
+ opts="$opts -Dmutex-manager=$3"
fi
if [ -n "$4" ]; then
- opts="$opts -Dnetwork-accessor=$4"
+ opts="$opts -Dnetwork:BOOL=$4"
fi
if [ -n "$5" ]; then
- opts="$opts -Dmessage-loader=$5"
+ opts="$opts -Dnetwork-accessor=$5"
fi
if [ -n "$6" ]; then
- opts="$opts -Dtranscoder=$6"
+ opts="$opts -Dmessage-loader=$6"
fi
if [ -n "$7" ]; then
- opts="$opts -Dxmlch-type=$7"
+ opts="$opts -Dtranscoder=$7"
+ fi
+ if [ -n "$8" ]; then
+ opts="$opts -Dxmlch-type=$8"
fi
PATH="$(pwd)/tools/bin:$PATH"
Modified: xerces/c/trunk/src/CMakeLists.txt
URL: http://svn.apache.org/viewvc/xerces/c/trunk/src/CMakeLists.txt?rev=1826421&r1=1826420&r2=1826421&view=diff
==============================================================================
--- xerces/c/trunk/src/CMakeLists.txt (original)
+++ xerces/c/trunk/src/CMakeLists.txt Sat Mar 10 21:07:56 2018
@@ -1009,6 +1009,14 @@ set(nothreadmmgr_sources
xercesc/util/MutexManagers/NoThreadMutexMgr.cpp
)
+set(stdmmgr_headers
+ xercesc/util/MutexManagers/StdMutexMgr.hpp
+)
+
+set(stdmmgr_sources
+ xercesc/util/MutexManagers/StdMutexMgr.cpp
+)
+
set(posixmmgr_headers
xercesc/util/MutexManagers/PosixMutexMgr.hpp
)
@@ -1201,6 +1209,12 @@ if(XERCES_USE_MUTEXMGR_NOTHREAD)
list(APPEND libxerces_c_HEADERS ${nothreadmmgr_headers})
endif()
+if(XERCES_USE_MUTEXMGR_STD)
+ list(APPEND libxerces_c_SOURCES ${stdmmgr_sources})
+ list(APPEND libxerces_c_HEADERS ${stdmmgr_headers})
+ list(APPEND libxerces_c_DEPS Threads::Threads)
+endif()
+
if(XERCES_USE_MUTEXMGR_POSIX)
list(APPEND libxerces_c_SOURCES ${posixmmgr_sources})
list(APPEND libxerces_c_HEADERS ${posixmmgr_headers})
Modified: xerces/c/trunk/src/Makefile.am
URL: http://svn.apache.org/viewvc/xerces/c/trunk/src/Makefile.am?rev=1826421&r1=1826420&r2=1826421&view=diff
==============================================================================
--- xerces/c/trunk/src/Makefile.am (original)
+++ xerces/c/trunk/src/Makefile.am Sat Mar 10 21:07:56 2018
@@ -173,6 +173,11 @@ libxerces_c_la_SOURCES += ${nothreadmmgr
nobase_libxerces_c_la_HEADERS += ${nothreadmmgr_headers}
endif
+if XERCES_USE_MUTEXMGR_STD
+libxerces_c_la_SOURCES += ${stdmmgr_sources}
+nobase_libxerces_c_la_HEADERS += ${stdmmgr_headers}
+endif
+
if XERCES_USE_MUTEXMGR_POSIX
libxerces_c_la_SOURCES += ${posixmmgr_sources}
nobase_libxerces_c_la_HEADERS += ${posixmmgr_headers}
@@ -1118,6 +1123,12 @@ nothreadmmgr_headers = \
nothreadmmgr_sources = \
xercesc/util/MutexManagers/NoThreadMutexMgr.cpp
+stdmmgr_headers = \
+ xercesc/util/MutexManagers/StdMutexMgr.hpp
+
+stdmmgr_sources = \
+ xercesc/util/MutexManagers/StdMutexMgr.cpp
+
posixmmgr_headers = \
xercesc/util/MutexManagers/PosixMutexMgr.hpp
Added: xerces/c/trunk/src/xercesc/util/MutexManagers/StdMutexMgr.cpp
URL: http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/util/MutexManagers/StdMutexMgr.cpp?rev=1826421&view=auto
==============================================================================
--- xerces/c/trunk/src/xercesc/util/MutexManagers/StdMutexMgr.cpp (added)
+++ xerces/c/trunk/src/xercesc/util/MutexManagers/StdMutexMgr.cpp Sat Mar 10 21:07:56 2018
@@ -0,0 +1,91 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * $Id$
+ */
+
+#include <mutex>
+
+#include <xercesc/util/MutexManagers/StdMutexMgr.hpp>
+#include <xercesc/util/PlatformUtils.hpp>
+#include <xercesc/util/RuntimeException.hpp>
+#include <xercesc/util/PanicHandler.hpp>
+
+XERCES_CPP_NAMESPACE_BEGIN
+
+
+// Wrap up the mutex with XMemory
+class StdMutexWrap : public XMemory {
+public:
+ std::recursive_mutex m;
+};
+
+
+StdMutexMgr::StdMutexMgr()
+{
+}
+
+
+StdMutexMgr::~StdMutexMgr()
+{
+}
+
+
+XMLMutexHandle
+StdMutexMgr::create(MemoryManager* const manager)
+{
+ StdMutexWrap* mutex = new (manager) StdMutexWrap;
+ return (void*)(mutex);
+}
+
+
+void
+StdMutexMgr::destroy(XMLMutexHandle mtx, MemoryManager* const manager)
+{
+ StdMutexWrap* mutex = (StdMutexWrap*)(mtx);
+ if (mutex != NULL)
+ {
+ delete mutex;
+ }
+}
+
+
+void
+StdMutexMgr::lock(XMLMutexHandle mtx)
+{
+ StdMutexWrap* mutex = (StdMutexWrap*)(mtx);
+ if (mutex != NULL)
+ {
+ mutex->m.lock();
+ }
+}
+
+
+void
+StdMutexMgr::unlock(XMLMutexHandle mtx)
+{
+ StdMutexWrap* mutex = (StdMutexWrap*)(mtx);
+ if (mutex != NULL)
+ {
+ mutex->m.unlock();
+ }
+}
+
+
+XERCES_CPP_NAMESPACE_END
+
Added: xerces/c/trunk/src/xercesc/util/MutexManagers/StdMutexMgr.hpp
URL: http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/util/MutexManagers/StdMutexMgr.hpp?rev=1826421&view=auto
==============================================================================
--- xerces/c/trunk/src/xercesc/util/MutexManagers/StdMutexMgr.hpp (added)
+++ xerces/c/trunk/src/xercesc/util/MutexManagers/StdMutexMgr.hpp Sat Mar 10 21:07:56 2018
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * $Id$
+ */
+
+#if !defined(XERCESC_INCLUDE_GUARD_STDMUTEXMGR_HPP)
+#define XERCESC_INCLUDE_GUARD_STDMUTEXMGR_HPP
+
+#include <xercesc/util/XMLMutexMgr.hpp>
+
+XERCES_CPP_NAMESPACE_BEGIN
+
+// Std mutex implementation.
+class StdMutexMgr : public XMLMutexMgr
+{
+ public:
+ StdMutexMgr();
+ virtual ~StdMutexMgr();
+
+ // Mutex operations
+ virtual XMLMutexHandle create(MemoryManager* const manager);
+ virtual void destroy(XMLMutexHandle mtx, MemoryManager* const manager);
+ virtual void lock(XMLMutexHandle mtx);
+ virtual void unlock(XMLMutexHandle mtx);
+};
+
+XERCES_CPP_NAMESPACE_END
+
+
+#endif
Modified: xerces/c/trunk/src/xercesc/util/PlatformUtils.cpp
URL: http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/util/PlatformUtils.cpp?rev=1826421&r1=1826420&r2=1826421&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/util/PlatformUtils.cpp (original)
+++ xerces/c/trunk/src/xercesc/util/PlatformUtils.cpp Sat Mar 10 21:07:56 2018
@@ -69,6 +69,9 @@
#if XERCES_USE_MUTEXMGR_NOTHREAD
# include <xercesc/util/MutexManagers/NoThreadMutexMgr.hpp>
#endif
+#if XERCES_USE_MUTEXMGR_STD
+# include <xercesc/util/MutexManagers/StdMutexMgr.hpp>
+#endif
#if XERCES_USE_MUTEXMGR_POSIX
# include <xercesc/util/MutexManagers/PosixMutexMgr.hpp>
#endif
@@ -721,6 +724,8 @@ XMLMutexMgr* XMLPlatformUtils::makeMutex
#if XERCES_USE_MUTEXMGR_NOTHREAD
mgr = new (memmgr) NoThreadMutexMgr;
+ #elif XERCES_USE_MUTEXMGR_STD
+ mgr = new (memmgr) StdMutexMgr;
#elif XERCES_USE_MUTEXMGR_POSIX
mgr = new (memmgr) PosixMutexMgr;
#elif XERCES_USE_MUTEXMGR_WINDOWS
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@xerces.apache.org
For additional commands, e-mail: commits-help@xerces.apache.org