Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions qpid/cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ project(qpid-cpp)
cmake_minimum_required(VERSION 2.6 FATAL_ERROR)
if(COMMAND cmake_policy)
cmake_policy(VERSION 2.6)
# Use @rpath on OSX
cmake_policy(SET CMP0042 NEW)
endif(COMMAND cmake_policy)

if (${CMAKE_VERSION} VERSION_LESS "2.8.0")
Expand Down
11 changes: 11 additions & 0 deletions qpid/cpp/INSTALL
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,17 @@ the shared libraries built as part of Qpid.
The mktemp package must be installed separately in order to execute the
Qpid test suite.

2.5 Building on OSX
===================
Qpid has been tested on OSX 10.10 with Clang 6.0 and Boost 1.57. Boost 1.57 requires
C++11 support. SASL support has not been tested. The cmake command line should be:

# cmake -DBUILD_SASL=no -DBUILD_PROBES=no -DCMAKE_CXX_FLAGS="-std=c++11 -Wno-error=deprecated-declarations" ..

Dependencies can be installed from homebrew (http://brew.sh/) using:

# brew install cmake boost ossp-uuid pkgconfig help2man doxygen grpahviz swig boost sleepycat berkeley-db

3. Building a Repository Working Copy
=====================================
To get the source code from the subversion repository (trunk) do:
Expand Down
23 changes: 13 additions & 10 deletions qpid/cpp/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -310,16 +310,19 @@ endif (UUID_GENERATE_IN_LIBC)

# These dependencies aren't found on windows
if (NOT CMAKE_SYSTEM_NAME STREQUAL Windows)
# Ensure we have clock_gettime
CHECK_FUNCTION_EXISTS (clock_gettime CLOCK_GETTIME_IN_LIBC)
if (NOT CLOCK_GETTIME_IN_LIBC)
CHECK_LIBRARY_EXISTS (rt clock_gettime "" CLOCK_GETTIME_IN_RT)
if (CLOCK_GETTIME_IN_RT)
set(clock_gettime_LIB "rt")
else ()
message(FATAL_ERROR "Cannot find clock_gettime()")
endif (CLOCK_GETTIME_IN_RT)
endif (NOT CLOCK_GETTIME_IN_LIBC)
# Clocks on OSX are different
if (NOT CMAKE_SYSTEM_NAME STREQUAL Darwin)
# Ensure we have clock_gettime
CHECK_FUNCTION_EXISTS (clock_gettime CLOCK_GETTIME_IN_LIBC)
if (NOT CLOCK_GETTIME_IN_LIBC)
CHECK_LIBRARY_EXISTS (rt clock_gettime "" CLOCK_GETTIME_IN_RT)
if (CLOCK_GETTIME_IN_RT)
set(clock_gettime_LIB "rt")
else ()
message(FATAL_ERROR "Cannot find clock_gettime()")
endif (CLOCK_GETTIME_IN_RT)
endif (NOT CLOCK_GETTIME_IN_LIBC)
endif (NOT CMAKE_SYSTEM_NAME STREQUAL OSX)

# Check for header file for dtrace static probes
check_include_files(sys/sdt.h HAVE_SDT)
Expand Down
8 changes: 6 additions & 2 deletions qpid/cpp/src/qpid/store/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,12 @@ if (CMAKE_SYSTEM_NAME STREQUAL Windows)
endif (CMAKE_SYSTEM_NAME STREQUAL Windows)

set_target_properties (store PROPERTIES
COMPILE_DEFINITIONS _IN_QPID_BROKER
VERSION ${qpidc_version})
COMPILE_DEFINITIONS _IN_QPID_BROKER)
if (NOT CMAKE_SYSTEM_NAME STREQUAL Darwin)
set_target_properties (store PROPERTIES
VERSION ${qpidc_version})
endif (NOT CMAKE_SYSTEM_NAME STREQUAL Darwin)

install (TARGETS store # RUNTIME
DESTINATION ${QPIDD_MODULE_DIR}
COMPONENT ${QPID_COMPONENT_BROKER})
Expand Down
6 changes: 6 additions & 0 deletions qpid/cpp/src/qpid/sys/posix/Condition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,13 @@ struct ClockMonotonicAttr {

ClockMonotonicAttr() {
QPID_POSIX_ASSERT_THROW_IF(pthread_condattr_init(&attr));
#ifdef __MACH__
// OSX doesn't let you set the clock, and absolute pthread
// waits are always based on gettimeofday. Not sure what to
// do.
#else
QPID_POSIX_ASSERT_THROW_IF(pthread_condattr_setclock(&attr, CLOCK_MONOTONIC));
#endif
}
};

