Explorar el Código

Add VxWorks Support

Add vxworks option to CMakelists.txt, include the right files
for select in networking, and solve uncompatible code
Jose Cabral hace 7 años
padre
commit
8cfce19a03
Se han modificado 5 ficheros con 33 adiciones y 9 borrados
  1. 14 5
      CMakeLists.txt
  2. 3 1
      include/ua_config.h.in
  3. 10 1
      plugins/ua_network_tcp.c
  4. 5 1
      plugins/ua_network_udp.c
  5. 1 1
      src/ua_types_encoding_binary.c

+ 14 - 5
CMakeLists.txt

@@ -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")
@@ -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

+ 3 - 1
include/ua_config.h.in

@@ -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
@@ -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

+ 10 - 1
plugins/ua_network_tcp.c

@@ -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
@@ -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)

+ 5 - 1
plugins/ua_network_udp.c

@@ -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>

+ 1 - 1
src/ua_types_encoding_binary.c

@@ -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];