Boost logo

Boost Testing :

From: Thorsten Froehlich (froetho_at_[hidden])
Date: 2006-03-15 13:24:24


Stephen W. Carson wrote:
> We're trying to benefit from all this testing I've been doing with
> CodeWarrior for the Mac. Our Mac programmer has been trying to build
> boost thread from boost version 1.32.0 in the CodeWarrior GUI and got
> the following errors:

The Carbon version of boost::thread is completely broken. I did not bother
trying any more as CodeWarrior (since CW 9 iirc) includes their own, working
implementation based on earlier ISO C++ standard extension proposals (iirc).
As metrowerks has now declared CW Mac EOL, and it is the last supported
compiler for Carbon COM, there is little point in changing boost...

The Matrowerks implementation is essentially identical in functionality with
boost::thread and works perfectly with Carbon, so just a few tricks are
needed to get other boost libraries to accept another thread implementation
without requiring changes to code including boost::thread headers 8remember
to recompile boost). As I only needed some parts of boost::thread, I added
the following to a precompiled header file. It works without problems, and
can be extended to handle all of boost::thread. Note though that you
absolutely have to create your own multithreaded Carbon CFM library variants
(assuming you are using CFM Carbon rather than Mach-O Carbon) and *build*
the MSL C and C++ libraries with _MSL_THREADSAFE because it is not enabled
for Carbon CFM in any of the variants supplied by Metrowerks.

So here is what i have in my current precompiled header:

#define TARGET_API_MAC_CARBON 1

#define _MSL_THREADSAFE 1

// boost thread for Carbon is completely broken, so this mixes
// the MSL thread implementation with other boost code [trf]

#define BOOST_THREAD_WEK01082003_HPP 1 // disable boost/thread.hpp include file
#define BOOST_RECURSIVE_MUTEX_WEK070601_HPP 1 // disable
boost/thread/recursive_mutex.hpp include file
#define BOOST_ONCE_WEK080101_HPP 1 // disable boost/thread/once.hpp include file
#define BOOST_XTIME_WEK070601_HPP 1 // disable boost's xtime hack

// import MSL thread implementation
#include <msl_time>
#include <msl_thread>
#include <msl_mutex>
#include <msl_condition>

// force the MSL thread implementation into the boost namespace
namespace boost
{
        using Metrowerks::thread;
        using Metrowerks::once_flag;
        using Metrowerks::call_once;
        using Metrowerks::thread_group;
        using Metrowerks::thread_specific_ptr;
        using Metrowerks::mutex;
        using Metrowerks::try_mutex;
        using Metrowerks::timed_mutex;
        using Metrowerks::recursive_mutex;
        using Metrowerks::detail::scoped_lock;
        using Metrowerks::condition;

        class xtime : public Metrowerks::universal_time
        {
                public:
                        typedef std::time_t xtime_sec_t;
                        typedef std::int32_t xtime_nsec_t;

                        inline xtime() : sec(sec_), nsec(nsec_) { }

                        xtime_sec_t& sec;
                        xtime_nsec_t& nsec;
        };

        enum xtime_clock_types { TIME_UTC = 1 };
        inline void xtime_get(xtime *xt, xtime_clock_types) {
Metrowerks::universal_time ut; xt->sec = ut.sec_; xt->nsec = ut.nsec_; }
}


Boost-testing list run by mbergal at meta-comm.com