From 60659c5d84da529ee2faac1f8bf32ccedf123b17 Mon Sep 17 00:00:00 2001 From: John Maddock Date: Mon, 28 May 2001 11:48:06 +0000 Subject: [PATCH] Added BeOS threading support, tweeked STLPort detection. [SVN r10235] --- include/boost/regex/detail/regex_config.hpp | 4 +-- include/boost/regex/detail/regex_synch.hpp | 40 +++++++++++++++++++-- 2 files changed, 39 insertions(+), 5 deletions(-) diff --git a/include/boost/regex/detail/regex_config.hpp b/include/boost/regex/detail/regex_config.hpp index 803d102d..a0b6fc6a 100644 --- a/include/boost/regex/detail/regex_config.hpp +++ b/include/boost/regex/detail/regex_config.hpp @@ -307,7 +307,7 @@ full list of macros and their usage. # endif #endif -#if (defined(_REENTRANT) || defined(_PTHREADS)) && !defined(_NOTHREADS) +#if (defined(_REENTRANT) || defined(_PTHREADS) || defined(__BEOS__)) && !defined(_NOTHREADS) // // Several compilers define _REENTRANT or // _PTHREADS when threading support is turned on: @@ -967,7 +967,7 @@ public: #undef wcsxfrm #endif -#if defined(BOOST_NO_STDC_NAMESPACE) || (defined(std) && defined(__SGI_STL_PORT)) +#if defined(BOOST_NO_STDC_NAMESPACE) || (defined(std) && defined(__SGI_STL_PORT)) || defined(_STLP_IMPORT_VENDOR_CSTD) || defined(__STL_IMPORT_VENDOR_CSTD) // // fix namespaces, // note that we almost always do this for STLPort, as it doesn't always diff --git a/include/boost/regex/detail/regex_synch.hpp b/include/boost/regex/detail/regex_synch.hpp index d5af6a24..a5eb5ce7 100644 --- a/include/boost/regex/detail/regex_synch.hpp +++ b/include/boost/regex/detail/regex_synch.hpp @@ -33,9 +33,14 @@ #include #endif -#if !defined(BOOST_RE_PLATFORM_W32) && defined(BOOST_RE_THREADS) +#if !defined(BOOST_RE_PLATFORM_W32) && defined(BOOST_RE_THREADS) +#if defined(__BEOS__) +#include +#include +#else #include #endif +#endif namespace boost{ @@ -51,6 +56,35 @@ void BOOST_RE_CALL re_free_threads(); #ifdef BOOST_RE_THREADS #ifndef BOOST_RE_PLATFORM_W32 +#ifdef __BEOS__ + +typedef sem_id CRITICAL_SECTION; + +inline void BOOST_RE_CALL InitializeCriticalSection(CRITICAL_SECTION* ps) +{ + *ps = create_sem(1, "regex++"); + assert(*ps > 0); +} + +inline void BOOST_RE_CALL DeleteCriticalSection(CRITICAL_SECTION* ps) +{ + int t = delete_sem(*ps); + assert(t == B_NO_ERROR); +} + +inline void BOOST_RE_CALL EnterCriticalSection(CRITICAL_SECTION* ps) +{ + status_t t = acquire_sem(*ps); + assert(t == B_NO_ERROR); +} + +inline void BOOST_RE_CALL LeaveCriticalSection(CRITICAL_SECTION* ps) +{ + status_t t = release_sem(*ps); + assert(t == B_NO_ERROR); +} + +#else // __BEOS__ typedef pthread_mutex_t CRITICAL_SECTION; @@ -73,7 +107,7 @@ inline void BOOST_RE_CALL LeaveCriticalSection(CRITICAL_SECTION* ps) { pthread_mutex_unlock(ps); } - +#endif // __BEOS__ #endif template @@ -136,7 +170,7 @@ public: typedef lock_guard ro_guard; typedef lock_guard rw_guard; - friend lock_guard; + friend class lock_guard; }; inline bool BOOST_RE_CALL operator==(const critical_section&, const critical_section&)