This repository has been archived by the owner on Apr 6, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 133
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* start port to windows. now compile but code need to be improve to ensure better separation between unix & windows parts. cpp_redis tests do not pass for now. * reorganize repository to separate windows and unix code * windows compilation after code reorganization * small timeout on WSAPoll, use windows versions of POLLIN POLLOUt * fix unix compilation & listen to PULLHUP event * fix io_service causing idle when waiting for sockets to be removed. Set WSAPoll timeout to -1. Clean code * unix compilation warning fix && clang-format * port windows fix to unix (io_service idle / POLLHUP / ...) * update cmakelist for windows cpp_redis integration * fix Cmake warnings under unix (cpp_redis integration) * install_deps update * try fix travis * try fix travis * fix cmakelist * fix cmakelist * fix cmakelist
- Loading branch information
Showing
16 changed files
with
924 additions
and
106 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
# The MIT License (MIT) | ||
# | ||
# Copyright (c) 2015-2017 Simon Ninon <[email protected]> | ||
# Copyright (c) 2016-2017 Simon Ninon <[email protected]> | ||
# | ||
# Permission is hereby granted, free of charge, to any person obtaining a copy | ||
# of this software and associated documentation files (the "Software"), to deal | ||
|
@@ -43,19 +43,29 @@ project(${PROJECT} CXX) | |
### | ||
# compilation options | ||
### | ||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -W -Wall -Wextra -O3") | ||
IF (WIN32) | ||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W3 /O2") | ||
|
||
# was causing conflics with gtest build | ||
string(REPLACE "/RTC1" "" CMAKE_CXX_FLAGS_DEBUG ${CMAKE_CXX_FLAGS_DEBUG}) | ||
foreach (flag_var CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE) | ||
string(REPLACE "/MD" "-MT" ${flag_var} "${${flag_var}}") | ||
endforeach() | ||
|
||
add_definitions(-D_UNICODE) | ||
add_definitions(-DUNICODE) | ||
add_definitions(-DWIN32_LEAN_AND_MEAN) | ||
ELSE () | ||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -W -Wall -Wextra -O3") | ||
ENDIF (WIN32) | ||
|
||
|
||
### | ||
# variables | ||
### | ||
set(DEPS_FOLDER ${PROJECT_SOURCE_DIR}/deps/build) | ||
IF (NOT GTEST_INCLUDES) | ||
set(GTEST_INCLUDES ${DEPS_FOLDER}/gtest/include) | ||
set(GTEST_INCLUDES ${PROJECT_SOURCE_DIR}/deps/src/googletest/googletest/include) | ||
ENDIF (NOT GTEST_INCLUDES) | ||
IF (NOT GTEST_LIBS) | ||
set(GTEST_LIBS ${DEPS_FOLDER}/gtest/lib) | ||
ENDIF (NOT GTEST_LIBS) | ||
set(TACOPIE_INCLUDES ${PROJECT_SOURCE_DIR}/includes) | ||
|
||
|
||
|
@@ -64,17 +74,17 @@ set(TACOPIE_INCLUDES ${PROJECT_SOURCE_DIR}/includes) | |
### | ||
include_directories(${TACOPIE_INCLUDES}) | ||
|
||
|
||
### | ||
# link | ||
### | ||
link_directories(${GTEST_LIBS}) | ||
|
||
|
||
### | ||
# sources | ||
### | ||
set(SRC_DIRS "sources" "sources/network" "sources/utils" "includes/tacopie" "includes/tacopie/network" "includes/tacopie/utils") | ||
|
||
IF (WIN32) | ||
set(SRC_DIRS ${SRC_DIRS} "sources/network/windows" "includes/tacopie/network/windows") | ||
ELSE () | ||
set(SRC_DIRS ${SRC_DIRS} "sources/network/unix" "includes/tacopie/network/unix") | ||
ENDIF (WIN32) | ||
|
||
foreach(dir ${SRC_DIRS}) | ||
# get directory sources and headers | ||
file(GLOB s_${dir} "${dir}/*.cpp") | ||
|
@@ -98,7 +108,12 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) | |
# executable | ||
### | ||
add_library(${PROJECT} STATIC ${SOURCES}) | ||
target_link_libraries(${PROJECT} pthread) | ||
|
||
IF (WIN32) | ||
target_link_libraries(${PROJECT} ws2_32) | ||
ELSE () | ||
target_link_libraries(${PROJECT} pthread) | ||
ENDIF (WIN32) | ||
|
||
# __TACOPIE_LOGGING_ENABLED | ||
IF (LOGGING_ENABLED) | ||
|
@@ -137,4 +152,7 @@ ENDIF(BUILD_EXAMPLES) | |
### | ||
IF (BUILD_TESTS) | ||
add_subdirectory(tests) | ||
IF (EXISTS ${PROJECT_SOURCE_DIR}/deps/src/googletest) | ||
add_subdirectory(${PROJECT_SOURCE_DIR}/deps/src/googletest) | ||
ENDIF () | ||
ENDIF(BUILD_TESTS) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
// MIT License | ||
// | ||
// Copyright (c) 2016-2017 Simon Ninon <[email protected]> | ||
// | ||
// Permission is hereby granted, free of charge, to any person obtaining a copy | ||
// of this software and associated documentation files (the "Software"), to deal | ||
// in the Software without restriction, including without limitation the rights | ||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
// copies of the Software, and to permit persons to whom the Software is | ||
// furnished to do so, subject to the following conditions: | ||
// | ||
// The above copyright notice and this permission notice shall be included in all | ||
// copies or substantial portions of the Software. | ||
// | ||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
// SOFTWARE. | ||
|
||
#pragma once | ||
|
||
#include <tacopie/typedefs.hpp> | ||
|
||
namespace tacopie { | ||
|
||
class self_pipe { | ||
public: | ||
//! ctor & dtor | ||
self_pipe(void); | ||
~self_pipe(void); | ||
|
||
//! copy ctor & assignment operator | ||
self_pipe(const self_pipe&) = delete; | ||
self_pipe& operator=(const self_pipe&) = delete; | ||
|
||
public: | ||
//! get rd/wr fds | ||
fd_t get_read_fd(void) const; | ||
fd_t get_write_fd(void) const; | ||
|
||
//! notify | ||
void notify(void); | ||
|
||
//! clr buffer | ||
void clr_buffer(void); | ||
|
||
private: | ||
#ifdef _WIN32 | ||
fd_t m_fd; | ||
struct sockaddr m_addr; | ||
int m_addr_len; | ||
#else | ||
fd_t m_fds[2]; | ||
#endif /* _WIN32 */ | ||
}; | ||
|
||
} //! tacopie |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.