Commit f48167fa authored by Dominik Charousset's avatar Dominik Charousset

Add defines for iOS and Android

parent 5e55e81a
...@@ -131,16 +131,23 @@ ...@@ -131,16 +131,23 @@
// - CAF_WINDOWS // - CAF_WINDOWS
// It also defines CAF_POSIX for POSIX-compatible systems // It also defines CAF_POSIX for POSIX-compatible systems
#if defined(__APPLE__) #if defined(__APPLE__)
# define CAF_MACOS # include "TargetConditionals.h"
# ifndef _GLIBCXX_HAS_GTHREADS # if TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR
# define _GLIBCXX_HAS_GTHREADS # define CAF_IOS
# else
# define CAF_MACOS
# ifndef _GLIBCXX_HAS_GTHREADS
# define _GLIBCXX_HAS_GTHREADS
# endif
# endif # endif
#elif defined(__ANDROID__)
# define CAF_ANDROID
#elif defined(__linux__) #elif defined(__linux__)
# define CAF_LINUX # define CAF_LINUX
# include <linux/version.h> # include <linux/version.h>
# if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,16) # if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,16)
# define CAF_POLL_IMPL # define CAF_POLL_IMPL
# endif # endif
#elif defined(__FreeBSD__) #elif defined(__FreeBSD__)
# define CAF_BSD # define CAF_BSD
#elif defined(WIN32) || defined(_WIN32) #elif defined(WIN32) || defined(_WIN32)
......
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
#include "caf/config.hpp" #include "caf/config.hpp"
#ifdef CAF_MACOS #if defined(CAF_MACOS) || defined(CAF_IOS)
#include <mach/mach.h> #include <mach/mach.h>
#else #else
#include <sys/resource.h> #include <sys/resource.h>
...@@ -58,7 +58,7 @@ class profiled_coordinator : public coordinator<Policy> { ...@@ -58,7 +58,7 @@ class profiled_coordinator : public coordinator<Policy> {
class measurement { class measurement {
public: public:
# ifdef CAF_MACOS # if defined(CAF_MACOS) || defined(CAF_IOS)
static usec to_usec(const ::time_value_t& tv) { static usec to_usec(const ::time_value_t& tv) {
return std::chrono::seconds(tv.seconds) + usec(tv.microseconds); return std::chrono::seconds(tv.seconds) + usec(tv.microseconds);
} }
...@@ -72,7 +72,7 @@ class profiled_coordinator : public coordinator<Policy> { ...@@ -72,7 +72,7 @@ class profiled_coordinator : public coordinator<Policy> {
auto now = clock_type::now().time_since_epoch(); auto now = clock_type::now().time_since_epoch();
measurement m; measurement m;
m.time = std::chrono::duration_cast<usec>(now); m.time = std::chrono::duration_cast<usec>(now);
# ifdef CAF_MACOS # if defined(CAF_MACOS) || defined(CAF_IOS)
auto tself = ::mach_thread_self(); auto tself = ::mach_thread_self();
::thread_basic_info info; ::thread_basic_info info;
auto count = THREAD_BASIC_INFO_COUNT; auto count = THREAD_BASIC_INFO_COUNT;
......
#include "caf/config.hpp" #include "caf/config.hpp"
#include "caf/detail/get_mac_addresses.hpp" #include "caf/detail/get_mac_addresses.hpp"
#if defined(CAF_MACOS) || defined(CAF_BSD) #if defined(CAF_MACOS) || defined(CAF_BSD) || defined(CAF_IOS)
#include <sys/types.h> #include <sys/types.h>
#include <sys/socket.h> #include <sys/socket.h>
...@@ -76,7 +76,7 @@ std::vector<iface_info> get_mac_addresses() { ...@@ -76,7 +76,7 @@ std::vector<iface_info> get_mac_addresses() {
} // namespace detail } // namespace detail
} // namespace caf } // namespace caf
#elif defined(CAF_LINUX) #elif defined(CAF_LINUX) || defined(CAF_ANDROID)
#include <vector> #include <vector>
#include <string> #include <string>
......
...@@ -50,11 +50,11 @@ using std::string; ...@@ -50,11 +50,11 @@ using std::string;
namespace { namespace {
#ifdef CAF_MACOS #if defined(CAF_MACOS) || defined(CAF_IOS)
constexpr int no_sigpipe_flag = SO_NOSIGPIPE; constexpr int no_sigpipe_flag = SO_NOSIGPIPE;
#elif defined(CAF_WINDOWS) #elif defined(CAF_WINDOWS)
constexpr int no_sigpipe_flag = 0; // does not exist on Windows constexpr int no_sigpipe_flag = 0; // does not exist on Windows
#else // BSD or Linux #else // BSD, Linux or Android
constexpr int no_sigpipe_flag = MSG_NOSIGNAL; constexpr int no_sigpipe_flag = MSG_NOSIGNAL;
#endif #endif
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment