Skip to content

Commit

Permalink
Add VxWorks Support
Browse files Browse the repository at this point in the history
Add vxworks option to CMakelists.txt, include the right files
for select in networking, and solve uncompatible code
  • Loading branch information
Jose Cabral authored and Pro committed Oct 17, 2017
1 parent a894e31 commit a4b80c9
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 9 deletions.
19 changes: 14 additions & 5 deletions CMakeLists.txt
Expand Up @@ -62,6 +62,8 @@ option(UA_ENABLE_AMALGAMATION "Concatenate the library to a single file open6254
option(UA_ENABLE_COVERAGE "Enable gcov coverage" OFF)
option(BUILD_SHARED_LIBS "Enable building of shared libraries (dll/so)" OFF)

set(UA_VXWORKS_WRS_KERNEL OFF CACHE BOOL "Enable if you want to compile for VxWorks as kernel Module")

if(UA_ENABLE_COVERAGE)
set(CMAKE_BUILD_TYPE DEBUG)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fprofile-arcs -ftest-coverage")
Expand Down Expand Up @@ -176,13 +178,20 @@ if(NOT UA_COMPILE_AS_CXX AND (CMAKE_COMPILER_IS_GNUCC OR "x${CMAKE_C_COMPILER_ID
-Wmultichar
-Wundef
-Wc++-compat)
if(NOT WIN32 AND NOT CYGWIN AND NOT QNXNTO)

if(NOT WIN32 AND NOT CYGWIN AND NOT QNXNTO)
add_definitions(-Wshadow -Wconversion -fvisibility=hidden -fPIC)
endif()
endif()

if(UA_ENABLE_AMALGAMATION)
add_definitions(-Wno-unused-function)
endif()
if(UA_ENABLE_AMALGAMATION)
add_definitions(-Wno-unused-function)
endif()

if(UA_VXWORKS_WRS_KERNEL)
# Disable flags for VXWORKS
remove_definitions(-Werror -Wpedantic -Wno-static-in-inline -fPIC)
add_definitions(-D_WRS_KERNEL)
endif()

# Linker
set(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "") # cmake sets -rdynamic by default
Expand Down
4 changes: 3 additions & 1 deletion include/ua_config.h.in
Expand Up @@ -44,7 +44,7 @@ extern "C" {
/**
* Standard Includes
* ----------------- */
#ifndef _XOPEN_SOURCE
#if !defined(_XOPEN_SOURCE) && !defined(_WRS_KERNEL)
# define _XOPEN_SOURCE 600
#endif
#ifndef _DEFAULT_SOURCE
Expand Down Expand Up @@ -268,6 +268,8 @@ extern "C" {
#elif defined(__FLOAT_WORD_ORDER) && defined(__LITTLE_ENDIAN) && \
(__FLOAT_WORD_ORDER == __LITTLE_ENDIAN) /* Defined only in GCC */
# define UA_BINARY_OVERLAYABLE_FLOAT 1
#elif defined(_WRS_KERNEL)
# define UA_BINARY_OVERLAYABLE_FLOAT 1
#endif

#ifndef UA_BINARY_OVERLAYABLE_FLOAT
Expand Down
11 changes: 10 additions & 1 deletion plugins/ua_network_tcp.c
Expand Up @@ -37,7 +37,12 @@
# define UA_sleep_ms(X) usleep(X * 1000)
# include <arpa/inet.h>
# include <netinet/in.h>
# include <sys/select.h>
# ifndef _WRS_KERNEL
# include <sys/select.h>
# else
# include <hostLib.h>
# include <selectLib.h>
# endif
# include <sys/ioctl.h>
# include <fcntl.h>
# include <unistd.h> // read, write, close
Expand Down Expand Up @@ -198,6 +203,10 @@ socket_set_nonblocking(SOCKET sockfd) {
u_long iMode = 1;
if(ioctlsocket(sockfd, FIONBIO, &iMode) != NO_ERROR)
return UA_STATUSCODE_BADINTERNALERROR;
#elif defined(_WRS_KERNEL)
int on = TRUE;
if(ioctl(sockfd, FIONBIO, &on) < 0)
return UA_STATUSCODE_BADINTERNALERROR;
#else
int opts = fcntl(sockfd, F_GETFL);
if(opts < 0 || fcntl(sockfd, F_SETFL, opts|O_NONBLOCK) < 0)
Expand Down
6 changes: 5 additions & 1 deletion plugins/ua_network_udp.c
Expand Up @@ -13,7 +13,11 @@
# include <errno.h> // errno, EINTR
# include <fcntl.h> // fcntl
# include <strings.h> //bzero
# include <sys/select.h>
# ifndef _WRS_KERNEL
# include <sys/select.h>
# else
# include <selectLib.h>
# endif
# include <netinet/in.h>
# include <netinet/tcp.h>
# include <sys/socketvar.h>
Expand Down
2 changes: 1 addition & 1 deletion src/ua_types_encoding_binary.c
Expand Up @@ -1107,7 +1107,7 @@ Variant_decodeBinaryUnwrapExtensionObject(UA_Variant *dst) {
if(encoding == UA_EXTENSIONOBJECT_ENCODED_BYTESTRING &&
(dst->type = UA_findDataTypeByBinary(&typeId)) != NULL) {
/* Jump over the length field (TODO: check if length matches) */
g_pos += 4;
g_pos += 4;
} else {
/* Reset and decode as ExtensionObject */
dst->type = &UA_TYPES[UA_TYPES_EXTENSIONOBJECT];
Expand Down

0 comments on commit a4b80c9

Please sign in to comment.