Przeglądaj źródła

Split architecture related functions to separated folder

Jose Cabral 7 lat temu
rodzic
commit
108fcddbba

+ 50 - 38
CMakeLists.txt

@@ -40,7 +40,6 @@ if(NOT OPEN62541_VER_COMMIT OR OPEN62541_VER_COMMIT STREQUAL "")
     set(OPEN62541_VER_COMMIT "undefined")
     set(OPEN62541_VER_COMMIT "undefined")
 endif()
 endif()
 
 
-add_subdirectory(plugins)
 
 
 #################
 #################
 # Build Options #
 # Build Options #
@@ -52,6 +51,36 @@ if(NOT CMAKE_BUILD_TYPE)
     set(CMAKE_BUILD_TYPE "Debug" CACHE STRING "Choose the type of build" FORCE)
     set(CMAKE_BUILD_TYPE "Debug" CACHE STRING "Choose the type of build" FORCE)
 endif()
 endif()
 
 
+# Platform. This is at the beginning in case the architecture changes some UA options
+set(UA_ARCHITECTURE "None" CACHE STRING "Architecture to build open62541 on")
+
+if(${UA_ARCHITECTURE} STREQUAL "None")
+  if(UNIX)
+    set(UA_ARCHITECTURE "posix" CACHE STRING "" FORCE)
+  elseif(WIN32)  
+    set(UA_ARCHITECTURE "win32" CACHE STRING ""  FORCE)
+  endif(UNIX)
+endif(${UA_ARCHITECTURE} STREQUAL "None")
+
+message(STATUS "The selected architecture is ${UA_ARCHITECTURE}")
+
+add_subdirectory(plugins)
+
+GET_PROPERTY(architectures GLOBAL PROPERTY UA_ARCHITECTURES)
+list(SORT architectures)
+set_property(CACHE UA_ARCHITECTURE PROPERTY STRINGS None ${architectures})
+
+GET_PROPERTY(ua_directories_to_include GLOBAL PROPERTY UA_INCLUDE_DIRECTORIES)
+include_directories(${ua_directories_to_include})
+
+GET_PROPERTY(ua_architecture_headers GLOBAL PROPERTY UA_ARCHITECTURE_HEADERS)
+
+GET_PROPERTY(ua_architecture_sources GLOBAL PROPERTY UA_ARCHITECTURE_SOURCES)
+
+if(${UA_ARCHITECTURE} STREQUAL "None")
+  message(FATAL_ERROR "No architecture was selected. Please select the architecture of your target platform")
+endif(${UA_ARCHITECTURE} STREQUAL "None")
+
 # Options
 # Options
 set(UA_LOGLEVEL 300 CACHE STRING "Level at which logs shall be reported")
 set(UA_LOGLEVEL 300 CACHE STRING "Level at which logs shall be reported")
 option(UA_ENABLE_METHODCALLS "Enable the Method service set" ON)
 option(UA_ENABLE_METHODCALLS "Enable the Method service set" ON)
@@ -63,15 +92,6 @@ option(UA_ENABLE_AMALGAMATION "Concatenate the library to a single file open6254
 option(UA_ENABLE_COVERAGE "Enable gcov coverage" OFF)
 option(UA_ENABLE_COVERAGE "Enable gcov coverage" OFF)
 option(BUILD_SHARED_LIBS "Enable building of shared libraries (dll/so)" OFF)
 option(BUILD_SHARED_LIBS "Enable building of shared libraries (dll/so)" OFF)
 
 
-# Platform
-set(UA_ARCHITECTURE "None" CACHE STRING "Architecture to build open62541 on")
-GET_PROPERTY(architectures GLOBAL PROPERTY UA_ARCHITECTURES)
-list(SORT architectures)
-set_property(CACHE UA_ARCHITECTURE PROPERTY STRINGS None ${architectures})
-
-GET_PROPERTY(directoriesToInclude GLOBAL PROPERTY UA_INCLUDE_DIRECTORIES)
-include_directories(${directoriesToInclude})
-
 # Encryption Options
 # Encryption Options
 option(UA_ENABLE_ENCRYPTION "Enable encryption support (uses mbedTLS)" OFF)
 option(UA_ENABLE_ENCRYPTION "Enable encryption support (uses mbedTLS)" OFF)
 
 
@@ -141,12 +161,6 @@ option(UA_ENABLE_UNIT_TEST_FAILURE_HOOKS
        "Add hooks to force failure modes for additional unit tests. Not for production use!" OFF)
        "Add hooks to force failure modes for additional unit tests. Not for production use!" OFF)
 mark_as_advanced(UA_ENABLE_UNIT_TEST_FAILURE_HOOKS)
 mark_as_advanced(UA_ENABLE_UNIT_TEST_FAILURE_HOOKS)
 
 
