Commit 715ade35 authored by Dominik Charousset's avatar Dominik Charousset

fixed selection of poll/epoll impl, closes #110

this patch also gets rid of an unused-private-field-warning
when compiling w/o context switching
parent 04f3b8fa
cmake_minimum_required(VERSION 2.8) cmake_minimum_required(VERSION 2.8)
project(cppa CXX) project(cppa C CXX)
set(LIBCPPA_VERSION_MAJOR 0) set(LIBCPPA_VERSION_MAJOR 0)
set(LIBCPPA_VERSION_MINOR 8) set(LIBCPPA_VERSION_MINOR 8)
...@@ -84,14 +84,6 @@ if ("${CMAKE_BUILD_TYPE}" STREQUAL "") ...@@ -84,14 +84,6 @@ if ("${CMAKE_BUILD_TYPE}" STREQUAL "")
set(CMAKE_BUILD_TYPE RelWithDebInfo) set(CMAKE_BUILD_TYPE RelWithDebInfo)
endif ("${CMAKE_BUILD_TYPE}" STREQUAL "") endif ("${CMAKE_BUILD_TYPE}" STREQUAL "")
if (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
set(LIBCPPA_PLATFORM_SRC src/middleman_event_handler_epoll.cpp)
elseif (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set(LIBCPPA_PLATFORM_SRC src/middleman_event_handler_poll.cpp)
else ()
message(FATAL_ERROR "This platform is not supported by libcppa")
endif()
set(LIBCPPA_SRC set(LIBCPPA_SRC
${LIBCPPA_PLATFORM_SRC} ${LIBCPPA_PLATFORM_SRC}
src/abstract_tuple.cpp src/abstract_tuple.cpp
...@@ -143,6 +135,8 @@ set(LIBCPPA_SRC ...@@ -143,6 +135,8 @@ set(LIBCPPA_SRC
src/message_header.cpp src/message_header.cpp
src/middleman.cpp src/middleman.cpp
src/middleman_event_handler.cpp src/middleman_event_handler.cpp
src/middleman_event_handler_epoll.cpp
src/middleman_event_handler_poll.cpp
src/object.cpp src/object.cpp
src/object_array.cpp src/object_array.cpp
src/on.cpp src/on.cpp
......
...@@ -31,10 +31,6 @@ ...@@ -31,10 +31,6 @@
#ifndef CPPA_CONFIG_HPP #ifndef CPPA_CONFIG_HPP
#define CPPA_CONFIG_HPP #define CPPA_CONFIG_HPP
// uncomment this line or use define CPPA_DISABLE_CONTEXT_SWITCHING using CMAKE
// if boost.context is not available on your platform
//#define CPPA_DISABLE_CONTEXT_SWITCHING
#if defined(__clang__) #if defined(__clang__)
# define CPPA_CLANG # define CPPA_CLANG
# define CPPA_DEPRECATED __attribute__((__deprecated__)) # define CPPA_DEPRECATED __attribute__((__deprecated__))
...@@ -54,6 +50,10 @@ ...@@ -54,6 +50,10 @@
# endif # endif
#elif defined(__linux__) #elif defined(__linux__)
# define CPPA_LINUX # define CPPA_LINUX
# include <linux/version.h>
# if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,16)
# define CPPA_POLL_IMPL
# endif
#elif defined(WIN32) #elif defined(WIN32)
# define CPPA_WINDOWS # define CPPA_WINDOWS
#else #else
...@@ -80,7 +80,7 @@ ...@@ -80,7 +80,7 @@
CPPA_REQUIRE__(#stmt, __FILE__, __LINE__); \ CPPA_REQUIRE__(#stmt, __FILE__, __LINE__); \
}((void) 0) }((void) 0)
#else // CPPA_DEBUG_MODE #else // CPPA_DEBUG_MODE
#define CPPA_REQUIRE(unused) ((void) 0) #define CPPA_REQUIRE(unused) static_cast<void>(0)
#endif // CPPA_DEBUG_MODE #endif // CPPA_DEBUG_MODE
#define CPPA_CRITICAL__(error, file, line) { \ #define CPPA_CRITICAL__(error, file, line) { \
...@@ -93,11 +93,6 @@ ...@@ -93,11 +93,6 @@
#ifdef CPPA_WINDOWS #ifdef CPPA_WINDOWS
#else #else
# include <unistd.h> # include <unistd.h>
# include <linux/version.h>
# if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,16)
# define CPPA_POLL_IMPL
# endif // LINUX_VERSION
#endif #endif
namespace cppa { namespace cppa {
...@@ -110,7 +105,6 @@ std::unique_ptr<T> create_unique(Args&&... args) { ...@@ -110,7 +105,6 @@ std::unique_ptr<T> create_unique(Args&&... args) {
return std::unique_ptr<T>{new T(std::forward<Args>(args)...)}; return std::unique_ptr<T>{new T(std::forward<Args>(args)...)};
} }
#ifdef CPPA_WINDOWS #ifdef CPPA_WINDOWS
typedef SOCKET native_socket_type; typedef SOCKET native_socket_type;
typedef const char* socket_send_ptr; typedef const char* socket_send_ptr;
......
...@@ -50,7 +50,7 @@ ...@@ -50,7 +50,7 @@
namespace cppa { namespace cppa {
class scheduler; class scheduler;
namespace util { class fiber; } namespace util { struct fiber; }
enum class resume_result { enum class resume_result {
actor_blocked, actor_blocked,
......
...@@ -35,9 +35,7 @@ namespace cppa { namespace util { ...@@ -35,9 +35,7 @@ namespace cppa { namespace util {
class fiber_impl; class fiber_impl;
class fiber { struct fiber {
public:
fiber(); fiber();
...@@ -47,8 +45,6 @@ class fiber { ...@@ -47,8 +45,6 @@ class fiber {
static void swap(fiber& from, fiber& to); static void swap(fiber& from, fiber& to);
private:
fiber_impl* m_impl; fiber_impl* m_impl;
}; };
......
...@@ -108,8 +108,8 @@ class middleman_impl { ...@@ -108,8 +108,8 @@ class middleman_impl {
atomic_thread_fence(memory_order_seq_cst); atomic_thread_fence(memory_order_seq_cst);
uint8_t dummy = 0; uint8_t dummy = 0;
// ignore result; write error only means middleman already exited // ignore result; write error only means middleman already exited
auto unused_ret = write(m_pipe_write, &dummy, sizeof(dummy)); auto unused_ret = write(m_pipe_write, &dummy, sizeof(dummy));
static_cast<void>(unused_ret); static_cast<void>(unused_ret);
} }
void continue_writer(continuable* ptr) { void continue_writer(continuable* ptr) {
......
...@@ -27,6 +27,11 @@ ...@@ -27,6 +27,11 @@
* along with libcppa. If not, see <http://www.gnu.org/licenses/>. * * along with libcppa. If not, see <http://www.gnu.org/licenses/>. *
\******************************************************************************/ \******************************************************************************/
#include "cppa/config.hpp"
#if defined(CPPA_LINUX) && !defined(CPPA_POLL_IMPL)
#include <ios> #include <ios>
#include <string> #include <string>
#include <vector> #include <vector>
...@@ -171,4 +176,10 @@ std::unique_ptr<middleman_event_handler> middleman_event_handler::create() { ...@@ -171,4 +176,10 @@ std::unique_ptr<middleman_event_handler> middleman_event_handler::create() {
return std::unique_ptr<middleman_event_handler>{new middleman_event_handler_impl}; return std::unique_ptr<middleman_event_handler>{new middleman_event_handler_impl};
} }
} } // namespace cppa::network } } // namespace cppa::io
#else // defined(CPPA_LINUX) && !defined(CPPA_POLL_IMPL)
int keep_compiler_happy_for_epoll_impl() { return 42; }
#endif // defined(CPPA_LINUX) && !defined(CPPA_POLL_IMPL)
...@@ -28,6 +28,10 @@ ...@@ -28,6 +28,10 @@
\******************************************************************************/ \******************************************************************************/
#include "cppa/config.hpp"
#if !defined(CPPA_LINUX) || defined(CPPA_POLL_IMPL)
#include <poll.h> #include <poll.h>
#include "cppa/io/middleman_event_handler.hpp" #include "cppa/io/middleman_event_handler.hpp"
...@@ -154,4 +158,10 @@ std::unique_ptr<middleman_event_handler> middleman_event_handler::create() { ...@@ -154,4 +158,10 @@ std::unique_ptr<middleman_event_handler> middleman_event_handler::create() {
return std::unique_ptr<middleman_event_handler>{new middleman_event_handler_impl}; return std::unique_ptr<middleman_event_handler>{new middleman_event_handler_impl};
} }
} } // namespace cppa::network } } // namespace cppa::io
#else // !defined(CPPA_LINUX) || defined(CPPA_POLL_IMPL)
int keep_compiler_happy_for_poll_impl() { return 42; }
#endif // !defined(CPPA_LINUX) || defined(CPPA_POLL_IMPL)
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