Skip to content

Commit

Permalink
iox-eclipse-iceoryx#33 it compiles finally; added platform dependent …
Browse files Browse the repository at this point in the history
…linking in cmake; adjusted smart_c calls since __PRETTY_FUNCTION__ works in windows only inside of functions; removed linux headers from windows platform files

Signed-off-by: Christian Eltzschig <christian.eltzschig2@de.bosch.com>
  • Loading branch information
elfenpiff committed Feb 5, 2020
1 parent e50ce57 commit 4607558
Show file tree
Hide file tree
Showing 14 changed files with 75 additions and 24 deletions.
14 changes: 11 additions & 3 deletions iceoryx_posh/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,17 @@ target_link_libraries(iceoryx_posh
PRIVATE
${CMAKE_THREAD_LIBS_INIT}
)
if(NOT CMAKE_SYSTEM_NAME MATCHES QNX)
target_link_libraries(iceoryx_posh PRIVATE rt)
endif(NOT CMAKE_SYSTEM_NAME MATCHES QNX)

if(LINUX)
target_link_libraries(iceoryx_posh PRIVATE rt )
elseif(QNX)
elseif(APPLE)
elseif(WIN32)
else()
message(WARNING "Could not detect supported platform, but I'm feeling lucky today." )
endif()



#
########## build roudi lib ##########
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "iceoryx_posh/mepoo/chunk_header.hpp"
#include "iceoryx_posh/roudi/introspection_types.hpp"
#include "iceoryx_utils/cxx/helplets.hpp"
#include "iceoryx_utils/platform/pthread.hpp"

#include <atomic>
#include <mutex>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,7 @@ class RouDiLock
~RouDiLock();

private:
int m_socket_fd =
cxx::makeSmartC(socket, cxx::ReturnMode::PRE_DEFINED_ERROR_CODE, {-1}, {}, AF_INET, SOCK_STREAM, 0)
.getReturnValue();
int m_socket_fd;
struct sockaddr_in m_sockserv;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,15 @@
#include "iceoryx_utils/cxx/optional.hpp"
#include "iceoryx_utils/internal/posix_wrapper/shared_memory_object.hpp"
#include "iceoryx_utils/internal/relocatable_pointer/relative_ptr.hpp"
#include "iceoryx_utils/platform/signal.hpp"
#include "iceoryx_utils/platform/unistd.hpp"

#include <cstdint>
#include <cstdlib>
#include <cstring>
#include <string>


namespace iox
{
namespace runtime
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#include "iceoryx_utils/platform/unistd.hpp"

#include <cstdlib>
#include <cstring>
#include <signal.h>

namespace iox
{
Expand All @@ -41,13 +36,21 @@ inline SharedMemoryCreator<ShmType>::SharedMemoryCreator(const RouDiConfig_t& co
/// @todo these are internal mempool for the introspection, move to a better place
mepoo::MePooConfig mempoolConfig;
mempoolConfig.m_mempoolConfig.push_back(
{static_cast<uint32_t>(cxx::align(static_cast<uint64_t>(sizeof(roudi::MemPoolIntrospectionTopic)), SHARED_MEMORY_ALIGNMENT)), 250});
{static_cast<uint32_t>(
cxx::align(static_cast<uint64_t>(sizeof(roudi::MemPoolIntrospectionTopic)), SHARED_MEMORY_ALIGNMENT)),
250});
mempoolConfig.m_mempoolConfig.push_back(
{static_cast<uint32_t>(cxx::align(static_cast<uint64_t>(sizeof(roudi::ProcessIntrospectionFieldTopic)), SHARED_MEMORY_ALIGNMENT)), 10});
{static_cast<uint32_t>(
cxx::align(static_cast<uint64_t>(sizeof(roudi::ProcessIntrospectionFieldTopic)), SHARED_MEMORY_ALIGNMENT)),
10});
mempoolConfig.m_mempoolConfig.push_back(
{static_cast<uint32_t>(cxx::align(static_cast<uint64_t>(sizeof(roudi::PortIntrospectionFieldTopic)), SHARED_MEMORY_ALIGNMENT)), 10});
{static_cast<uint32_t>(
cxx::align(static_cast<uint64_t>(sizeof(roudi::PortIntrospectionFieldTopic)), SHARED_MEMORY_ALIGNMENT)),
10});
mempoolConfig.m_mempoolConfig.push_back(
{static_cast<uint32_t>(cxx::align(static_cast<uint64_t>(sizeof(roudi::PortThroughputIntrospectionFieldTopic)), SHARED_MEMORY_ALIGNMENT)), 10});
{static_cast<uint32_t>(cxx::align(static_cast<uint64_t>(sizeof(roudi::PortThroughputIntrospectionFieldTopic)),
SHARED_MEMORY_ALIGNMENT)),
10});
mempoolConfig.optimize();