-set(UA_VXWORKS_WRS_KERNEL OFF CACHE BOOL "Enable if you want to compile for VxWorks as kernel Module")
-mark_as_advanced(UA_VXWORKS_WRS_KERNEL)
-
-set(UA_FREERTOS OFF CACHE BOOL "Enable if you want to compile for freeRTOS")
-mark_as_advanced(UA_FREERTOS)
-
 set(UA_VALGRIND_INTERACTIVE_INTERVAL 1000 CACHE STRING "The number of iterations to wait before creating the next dump")
 set(UA_VALGRIND_INTERACTIVE_INTERVAL 1000 CACHE STRING "The number of iterations to wait before creating the next dump")
 mark_as_advanced(UA_VALGRIND_INTERACTIVE_INTERVAL)
 mark_as_advanced(UA_VALGRIND_INTERACTIVE_INTERVAL)
 
 
@@ -266,22 +280,6 @@ if(NOT UA_COMPILE_AS_CXX AND (CMAKE_COMPILER_IS_GNUCC OR "x${CMAKE_C_COMPILER_ID
         add_definitions(-Wno-unused-function)
         add_definitions(-Wno-unused-function)
     endif()
     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()
-
-    if(UA_FREERTOS)
-       SET(UA_FREERTOS_INCLUDES "" CACHE STRING "Folders to include from the freeRTOS OS")
-       include_directories(${UA_FREERTOS_INCLUDES})
-        # Disable flags for freeRTOS
-        remove_definitions(-fPIC -Wconversion )
-        add_definitions(-DUA_FREERTOS -DLWIP_TIMEVAL_PRIVATE=0 -DLWIP_COMPAT_MUTEX=0 -DLWIP_POSIX_SOCKETS_IO_NAMES=0 -mcpu=cortex-m3 -mthumb -g -Wall -O0 -specs=nano.specs
-                        -ffunction-sections -fdata-sections  -fno-exceptions -fstack-usage -Wno-unused-variable -Wno-format -Wno-format-security -Wno-format-nonliteral)
-        list(APPEND open62541_LIBRARIES c m stdc++ supc++)
-    endif(UA_FREERTOS)
-
     # Linker
     # Linker
     set(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "") # cmake sets -rdynamic by default
     set(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "") # cmake sets -rdynamic by default
 
 
@@ -615,17 +613,17 @@ add_custom_command(OUTPUT ${PROJECT_BINARY_DIR}/open62541.h
                    PRE_BUILD
                    PRE_BUILD
                    COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/tools/amalgamate.py
                    COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/tools/amalgamate.py
                            ${OPEN62541_VER_COMMIT} ${CMAKE_CURRENT_BINARY_DIR}/open62541.h
                            ${OPEN62541_VER_COMMIT} ${CMAKE_CURRENT_BINARY_DIR}/open62541.h
-                           ${exported_headers} ${default_plugin_headers}
+                           ${exported_headers} ${default_plugin_headers} ${ua_architecture_headers}
                    DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/tools/amalgamate.py
                    DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/tools/amalgamate.py
-                           ${exported_headers} ${default_plugin_headers})
+                           ${exported_headers} ${default_plugin_headers} ${ua_architecture_headers})
 
 
 add_custom_command(OUTPUT ${PROJECT_BINARY_DIR}/open62541.c
 add_custom_command(OUTPUT ${PROJECT_BINARY_DIR}/open62541.c
                    PRE_BUILD
                    PRE_BUILD
                    COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/tools/amalgamate.py
                    COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/tools/amalgamate.py
                            ${OPEN62541_VER_COMMIT} ${CMAKE_CURRENT_BINARY_DIR}/open62541.c
                            ${OPEN62541_VER_COMMIT} ${CMAKE_CURRENT_BINARY_DIR}/open62541.c
-                           ${internal_headers} ${lib_sources} ${default_plugin_sources}
+                           ${internal_headers} ${lib_sources} ${default_plugin_sources} ${ua_architecture_sources}
                    DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/tools/amalgamate.py ${internal_headers}
                    DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/tools/amalgamate.py ${internal_headers}
-                           ${lib_sources} ${default_plugin_sources})
+                           ${lib_sources} ${default_plugin_sources} ${ua_architecture_sources})
 
 
 add_custom_target(open62541-amalgamation-source DEPENDS ${PROJECT_BINARY_DIR}/open62541.c)
 add_custom_target(open62541-amalgamation-source DEPENDS ${PROJECT_BINARY_DIR}/open62541.c)
 add_custom_target(open62541-amalgamation-header DEPENDS ${PROJECT_BINARY_DIR}/open62541.h)
 add_custom_target(open62541-amalgamation-header DEPENDS ${PROJECT_BINARY_DIR}/open62541.h)
@@ -679,6 +677,7 @@ assign_source_group(${lib_sources})
 assign_source_group(${internal_headers})
 assign_source_group(${internal_headers})
 assign_source_group(${exported_headers})
 assign_source_group(${exported_headers})
 assign_source_group(${default_plugin_sources})
 assign_source_group(${default_plugin_sources})
+assign_source_group(${ua_architecture_sources})
 
 
 if(UA_ENABLE_AMALGAMATION)
 if(UA_ENABLE_AMALGAMATION)
     add_library(open62541-object OBJECT ${PROJECT_BINARY_DIR}/open62541.c ${PROJECT_BINARY_DIR}/open62541.h)
     add_library(open62541-object OBJECT ${PROJECT_BINARY_DIR}/open62541.c ${PROJECT_BINARY_DIR}/open62541.h)
@@ -709,7 +708,7 @@ else()
                      open62541-generator-statuscode)
                      open62541-generator-statuscode)
     target_include_directories(open62541-object PRIVATE ${PROJECT_SOURCE_DIR}/src)
     target_include_directories(open62541-object PRIVATE ${PROJECT_SOURCE_DIR}/src)
 
 