Expand Down
6 changes: 3 additions & 3 deletions qpid/cpp/src/qpid/sys/posix/PosixPoller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -681,9 +681,9 @@ void Poller::run() {
// Ensure that we exit thread responsibly under all circumstances
try {
// Make sure we can't be interrupted by signals at a bad time
::sigset_t ss;
::sigfillset(&ss);
::pthread_sigmask(SIG_SETMASK, &ss, 0);
sigset_t ss;
sigfillset(&ss);
pthread_sigmask(SIG_SETMASK, &ss, 0);

++(impl->threadCount);
do {
Expand Down
5 changes: 4 additions & 1 deletion qpid/cpp/src/qpid/sys/posix/PrivatePosix.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@

#include "qpid/sys/Time.h"

#ifdef __MACH__
#include <mach/clock.h>
#endif

struct timespec;
struct timeval;
struct addrinfo;
Expand All @@ -34,7 +38,6 @@ namespace sys {
// Private Time related implementation details
struct timespec& toTimespec(struct timespec& ts, const AbsTime& t);
struct timeval& toTimeval(struct timeval& tv, const Duration& t);
Duration toTime(const struct timespec& ts);

// Private SocketAddress details
class SocketAddress;
Expand Down
53 changes: 45 additions & 8 deletions qpid/cpp/src/qpid/sys/posix/Time.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
* 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
Expand All @@ -32,13 +32,28 @@
#include <iomanip>
#include <cctype>

#ifdef __MACH__
#include <mach/clock.h>
#include <mach/mach.h>
#endif

namespace {
int64_t max_abstime() { return std::numeric_limits<int64_t>::max(); }
}

namespace qpid {
namespace sys {

#ifdef __MACH__
inline Duration toTime(const mach_timespec_t& ts) {
return ts.tv_sec*TIME_SEC + ts.tv_nsec;
}
#else
inline Duration toTime(const struct timespec& ts) {
return ts.tv_sec*TIME_SEC + ts.tv_nsec;
}
#endif

AbsTime::AbsTime(const AbsTime& t, const Duration& d) :
timepoint(d == Duration::max() ? max_abstime() : t.timepoint+d.nanosecs)
{}
Expand All @@ -53,9 +68,18 @@ AbsTime AbsTime::FarFuture() {
}

AbsTime AbsTime::now() {
AbsTime time_now;
#ifdef __MACH__
// SYSTEM_CLOCK is like CLOCK_MONOTONIC
clock_serv_t cs;
mach_timespec_t ts;
host_get_clock_service(mach_host_self(), SYSTEM_CLOCK, &cs);
clock_get_time(cs, &ts);
mach_port_deallocate(mach_task_self(), cs);
#else
struct timespec ts;
::clock_gettime(CLOCK_MONOTONIC, &ts);
AbsTime time_now;
#endif
time_now.timepoint = toTime(ts).nanosecs;
return time_now;
}
Expand All @@ -65,8 +89,17 @@ AbsTime AbsTime::epoch() {
}

Duration Duration::FromEpoch() {
#ifdef __MACH__
// CALENDAR_CLOCK is like CLOCK_REALTIME
clock_serv_t cs;
mach_timespec_t ts;
host_get_clock_service(mach_host_self(), CALENDAR_CLOCK, &cs);
clock_get_time(cs, &ts);
mach_port_deallocate(mach_task_self(), cs);
#else
struct timespec ts;
::clock_gettime(CLOCK_REALTIME, &ts);
#endif
return toTime(ts).nanosecs;
}

Expand All @@ -84,11 +117,7 @@ struct timespec& toTimespec(struct timespec& ts, const AbsTime& a) {
Duration secs = t / TIME_SEC;
ts.tv_sec = (secs > TIME_T_MAX) ? TIME_T_MAX : static_cast<time_t>(secs);
ts.tv_nsec = static_cast<long>(t % TIME_SEC);
return ts;
}

Duration toTime(const struct timespec& ts) {
return ts.tv_sec*TIME_SEC + ts.tv_nsec;
return ts;
}

std::ostream& operator<<(std::ostream& o, const Duration& d) {
Expand Down Expand Up @@ -144,8 +173,16 @@ void outputFormattedNow(std::ostream& o) {
}

void outputHiresNow(std::ostream& o) {
#ifdef __MACH__
clock_serv_t cs;
mach_timespec_t time;
host_get_clock_service(mach_host_self(), CALENDAR_CLOCK, &cs);
clock_get_time(cs, &time);
mach_port_deallocate(mach_task_self(), cs);
#else
::timespec time;
::clock_gettime(CLOCK_REALTIME, &time);
#endif
::time_t seconds = time.tv_sec;
outputFormattedTime(o, &seconds);
o << "." << std::setw(9) << std::setfill('0') << time.tv_nsec << " ";
Expand Down
4 changes: 2 additions & 2 deletions qpid/cpp/src/qpid/sys/regex.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
*
*/

#if defined(_POSIX_SOURCE) || defined(__unix__)
#if defined(_POSIX_SOURCE) || defined(__unix__) || defined(__MACH__)
# include <stdexcept>
# include <string>
# include <regex.h>
Expand All @@ -38,7 +38,7 @@
namespace qpid {
namespace sys {

#if defined(_POSIX_SOURCE) || defined(__unix__)
#if defined(_POSIX_SOURCE) || defined(__unix__) || defined(__MACH__)

class regex {
::regex_t re;
Expand Down