uint64_t totalSharedMemorySize = ShmType::getRequiredSharedMemory()
Expand All @@ -63,7 +66,7 @@ inline SharedMemoryCreator<ShmType>::SharedMemoryCreator(const RouDiConfig_t& co
newAct.sa_handler = sigbusHandler;
newAct.sa_flags = 0;
sigaction(SIGBUS, &newAct, &oldAct);

// we let the OS decide where to map the shm segments
constexpr void* BASE_ADDRESS_HINT{nullptr};

Expand Down
2 changes: 2 additions & 0 deletions iceoryx_posh/source/roudi/roudi_lock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ namespace iox
namespace roudi
{
RouDiLock::RouDiLock()
: m_socket_fd(cxx::makeSmartC(socket, cxx::ReturnMode::PRE_DEFINED_ERROR_CODE, {-1}, {}, AF_INET, SOCK_STREAM, 0)
.getReturnValue())
{
if (m_socket_fd == -1)
{
Expand Down
6 changes: 1 addition & 5 deletions iceoryx_utils/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ add_library(iceoryx_utils::iceoryx_utils ALIAS iceoryx_utils)

if(LINUX)
set(ICEORYX_PLATFORM_INCLUDES ${CMAKE_CURRENT_SOURCE_DIR}/platform/linux/include/)
target_link_libraries(iceoryx_utils PRIVATE rt acl ${CODE_COVERAGE_LIBS})
target_link_libraries(iceoryx_utils PRIVATE rt acl atomic ${CODE_COVERAGE_LIBS})
elseif(QNX)
set(ICEORYX_PLATFORM_INCLUDES ${CMAKE_CURRENT_SOURCE_DIR}/platform/qnx/include/)
elseif(APPLE)
Expand All @@ -189,10 +189,6 @@ target_include_directories(iceoryx_utils
target_compile_options(iceoryx_utils PUBLIC -std=c++11)
target_compile_options(iceoryx_utils PUBLIC -fPIC)

if(NOT CMAKE_SYSTEM_NAME MATCHES QNX)
target_link_libraries(iceoryx_utils PRIVATE acl atomic rt ${CODE_COVERAGE_LIBS})
endif(NOT CMAKE_SYSTEM_NAME MATCHES QNX)

set_target_properties(iceoryx_utils
PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}"
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,3 @@
// limitations under the License.

#pragma once

#include <arpa/inet.h>
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
// compiles
//#pragma once


#ifndef __PRETTY_FUNCTION__
#define __PRETTY_FUNCTION__ __FUNCSIG__
#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,16 @@

#pragma once

#include <thread>

#define PTHREAD_PROCESS_SHARED 0
#define PTHREAD_MUTEX_RECURSIVE_NP 1
#define PTHREAD_MUTEX_FAST_NP 2
#define PTHREAD_PRIO_NONE 3

using pthread_mutex_t = int;
using pthread_mutexattr_t = int;
using pthread_t = int;
using pthread_t = std::thread::native_handle_type;

inline int pthread_setname_np(pthread_t thread, const char* name)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@
#include <cstdlib>
#include <stdio.h>
#include <type_traits>

#define _WINSOCKAPI_
#define WIN32_LEAN_AND_MEAN

#include <windows.h>

#define SEM_FAILED 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@
#include <signal.h>

#define SIGEV_THREAD 0
#define SIGBUS 1

using sigset_t = int;
using siginfo_t = int;

union sigval
{
Expand All @@ -36,3 +40,28 @@ struct sigevent
void* sigev_notify_attributes;
pid_t sigev_notify_thread_id;
};

struct sigaction
{
void (*sa_handler)(int);
void (*sa_sigaction)(int, siginfo_t*, void*);
sigset_t sa_mask;
int sa_flags;
void (*sa_restorer)(void);
};


inline int sigemptyset(sigset_t* set)
{
return 0;
}

inline int sigaction(int signum, const struct sigaction* act, struct sigaction* oldact)
{
return 0;
}

inline int kill(pid_t pid, int sig)
{
return 0;
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@

#pragma once

#include "iceoryx_utils/platform/platform-correction.hpp"
#include "iceoryx_utils/platform/types.hpp"

#define AF_INET 0
#define SOCK_STREAM 1
#define SOL_SOCKET 2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include <io.h>

#define _SC_PAGESIZE 1
#define STDERR_FILENO 2

inline int ftruncate(int fildes, off_t length)
{
Expand Down

0 comments on commit 4607558

Please sign in to comment.