-    add_library(open62541-plugins OBJECT ${default_plugin_sources} ${exported_headers})
+    add_library(open62541-plugins OBJECT ${default_plugin_sources} ${ua_architecture_sources} ${exported_headers})
     add_dependencies(open62541-plugins open62541-generator-types open62541-generator-transport)
     add_dependencies(open62541-plugins open62541-generator-types open62541-generator-transport)
     target_include_directories(open62541-plugins PRIVATE ${PROJECT_SOURCE_DIR}/plugins)
     target_include_directories(open62541-plugins PRIVATE ${PROJECT_SOURCE_DIR}/plugins)
     target_include_directories(open62541-plugins PRIVATE ${PROJECT_BINARY_DIR}/src_generated)
     target_include_directories(open62541-plugins PRIVATE ${PROJECT_BINARY_DIR}/src_generated)
@@ -720,7 +719,7 @@ else()
 
 
     if(UA_COMPILE_AS_CXX)
     if(UA_COMPILE_AS_CXX)
         set_source_files_properties(${lib_sources} PROPERTIES LANGUAGE CXX)
         set_source_files_properties(${lib_sources} PROPERTIES LANGUAGE CXX)
-        set_source_files_properties(${default_plugin_sources} PROPERTIES LANGUAGE CXX)
+        set_source_files_properties(${default_plugin_sources} ${ua_architecture_sources} PROPERTIES LANGUAGE CXX)
     endif()
     endif()
 endif()
 endif()
 
 
@@ -892,3 +891,16 @@ set_target_properties(open62541-generator-namespace PROPERTIES FOLDER "open62541
 set_target_properties(open62541-generator-statuscode PROPERTIES FOLDER "open62541/generators")
 set_target_properties(open62541-generator-statuscode PROPERTIES FOLDER "open62541/generators")
 set_target_properties(open62541-generator-transport PROPERTIES FOLDER "open62541/generators")
 set_target_properties(open62541-generator-transport PROPERTIES FOLDER "open62541/generators")
 set_target_properties(open62541-generator-types PROPERTIES FOLDER "open62541/generators")
 set_target_properties(open62541-generator-types PROPERTIES FOLDER "open62541/generators")
+
+##################################
+#     Architectures changes      #
+##################################
+
+GET_PROPERTY(ua_architecture_add_definitions GLOBAL PROPERTY UA_ARCHITECTURE_ADD_DEFINITIONS)
+add_definitions(${ua_architecture_add_definitions})
+
+GET_PROPERTY(ua_architecture_remove_definitions GLOBAL PROPERTY UA_ARCHITECTURE_REMOVE_DEFINITIONS)
+remove_definitions(${ua_architecture_remove_definitions})
+
+GET_PROPERTY(ua_architecture_append_to_library GLOBAL PROPERTY UA_ARCHITECTURE_APPEND_TO_LIBRARY)
+list(APPEND open62541_LIBRARIES ${ua_architecture_append_to_library})

+ 3 - 1
plugins/arch/CMakeLists.txt

@@ -2,4 +2,6 @@ SET(SOURCE_GROUP ${SOURCE_GROUP}\\arch)
 
 
 add_subdirectory(posix)
 add_subdirectory(posix)
 add_subdirectory(win32)
 add_subdirectory(win32)
-add_subdirectory(arduino)
+add_subdirectory(arduino)
+add_subdirectory(freertos)
+add_subdirectory(vxworks)

+ 18 - 0
plugins/arch/freertos/CMakeLists.txt

@@ -0,0 +1,18 @@
+SET(SOURCE_GROUP ${SOURCE_GROUP}\\freertos)
+
+ua_add_architecture("freertos")
+
+if("${UA_ARCHITECTURE}" STREQUAL "freertos")
+
+    ua_include_directories(${CMAKE_CURRENT_SOURCE_DIR})
+    ua_add_architecture_header(${CMAKE_CURRENT_SOURCE_DIR}/ua_architecture.h)
+    
+    SET(UA_FREERTOS_INCLUDES "" CACHE STRING "Folders to include from the freeRTOS OS")
+    ua_include_directories(${UA_FREERTOS_INCLUDES})
+    
+    ua_architecture_remove_definitions(-fPIC -Wconversion )
+    ua_architecture_add_definitions(-DUA_FREERTOS -mcpu=cortex-m3 -mthumb -g -Wall -O0 -specs=nano.specs 
+                -ffunction-sections -fdata-sections  -fno-exceptions -fstack-usage -Wno-unused-variable -Wno-format -Wno-format-security -Wno-format-nonliteral)
+    ua_architecture_append_to_library(c m stdc++ supc++)
+
+endif()

+ 71 - 0
plugins/arch/freertos/ua_architecture.h

@@ -0,0 +1,71 @@
+/* This work is licensed under a Creative Commons CCZero 1.0 Universal License.
+ * See http://creativecommons.org/publicdomain/zero/1.0/ for more information.
+ *
+ *    Copyright 2016-2017 (c) Julius Pfrommer, Fraunhofer IOSB
+ *    Copyright 2017 (c) Stefan Profanter, fortiss GmbH
+ */
+
+#ifndef PLUGINS_ARCH_FREERTOS_UA_ARCHITECTURE_H_
+#define PLUGINS_ARCH_FREERTOS_UA_ARCHITECTURE_H_
+
+
+//------------------------------------------------------------------
+// NOT WORKING YET!!!!!!!!!!!!!!!!!!!!!
+//------------------------------------------------------------------
+
+
+/*
+ * Set LWIP_COMPAT_SOCKETS to 2 in lwipoptions.h
+ */
+
+
+#define AI_PASSIVE 0x01
+#define TRUE 1
+#define FALSE 0
+#define ioctl ioctlsocket
+
+#define UA_FREERTOS_HOSTNAME "10.200.4.114"
+
+#include <stdlib.h>
+#include <string.h>
+
+static inline int gethostname_freertos(char* name, size_t len){
+  if(strlen(UA_FREERTOS_HOSTNAME) > (len))
+    return -1;
+  strcpy(name, UA_FREERTOS_HOSTNAME);
+  return 0;
+}
+#define gethostname gethostname_freertos
+
+#define LWIP_TIMEVAL_PRIVATE 0
+#define LWIP_COMPAT_MUTEX 0
+#define LWIP_POSIX_SOCKETS_IO_NAMES 0
+//#define __USE_W32_SOCKETS 1 //needed to avoid redefining of select in sys/select.h
+
+#include <lwip/tcpip.h>
+#include <lwip/netdb.h>
+#define CLOSESOCKET(S) lwip_close(S)
+#define sockaddr_storage sockaddr
+#ifdef BYTE_ORDER
+# undef BYTE_ORDER
+#endif
+#define UA_sleep_ms(X) vTaskDelay(pdMS_TO_TICKS(X))
+
+#define SOCKET int
+#define WIN32_INT
+#define OPTVAL_TYPE int
+#define ERR_CONNECTION_PROGRESS EINPROGRESS
+
+
+//# include <fcntl.h>
+# include <unistd.h> // read, write, close
+
+# define UA_fd_set(fd, fds) FD_SET((unsigned int)fd, fds)
+# define UA_fd_isset(fd, fds) FD_ISSET((unsigned int)fd, fds)
+
+#define errno__ errno
+#define INTERRUPTED EINTR
+#define WOULDBLOCK EWOULDBLOCK
+#define AGAIN EAGAIN
+
+#endif /* PLUGINS_ARCH_FREERTOS_UA_ARCHITECTURE_H_ */

+ 1 - 0
plugins/arch/posix/CMakeLists.txt

@@ -5,5 +5,6 @@ ua_add_architecture("posix")
 if("${UA_ARCHITECTURE}" STREQUAL "posix")
 if("${UA_ARCHITECTURE}" STREQUAL "posix")
 
 
 ua_include_directories(${CMAKE_CURRENT_SOURCE_DIR})
 ua_include_directories(${CMAKE_CURRENT_SOURCE_DIR})
+ua_add_architecture_header(${CMAKE_CURRENT_SOURCE_DIR}/ua_architecture.h)
 
 
 endif()
 endif()

+ 26 - 64
plugins/arch/posix/ua_architecture.h

@@ -9,7 +9,7 @@
 #define PLUGINS_ARCH_POSIX_UA_ARCHITECTURE_H_
 #define PLUGINS_ARCH_POSIX_UA_ARCHITECTURE_H_
 
 
 /* Enable POSIX features */
 /* Enable POSIX features */
-#if !defined(_XOPEN_SOURCE) && !defined(_WRS_KERNEL)
+#if !defined(_XOPEN_SOURCE)
 # define _XOPEN_SOURCE 600
 # define _XOPEN_SOURCE 600
 #endif
 #endif
 #ifndef _DEFAULT_SOURCE
 #ifndef _DEFAULT_SOURCE
@@ -21,75 +21,37 @@
 # define _BSD_SOURCE
 # define _BSD_SOURCE
 #endif
 #endif
 
 
-#if !defined(UA_FREERTOS)
-# include <errno.h>
-#else
-# define AI_PASSIVE 0x01
-# define TRUE 1
-# define FALSE 0
-# define ioctl ioctlsocket
-#endif
+#include <errno.h>
 
 
-# if defined(UA_FREERTOS)
-#  define UA_FREERTOS_HOSTNAME "10.200.4.114"
-static inline int gethostname_freertos(char* name, size_t len){
-  if(strlen(UA_FREERTOS_HOSTNAME) > (len))
-    return -1;
-  strcpy(name, UA_FREERTOS_HOSTNAME);
-  return 0;
-}
-#define gethostname gethostname_freertos
-#  include <lwip/tcpip.h>
-#  include <lwip/netdb.h>
-#  define CLOSESOCKET(S) lwip_close(S)
-#  define sockaddr_storage sockaddr
-#  ifdef BYTE_ORDER
-#   undef BYTE_ORDER
-#  endif
-#  define UA_sleep_ms(X) vTaskDelay(pdMS_TO_TICKS(X))
-# else /* Not freeRTOS */
-#  define CLOSESOCKET(S) close(S)
-#  include <arpa/inet.h>
-#  include <netinet/in.h>
-#  include <netdb.h>
-#  include <sys/ioctl.h>
-#  if defined(_WRS_KERNEL)
-#   include <hostLib.h>
-#   include <selectLib.h>
-#   define UA_sleep_ms(X)                            \
-    {                                                \
-    struct timespec timeToSleep;                     \
-      timeToSleep.tv_sec = X / 1000;                 \
-      timeToSleep.tv_nsec = 1000000 * (X % 1000);    \
-      nanosleep(&timeToSleep, NULL);                 \
-    }
-#  else /* defined(_WRS_KERNEL) */
-#   include <sys/select.h>
-#   define UA_sleep_ms(X) usleep(X * 1000)
-#  endif /* defined(_WRS_KERNEL) */
-# endif /* Not freeRTOS */
+#define CLOSESOCKET(S) close(S)
+#include <arpa/inet.h>
+#include <netinet/in.h>
+#include <netdb.h>
+#include <sys/ioctl.h>
+# include <sys/select.h>
+# define UA_sleep_ms(X) usleep(X * 1000)
 
 
-# define SOCKET int
-# define WIN32_INT
-# define OPTVAL_TYPE int
-# define ERR_CONNECTION_PROGRESS EINPROGRESS
+#define SOCKET int
+#define WIN32_INT
+#define OPTVAL_TYPE int
+#define ERR_CONNECTION_PROGRESS EINPROGRESS
 
 
 
 
-# include <fcntl.h>
-# include <unistd.h> // read, write, close
+#include <fcntl.h>
+#include <unistd.h> // read, write, close
 
 
-# ifdef __QNX__
-#  include <sys/socket.h>
-# endif
-# if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__))
-#  include <sys/param.h>
-#  if defined(BSD)
-#   include<sys/socket.h>
-#  endif
-# endif
-# if !defined(__CYGWIN__) && !defined(UA_FREERTOS)
-#  include <netinet/tcp.h>
+#ifdef __QNX__
+# include <sys/socket.h>
+#endif
+#if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__))
+# include <sys/param.h>
+# if defined(BSD)
+#  include<sys/socket.h>
 # endif
 # endif
+#endif
+#if !defined(__CYGWIN__)
+# include <netinet/tcp.h>
+#endif
 
 
 /* unsigned int for windows and workaround to a glibc bug */
 /* unsigned int for windows and workaround to a glibc bug */
 /* Additionally if GNU_LIBRARY is not defined, it may be using
 /* Additionally if GNU_LIBRARY is not defined, it may be using

+ 13 - 0
plugins/arch/vxworks/CMakeLists.txt

@@ -0,0 +1,13 @@
+SET(SOURCE_GROUP ${SOURCE_GROUP}\\vxworks)
+
+ua_add_architecture("vxworks")
+
+if("${UA_ARCHITECTURE}" STREQUAL "vxworks")
+
+    ua_include_directories(${CMAKE_CURRENT_SOURCE_DIR})
+    ua_add_architecture_header(${CMAKE_CURRENT_SOURCE_DIR}/ua_architecture.h)
+    
+    ua_architecture_remove_definitions(-Werror -Wpedantic -Wno-static-in-inline -fPIC)
+    ua_architecture_add_definitions(-D_WRS_KERNEL)
+    
+endif()

+ 48 - 0
plugins/arch/vxworks/ua_architecture.h

@@ -0,0 +1,48 @@
+/* This work is licensed under a Creative Commons CCZero 1.0 Universal License.
+ * See http://creativecommons.org/publicdomain/zero/1.0/ for more information.
+ *
+ *    Copyright 2016-2017 (c) Julius Pfrommer, Fraunhofer IOSB
+ *    Copyright 2017 (c) Stefan Profanter, fortiss GmbH
+ */
+
+#ifndef PLUGINS_ARCH_VXWORKS_UA_ARCHITECTURE_H_
+#define PLUGINS_ARCH_VXWORKS_UA_ARCHITECTURE_H_
+
+#include <../deps/queue.h>  //in some compilers there's already a _SYS_QUEUE_H_ who is included first and doesn't have all functions
+
+#include <errno.h>
+
+#define CLOSESOCKET(S) close(S)
+#include <arpa/inet.h>
+#include <netinet/in.h>
+#include <netdb.h>
+#include <sys/ioctl.h>
+
+#include <hostLib.h>
+#include <selectLib.h>
+#define UA_sleep_ms(X)                            \
+ {                                                \
+ struct timespec timeToSleep;                     \
+   timeToSleep.tv_sec = X / 1000;                 \
+   timeToSleep.tv_nsec = 1000000 * (X % 1000);    \
+   nanosleep(&timeToSleep, NULL);                 \
+ }
+
+#define SOCKET int
+#define WIN32_INT
+#define OPTVAL_TYPE int
+#define ERR_CONNECTION_PROGRESS EINPROGRESS
+
+#include <fcntl.h>
+#include <unistd.h> // read, write, close
+#include <netinet/tcp.h>
+
+#define UA_fd_set(fd, fds) FD_SET((unsigned int)fd, fds)
+#define UA_fd_isset(fd, fds) FD_ISSET((unsigned int)fd, fds)
+
+#define errno__ errno
+#define INTERRUPTED EINTR
+#define WOULDBLOCK EWOULDBLOCK
+#define AGAIN EAGAIN
+
+#endif /* PLUGINS_ARCH_VXWORKS_UA_ARCHITECTURE_H_ */

+ 1 - 0
plugins/arch/win32/CMakeLists.txt

@@ -5,5 +5,6 @@ ua_add_architecture("win32")
 if("${UA_ARCHITECTURE}" STREQUAL "win32")
 if("${UA_ARCHITECTURE}" STREQUAL "win32")
 
 
 ua_include_directories(${CMAKE_CURRENT_SOURCE_DIR})
 ua_include_directories(${CMAKE_CURRENT_SOURCE_DIR})
+ua_add_architecture_header(${CMAKE_CURRENT_SOURCE_DIR}/ua_architecture.h)
 
 
 endif()
 endif()

+ 1 - 1
plugins/ua_network_tcp.c

@@ -9,7 +9,7 @@
  */
  */
 
 
 
 
-#include <ua_architecture.h>
+#include "ua_architecture.h"
 
 
 #include "ua_network_tcp.h"
 #include "ua_network_tcp.h"
 #include "ua_log_stdout.h"
 #include "ua_log_stdout.h"

+ 5 - 0
src/ua_util.h

@@ -170,8 +170,13 @@ UA_atomic_subSize(volatile size_t *addr, size_t decrease) {
  * up to that point. */
  * up to that point. */
 size_t UA_readNumber(u8 *buf, size_t buflen, u32 *number);
 size_t UA_readNumber(u8 *buf, size_t buflen, u32 *number);
 
 
+#ifndef MIN
 #define MIN(A,B) (A > B ? B : A)
 #define MIN(A,B) (A > B ? B : A)
+#endif
+
+#ifndef MAX
 #define MAX(A,B) (A > B ? A : B)
 #define MAX(A,B) (A > B ? A : B)
+#endif
 
 
 #ifdef UA_DEBUG_DUMP_PKGS
 #ifdef UA_DEBUG_DUMP_PKGS
 void UA_EXPORT UA_dump_hex_pkg(UA_Byte* buffer, size_t bufferLen);
 void UA_EXPORT UA_dump_hex_pkg(UA_Byte* buffer, size_t bufferLen);

+ 1 - 1
tests/fuzz/generate_corpus.sh

@@ -118,4 +118,4 @@ done
 
 
 
 
 merge_corpus $BUILD_DIR_FUZZ_MODE/bin/fuzz_binary_message $BASE_DIR/tests/fuzz/fuzz_binary_message_corpus/generated $CORPUS_COMBINED
 merge_corpus $BUILD_DIR_FUZZ_MODE/bin/fuzz_binary_message $BASE_DIR/tests/fuzz/fuzz_binary_message_corpus/generated $CORPUS_COMBINED
-if [ $? -ne 0 ] ; then exit 1 ; fi
+if [ $? -ne 0 ] ; then exit 1 ; fi

+ 31 - 1
tools/cmake/macros.cmake

@@ -8,4 +8,34 @@ FUNCTION(ua_include_directories)
     FOREACH(ARG ${ARGV})
     FOREACH(ARG ${ARGV})
         set_property(GLOBAL APPEND PROPERTY UA_INCLUDE_DIRECTORIES ${ARG})
         set_property(GLOBAL APPEND PROPERTY UA_INCLUDE_DIRECTORIES ${ARG})
     ENDFOREACH(ARG)
     ENDFOREACH(ARG)
-ENDFUNCTION(ua_include_directories)
+ENDFUNCTION(ua_include_directories)
+
+FUNCTION(ua_add_architecture_header)
+    FOREACH(ARG ${ARGV})
+        set_property(GLOBAL APPEND PROPERTY UA_ARCHITECTURE_HEADERS ${ARG})
+    ENDFOREACH(ARG)
+ENDFUNCTION(ua_add_architecture_header)
+
+FUNCTION(ua_add_architecture_file)
+    FOREACH(ARG ${ARGV})
+        set_property(GLOBAL APPEND PROPERTY UA_ARCHITECTURE_SOURCES ${ARG})
+    ENDFOREACH(ARG)
+ENDFUNCTION(ua_add_architecture_file)
+
+FUNCTION(ua_architecture_add_definitions)
+    FOREACH(ARG ${ARGV})
+        set_property(GLOBAL APPEND PROPERTY UA_ARCHITECTURE_ADD_DEFINITIONS ${ARG})
+    ENDFOREACH(ARG)
+ENDFUNCTION(ua_architecture_add_definitions)
+
+FUNCTION(ua_architecture_remove_definitions)
+    FOREACH(ARG ${ARGV})
+        set_property(GLOBAL APPEND PROPERTY UA_ARCHITECTURE_REMOVE_DEFINITIONS ${ARG})
+    ENDFOREACH(ARG)
+ENDFUNCTION(ua_architecture_remove_definitions)
+
+FUNCTION(ua_architecture_append_to_library)
+    FOREACH(ARG ${ARGV})
+        set_property(GLOBAL APPEND PROPERTY UA_ARCHITECTURE_APPEND_TO_LIBRARY ${ARG})
+    ENDFOREACH(ARG)
+ENDFUNCTION(ua_architecture_append_to_library)