Jose Cabral преди 5 години
родител
ревизия
1605455a74
променени са 43 файла, в които са добавени 316 реда и са изтрити 317 реда
  1. 25 12
      CMakeLists.txt
  2. 248 0
      arch/ua_architecture_definitions.h
  3. 3 0
      arch/ua_architecture_functions.h
  4. 1 0
      examples/CMakeLists.txt
  5. 0 2
      examples/access_control/client_access_control.c
  6. 1 3
      examples/access_control/server_access_control.c
  7. 0 1
      examples/client.c
  8. 0 1
      examples/client_async.c
  9. 0 1
      examples/custom_datatype/client_types_custom.c
  10. 2 2
      examples/custom_datatype/server_types_custom.c
  11. 1 3
      examples/discovery/client_find_servers.c
  12. 1 2
      examples/discovery/server_lds.c
  13. 1 4
      examples/discovery/server_multicast.c
  14. 1 3
      examples/discovery/server_register.c
  15. 0 3
      examples/encryption/client_basic128rsa15.c
  16. 0 3
      examples/encryption/client_basic256sha256.c
  17. 1 3
      examples/encryption/server_basic128rsa15.c
  18. 1 3
      examples/encryption/server_basic256sha256.c
  19. 1 1
      examples/nodeset/server_nodeset.c
  20. 1 1
      examples/nodeset/server_nodeset_plcopen.c
  21. 1 1
      examples/pubsub/tutorial_pubsub_connection.c
  22. 1 1
      examples/pubsub/tutorial_pubsub_publish.c
  23. 1 1
      examples/pubsub/tutorial_pubsub_subscribe.c
  24. 1 3
      examples/server.cpp
  25. 1 4
      examples/server_certificate.c
  26. 1 6
      examples/server_ctt.c
  27. 1 1
      examples/server_inheritance.c
  28. 1 1
      examples/server_instantiation.c
  29. 1 1
      examples/server_repeated_job.c
  30. 1 2
      examples/server_udp.c
  31. 1 2
      examples/tutorial_client_events.c
  32. 0 1
      examples/tutorial_client_firststeps.c
  33. 0 1
      examples/tutorial_datatypes.c
  34. 1 1
      examples/tutorial_server_datasource.c
  35. 1 1
      examples/tutorial_server_events.c
  36. 1 1
      examples/tutorial_server_firststeps.c
  37. 1 1
      examples/tutorial_server_method.c
  38. 1 1
      examples/tutorial_server_monitoreditems.c
  39. 1 1
      examples/tutorial_server_object.c
  40. 1 2
      examples/tutorial_server_variable.c
  41. 1 1
      examples/tutorial_server_variabletype.c
  42. 7 233
      include/ua_config.h.in
  43. 2 2
      tools/travis/travis_linux_script.sh

+ 25 - 12
CMakeLists.txt

@@ -52,22 +52,22 @@ endif()
 
 
 option(UA_ENABLE_AMALGAMATION "Concatenate the library to a single file open62541.h/.c" OFF)
-set(UA_AMALGAMATION_ARCHITECUTRES "" CACHE STRING "List of architectures to include in amalgamation")
-mark_as_advanced(UA_AMALGAMATION_ARCHITECUTRES)
+set(UA_AMALGAMATION_ARCHITECTURES "" CACHE STRING "List of architectures to include in amalgamation")
+mark_as_advanced(UA_AMALGAMATION_ARCHITECTURES)
 
 # 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_ENABLE_AMALGAMATION)
     if(NOT "${UA_ARCHITECTURE}" STREQUAL "None")
-        set(UA_AMALGAMATION_ARCHITECUTRES "${UA_ARCHITECTURE}")
+        set(UA_AMALGAMATION_ARCHITECTURES "${UA_ARCHITECTURE}")
     else()
-        if("${UA_AMALGAMATION_ARCHITECUTRES}" STREQUAL "")
+        if("${UA_AMALGAMATION_ARCHITECTURES}" STREQUAL "")
             # select some default architectures which should be included
-            set(UA_AMALGAMATION_ARCHITECUTRES "win32;posix")
+            set(UA_AMALGAMATION_ARCHITECTURES "win32;posix")
         endif()
     endif()
-    message(STATUS "Architectures included in amalgamation: ${UA_AMALGAMATION_ARCHITECUTRES}")
+    message(STATUS "Architectures included in amalgamation: ${UA_AMALGAMATION_ARCHITECTURES}")
 endif()
 
 if("${UA_ARCHITECTURE}" STREQUAL "None")
@@ -112,6 +112,15 @@ 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")
 
+# Create a list of ifdefs for all the architectures.
+# This is needed to enable a default architecture if none is selected through gcc compiler def.
+# Especially if someone is using the amalgamated file on Linux/Windows he should not need to define an architecture.
+set(UA_ARCHITECTURES_NODEF "1 ") #to make it easier to append later the && symbol
+foreach(arch_ ${architectures})
+    string(TOUPPER ${arch_} UA_ARCHITECTURE_UPPER_)
+    set(UA_ARCHITECTURES_NODEF "${UA_ARCHITECTURES_NODEF} && !defined(UA_ARCHITECTURE_${UA_ARCHITECTURE_UPPER_})")
+endforeach(arch_ ${architectures})
+
 # Options
 set(UA_LOGLEVEL 300 CACHE STRING "Level at which logs shall be reported")
 option(UA_ENABLE_HISTORIZING "Enable server to provide historical access." ON)
@@ -392,18 +401,22 @@ include_directories(${PROJECT_SOURCE_DIR}/include
                     ${PROJECT_BINARY_DIR}/src_generated
                     ${MBEDTLS_INCLUDE_DIRS})
 
-if(NOT "${UA_AMALGAMATION_ARCHITECUTRES}" STREQUAL "")
-    set(exported_headers)
-    foreach(arch ${UA_AMALGAMATION_ARCHITECUTRES})
+set(exported_headers ${exported_headers}
+                     ${PROJECT_BINARY_DIR}/src_generated/ua_config.h
+                     ${ua_architecture_headers_beginning}
+                     )
+
+if(NOT "${UA_AMALGAMATION_ARCHITECTURES}" STREQUAL "")
+    foreach(arch ${UA_AMALGAMATION_ARCHITECTURES})
         list(APPEND exported_headers ${PROJECT_SOURCE_DIR}/arch/${arch}/ua_architecture.h)
     endforeach()
 else()
-    set(exported_headers ${PROJECT_SOURCE_DIR}/arch/${UA_ARCHITECTURE}/ua_architecture.h)
+    list(APPEND exported_headers ${PROJECT_SOURCE_DIR}/arch/${UA_ARCHITECTURE}/ua_architecture.h)
 endif()
 
+list(APPEND exported_headers ${PROJECT_SOURCE_DIR}/arch/ua_architecture_definitions.h)
+
 set(exported_headers ${exported_headers}
-                     ${ua_architecture_headers_beginning}
-                     ${PROJECT_BINARY_DIR}/src_generated/ua_config.h
                      ${PROJECT_SOURCE_DIR}/deps/ms_stdint.h
                      ${PROJECT_BINARY_DIR}/src_generated/ua_statuscodes.h
                      ${PROJECT_BINARY_DIR}/src_generated/ua_nodeids.h

+ 248 - 0
arch/ua_architecture_definitions.h

@@ -0,0 +1,248 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ *    Copyright 2017 (c) Fraunhofer IOSB (Author: Julius Pfrommer)
+ *    Copyright 2017 (c) Stefan Profanter, fortiss GmbH
+ *    Copyright 2018 (c) Jose Cabral, fortiss GmbH
+ */
+
+#ifndef ARCH_UA_ARCHITECTURE_DEFINITIONS_H_
+#define ARCH_UA_ARCHITECTURE_DEFINITIONS_H_
+
+/**
+ * C99 Definitions
+ * --------------- */
+#include <string.h>
+#include <stddef.h>
+
+/* Include stdint.h and stdbool.h or workaround for older Visual Studios */
+#if !defined(_MSC_VER) || _MSC_VER >= 1600
+# include <stdint.h>
+# include <stdbool.h> /* C99 Boolean */
+#else
+# include "ms_stdint.h"
+# if !defined(__bool_true_false_are_defined)
+#  define bool unsigned char
+#  define true 1
+#  define false 0
+#  define __bool_true_false_are_defined
+# endif
+#endif
+
+/**
+ * Assertions
+ * ----------
+ * The assert macro is disabled by defining NDEBUG. It is often forgotten to
+ * include -DNDEBUG in the compiler flags when using the single-file release. So
+ * we make assertions dependent on the UA_DEBUG definition handled by CMake. */
+#ifdef UA_DEBUG
+# include <assert.h>
+# define UA_assert(ignore) assert(ignore)
+#else
+# define UA_assert(ignore)
+#endif
+
+/* Outputs an error message at compile time if the assert fails.
+ * Example usage:
+ * UA_STATIC_ASSERT(sizeof(long)==7, use_another_compiler_luke)
+ * See: https://stackoverflow.com/a/4815532/869402 */
+#if defined(__cplusplus) && __cplusplus >= 201103L /* C++11 or above */
+# define UA_STATIC_ASSERT(cond,msg) static_assert(cond, #msg)
+#elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L /* C11 or above */
+# define UA_STATIC_ASSERT(cond,msg) _Static_assert(cond, #msg)
+#elif defined(__GNUC__) || defined(__clang__) || defined(_MSC_VER) /* GCC, Clang, MSC */
+# define UA_CTASTR2(pre,post) pre ## post
+# define UA_CTASTR(pre,post) UA_CTASTR2(pre,post)
+# ifndef __COUNTER__ /* PPC GCC fix */
+#  define __COUNTER__ __LINE__
+# endif
+# define UA_STATIC_ASSERT(cond,msg)                             \
+    typedef struct {                                            \
+        int UA_CTASTR(static_assertion_failed_,msg) : !!(cond); \
+    } UA_CTASTR(static_assertion_failed_,__COUNTER__)
+#else /* Everybody else */
+# define UA_STATIC_ASSERT(cond,msg) typedef char static_assertion_##msg[(cond)?1:-1]
+#endif
+
+#if defined(_WIN32) && defined(UA_DYNAMIC_LINKING)
+# ifdef UA_DYNAMIC_LINKING_EXPORT /* export dll */
+#  ifdef __GNUC__
+#   define UA_EXPORT __attribute__ ((dllexport))
+#  else
+#   define UA_EXPORT __declspec(dllexport)
+#  endif
+# else /* import dll */
+#  ifdef __GNUC__
+#   define UA_EXPORT __attribute__ ((dllimport))
+#  else
+#   define UA_EXPORT __declspec(dllimport)
+#  endif
+# endif
+#else /* non win32 */
+# if __GNUC__ || __clang__
+#  define UA_EXPORT __attribute__ ((visibility ("default")))
+# endif
+#endif
+#ifndef UA_EXPORT
+# define UA_EXPORT /* fallback to default */
+#endif
+
+/**
+ * Inline Functions
+ * ---------------- */
+#ifdef _MSC_VER
+# define UA_INLINE __inline
+#else
+# define UA_INLINE inline
+#endif
+
+/**
+ * Non-aliasing pointers
+ * -------------------- */
+#ifdef _MSC_VER
+# define UA_RESTRICT __restrict
+#elif defined(__GNUC__)
+# define UA_RESTRICT __restrict__
+#else
+# define UA_RESTRICT restrict
+#endif
+
+/**
+ * Function attributes
+ * ------------------- */
+#if defined(__GNUC__) || defined(__clang__)
+# define UA_FUNC_ATTR_MALLOC __attribute__((malloc))
+# define UA_FUNC_ATTR_PURE __attribute__ ((pure))
+# define UA_FUNC_ATTR_CONST __attribute__((const))
+# define UA_FUNC_ATTR_WARN_UNUSED_RESULT __attribute__((warn_unused_result))
+# define UA_FORMAT(X,Y) __attribute__ ((format (printf, X, Y)))
+#else
+# define UA_FUNC_ATTR_MALLOC
+# define UA_FUNC_ATTR_PURE
+# define UA_FUNC_ATTR_CONST
+# define UA_FUNC_ATTR_WARN_UNUSED_RESULT
+# define UA_FORMAT(X,Y)
+#endif
+
+#if defined(__GNUC__) || defined(__clang__)
+# define UA_DEPRECATED __attribute__((deprecated))
+#elif defined(_MSC_VER)
+# define UA_DEPRECATED __declspec(deprecated)
+#else
+# define UA_DEPRECATED
+#endif
+
+/**
+ * Detect Endianness and IEEE 754 floating point
+ * ---------------------------------------------
+ * Integers and floating point numbers are transmitted in little-endian (IEEE
+ * 754 for floating point) encoding. If the target architecture uses the same
+ * format, numeral datatypes can be memcpy'd (overlayed) on the network buffer.
+ * Otherwise, a slow default encoding routine is used that works for every
+ * architecture.
+ *
+ * Integer Endianness
+ * ^^^^^^^^^^^^^^^^^^
+ * The definition ``UA_LITTLE_ENDIAN`` is true when the integer representation
+ * of the target architecture is little-endian. */
+#if defined(_WIN32)
+# define UA_LITTLE_ENDIAN 1
+#elif defined(__i386__) || defined(__x86_64__) || defined(__amd64__)
+# define UA_LITTLE_ENDIAN 1
+#elif (defined(__BYTE_ORDER__) && defined(__ORDER_LITTLE_ENDIAN__) && \
+      (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__))
+# define UA_LITTLE_ENDIAN 1
+#elif defined(__linux__) /* Linux (including Android) */
+# include <endian.h>
+# if __BYTE_ORDER == __LITTLE_ENDIAN
+#  define UA_LITTLE_ENDIAN 1
+# endif
+#elif defined(__OpenBSD__) /* OpenBSD */
+# include <sys/endian.h>
+# if BYTE_ORDER == LITTLE_ENDIAN
+#  define UA_LITTLE_ENDIAN 1
+# endif
+#elif defined(__NetBSD__) || defined(__FreeBSD__) || defined(__DragonFly__) /* Other BSD */
+# include <sys/endian.h>
+# if _BYTE_ORDER == _LITTLE_ENDIAN
+#  define UA_LITTLE_ENDIAN 1
+# endif
+#elif defined(__APPLE__) /* Apple (MacOS, iOS) */
+# include <libkern/OSByteOrder.h>
+# if defined(__LITTLE_ENDIAN__)
+#  define UA_LITTLE_ENDIAN 1
+# endif
+#elif defined(__QNX__) || defined(__QNXNTO__) /* QNX */
+# include <gulliver.h>
+# if defined(__LITTLEENDIAN__)
+#  define UA_LITTLE_ENDIAN 1
+# endif
+#elif defined(_OS9000) /* OS-9 */
+# if defined(_LIL_END)
+#  define UA_LITTLE_ENDIAN 1
+# endif
+#endif
+#ifndef UA_LITTLE_ENDIAN
+# define UA_LITTLE_ENDIAN 0
+#endif
+
+/* Can the integers be memcpy'd onto the network buffer? Add additional checks
+ * here. Some platforms (e.g. QNX) have sizeof(bool) > 1. Manually disable
+ * overlayed integer encoding if that is the case. */
+#if (UA_LITTLE_ENDIAN == 1)
+UA_STATIC_ASSERT(sizeof(bool) == 1, cannot_overlay_integers_with_large_bool);
+# define UA_BINARY_OVERLAYABLE_INTEGER 1
+#else
+# define UA_BINARY_OVERLAYABLE_INTEGER 0
+#endif
+
+/**
+ * Float Endianness
+ * ^^^^^^^^^^^^^^^^
+ * The definition ``UA_FLOAT_IEEE754`` is set to true when the floating point
+ * number representation of the target architecture is IEEE 754. The definition
+ * ``UA_FLOAT_LITTLE_ENDIAN`` is set to true when the floating point number
+ * representation is in little-endian encoding. */
+
+#if defined(_WIN32)
+# define UA_FLOAT_IEEE754 1
+#elif defined(__i386__) || defined(__x86_64__) || defined(__amd64__) || \
+    defined(__ia64__) || defined(__powerpc__) || defined(__sparc__) || \
+    defined(__arm__)
+# define UA_FLOAT_IEEE754 1
+#elif defined(__STDC_IEC_559__)
+# define UA_FLOAT_IEEE754 1
+#else
+# define UA_FLOAT_IEEE754 0
+#endif
+
+/* Wikipedia says (https://en.wikipedia.org/wiki/Endianness): Although the
+ * ubiquitous x86 processors of today use little-endian storage for all types of
+ * data (integer, floating point, BCD), there are a number of hardware
+ * architectures where floating-point numbers are represented in big-endian form
+ * while integers are represented in little-endian form. */
+#if defined(_WIN32)
+# define UA_FLOAT_LITTLE_ENDIAN 1
+#elif defined(__i386__) || defined(__x86_64__) || defined(__amd64__)
+# define UA_FLOAT_LITTLE_ENDIAN 1
+#elif defined(__FLOAT_WORD_ORDER__) && defined(__ORDER_LITTLE_ENDIAN__) && \
+    (__FLOAT_WORD_ORDER__ == __ORDER_LITTLE_ENDIAN__) /* Defined only in GCC */
+# define UA_FLOAT_LITTLE_ENDIAN 1
+#elif defined(__FLOAT_WORD_ORDER) && defined(__LITTLE_ENDIAN) && \
+    (__FLOAT_WORD_ORDER == __LITTLE_ENDIAN) /* Defined only in GCC */
+# define UA_FLOAT_LITTLE_ENDIAN 1
+#endif
+#ifndef UA_FLOAT_LITTLE_ENDIAN
+# define UA_FLOAT_LITTLE_ENDIAN 0
+#endif
+
+/* Only if the floating points are litle-endian **and** in IEEE 754 format can
+ * we memcpy directly onto the network buffer. */
+#if (UA_FLOAT_IEEE754 == 1) && (UA_FLOAT_LITTLE_ENDIAN == 1)
+# define UA_BINARY_OVERLAYABLE_FLOAT 1
+#else
+# define UA_BINARY_OVERLAYABLE_FLOAT 0
+#endif
+
+#endif /* ARCH_UA_ARCHITECTURE_DEFINITIONS_H_ */

+ 3 - 0
arch/ua_architecture_functions.h

@@ -198,6 +198,9 @@ int UA_snprintf(char* pa_stream, size_t pa_size, const char* pa_format, ...); //
 int UA_access(const char *pathname, int mode); //equivalent implementation of https://linux.die.net/man/2/access
 #endif
 
+
+#include "ua_architecture_definitions.h"
+
 #ifdef __cplusplus
 }
 #endif

+ 1 - 0
examples/CMakeLists.txt

@@ -2,6 +2,7 @@ include_directories(${PROJECT_SOURCE_DIR}/include)
 include_directories(${PROJECT_SOURCE_DIR}/plugins)
 include_directories(${PROJECT_BINARY_DIR})
 include_directories(${PROJECT_SOURCE_DIR}/examples)
+include_directories(${PROJECT_SOURCE_DIR}/arch)
 
 set(examples_headers
     ${examples_headers}

+ 0 - 2
examples/access_control/client_access_control.c

@@ -5,8 +5,6 @@
  * Using access_control_server
  */
 
-#include <stdio.h>
-
 #include "open62541.h"
 
 int main(void) {

+ 1 - 3
examples/access_control/server_access_control.c

@@ -1,10 +1,8 @@
 /* This work is licensed under a Creative Commons CCZero 1.0 Universal License.
  * See http://creativecommons.org/publicdomain/zero/1.0/ for more information. */
 
-#include <signal.h>
-#include <stdio.h>
-
 #include "open62541.h"
+#include <signal.h>
 
 static UA_Boolean
 allowAddNode(UA_Server *server, UA_AccessControl *ac,

+ 0 - 1
examples/client.c

@@ -1,7 +1,6 @@
 /* This work is licensed under a Creative Commons CCZero 1.0 Universal License.
  * See http://creativecommons.org/publicdomain/zero/1.0/ for more information. */
 
-#include <stdio.h>
 #include "open62541.h"
 
 #ifdef UA_ENABLE_SUBSCRIPTIONS

+ 0 - 1
examples/client_async.c

@@ -13,7 +13,6 @@
 # define _BSD_SOURCE
 #endif
 
-#include <stdio.h>
 #include "open62541.h"
 
 #define NODES_EXIST

+ 0 - 1
examples/custom_datatype/client_types_custom.c

@@ -1,7 +1,6 @@
 /* This work is licensed under a Creative Commons CCZero 1.0 Universal License.
  * See http://creativecommons.org/publicdomain/zero/1.0/ for more information. */
 
-#include <stdio.h>
 #include "open62541.h"
 #include "custom_datatype.h"
 

+ 2 - 2
examples/custom_datatype/server_types_custom.c

@@ -1,9 +1,9 @@
 /* This work is licensed under a Creative Commons CCZero 1.0 Universal License.
  * See http://creativecommons.org/publicdomain/zero/1.0/ for more information. */
 
-#include <signal.h>
-#include <open62541.h>
+#include "open62541.h"
 #include "custom_datatype.h"
+#include <signal.h>
 
 UA_Boolean running = true;
 

+ 1 - 3
examples/discovery/client_find_servers.c

@@ -5,9 +5,7 @@
  * and then calls GetEndpoints on the returned list of servers.
  */
 
-#include <stdio.h>
-#include <stdlib.h>
-#include <open62541.h>
+#include "open62541.h"
 
 UA_Logger logger = UA_Log_Stdout;
 

+ 1 - 2
examples/discovery/server_lds.c

@@ -6,9 +6,8 @@
  * find servers service to get all registered servers (see client_find_servers.c).
  */
 
-#include <stdio.h>
-#include <signal.h>
 #include "open62541.h"
+#include <signal.h>
 
 UA_Boolean running = true;
 static void stopHandler(int sig) {

+ 1 - 4
examples/discovery/server_multicast.c

@@ -7,11 +7,8 @@
  * (i.e., LDS-ME).
  */
 
-#include <signal.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <errno.h>
 #include "open62541.h"
+#include <signal.h>
 
 UA_Logger logger = UA_Log_Stdout;
 UA_Boolean running = true;

+ 1 - 3
examples/discovery/server_register.c

@@ -6,10 +6,8 @@
  */
 
 
-#include <signal.h>
-#include <stdio.h>
-#include <stdlib.h>
 #include "open62541.h"
+#include <signal.h>
 
 #define DISCOVERY_SERVER_ENDPOINT "opc.tcp://localhost:4840"
 

+ 0 - 3
examples/encryption/client_basic128rsa15.c

@@ -1,9 +1,6 @@
 /* This work is licensed under a Creative Commons CCZero 1.0 Universal License.
  * See http://creativecommons.org/publicdomain/zero/1.0/ for more information. */
 
-#include <stdio.h>
-#include <errno.h>
-
 #include "open62541.h"
 #include "common.h"
 

+ 0 - 3
examples/encryption/client_basic256sha256.c

@@ -1,9 +1,6 @@
 /* This work is licensed under a Creative Commons CCZero 1.0 Universal License.
  * See http://creativecommons.org/publicdomain/zero/1.0/ for more information. */
 
-#include <stdio.h>
-#include <errno.h>
-
 #include "open62541.h"
 #include "common.h"
 

+ 1 - 3
examples/encryption/server_basic128rsa15.c

@@ -1,11 +1,9 @@
 /* This work is licensed under a Creative Commons CCZero 1.0 Universal License.
  * See http://creativecommons.org/publicdomain/zero/1.0/ for more information. */
 
-#include <signal.h>
-#include <stdio.h>
-#include <errno.h>
 #include "open62541.h"
 #include "common.h"
+#include <signal.h>
 
 UA_Boolean running = true;
 static void stopHandler(int sig) {

+ 1 - 3
examples/encryption/server_basic256sha256.c

@@ -1,11 +1,9 @@
 /* This work is licensed under a Creative Commons CCZero 1.0 Universal License.
  * See http://creativecommons.org/publicdomain/zero/1.0/ for more information. */
 
-#include <signal.h>
-#include <stdio.h>
-#include <errno.h>
 #include "open62541.h"
 #include "common.h"
+#include <signal.h>
 
 UA_Boolean running = true;
 static void stopHandler(int sig) {

+ 1 - 1
examples/nodeset/server_nodeset.c

@@ -1,8 +1,8 @@
 /* This work is licensed under a Creative Commons CCZero 1.0 Universal License.
  * See http://creativecommons.org/publicdomain/zero/1.0/ for more information. */
 
-#include <signal.h>
 #include "open62541.h"
+#include <signal.h>
 
 /* Files example_namespace.h and example_namespace.c are created from server_nodeset.xml in the
  * /src_generated directory by CMake */

+ 1 - 1
examples/nodeset/server_nodeset_plcopen.c

@@ -1,7 +1,6 @@
 /* This work is licensed under a Creative Commons CCZero 1.0 Universal License.
  * See http://creativecommons.org/publicdomain/zero/1.0/ for more information. */
 
-#include <signal.h>
 #ifdef UA_NO_AMALGAMATION
 #include "ua_server.h"
 #include "ua_log_stdout.h"
@@ -9,6 +8,7 @@
 #else
 #include "open62541.h"
 #endif
+#include <signal.h>
 
 /* Files example_namespace.h and example_namespace.c are created from server_nodeset.xml in the
  * /src_generated directory by CMake */

+ 1 - 1
examples/pubsub/tutorial_pubsub_connection.c

@@ -2,8 +2,8 @@
 /* This work is licensed under a Creative Commons CCZero 1.0 Universal License.
  * See http://creativecommons.org/publicdomain/zero/1.0/ for more information. */
 
-#include <signal.h>
 #include "open62541.h"
+#include <signal.h>
 
 UA_Boolean running = true;
 static void stopHandler(int sign) {

+ 1 - 1
examples/pubsub/tutorial_pubsub_publish.c

@@ -21,8 +21,8 @@
  * PubSubConnections can be created and deleted on runtime. More details about the system preconfiguration and
  * connection can be found in ``tutorial_pubsub_connection.c``.
  */
-#include <signal.h>
 #include "open62541.h"
+#include <signal.h>
 UA_NodeId connectionIdent, publishedDataSetIdent, writerGroupIdent;
 
 static void

+ 1 - 1
examples/pubsub/tutorial_pubsub_subscribe.c

@@ -9,7 +9,6 @@
  * The following code uses internal API which will be later replaced by the higher-level
  * PubSub subscriber API.
 */
-#include <signal.h>
 #include "ua_pubsub_networkmessage.h"
 #include "ua_log_stdout.h"
 #include "ua_server.h"
@@ -17,6 +16,7 @@
 #include "ua_pubsub.h"
 #include "ua_network_pubsub_udp.h"
 #include "src_generated/ua_types_generated.h"
+#include <signal.h>
 
 UA_Boolean running = true;
 static void stopHandler(int sign) {

+ 1 - 3
examples/server.cpp

@@ -1,10 +1,8 @@
 /* This work is licensed under a Creative Commons CCZero 1.0 Universal License.
  * See http://creativecommons.org/publicdomain/zero/1.0/ for more information. */
 
-#include <signal.h>
-#include <iostream>
-#include <cstring>
 # include "open62541.h"
+#include <signal.h>
 
 /* Build Instructions (Linux)
  * - gcc -std=c99 -c open62541.c

+ 1 - 4
examples/server_certificate.c

@@ -5,12 +5,9 @@
 #define _CRT_SECURE_NO_WARNINGS //disable fopen deprication warning in msvs
 #endif
 
-#include <stdio.h>
-#include <signal.h>
-#include <errno.h> // errno, EINTR
-#include <stdlib.h>
 #include "open62541.h"
 #include "common.h"
+#include <signal.h>
 
 UA_Boolean running = true;
 UA_Logger logger = UA_Log_Stdout;

+ 1 - 6
examples/server_ctt.c

@@ -5,14 +5,9 @@
 #define _CRT_SECURE_NO_WARNINGS /* disable fopen deprication warning in msvs */
 #endif
 
-#include <signal.h>
-#include <errno.h> // errno, EINTR
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <open62541.h>
 #include "open62541.h"
 #include "common.h"
+#include <signal.h>
 
 /* This server is configured to the Compliance Testing Tools (CTT) against. The
  * corresponding CTT configuration is available at

+ 1 - 1
examples/server_inheritance.c

@@ -1,8 +1,8 @@
 /* This work is licensed under a Creative Commons CCZero 1.0 Universal License.
  * See http://creativecommons.org/publicdomain/zero/1.0/ for more information. */
 
-#include <signal.h>
 #include "open62541.h"
+#include <signal.h>
 
 UA_Boolean running = true;
 static void stopHandler(int sig) {

+ 1 - 1
examples/server_instantiation.c

@@ -1,8 +1,8 @@
 /* This work is licensed under a Creative Commons CCZero 1.0 Universal License.
  * See http://creativecommons.org/publicdomain/zero/1.0/ for more information. */
 
-#include <signal.h>
 #include "open62541.h"
+#include <signal.h>
 
 UA_Boolean running = true;
 static void stopHandler(int sig) {

+ 1 - 1
examples/server_repeated_job.c

@@ -1,8 +1,8 @@
 /* This work is licensed under a Creative Commons CCZero 1.0 Universal License.
  * See http://creativecommons.org/publicdomain/zero/1.0/ for more information. */
 
-#include <signal.h>
 #include "open62541.h"
+#include <signal.h>
 
 static void
 testCallback(UA_Server *server, void *data) {

+ 1 - 2
examples/server_udp.c

@@ -2,9 +2,8 @@
  * This work is licensed under a Creative Commons CCZero 1.0 Universal License.
  * See http://creativecommons.org/publicdomain/zero/1.0/ for more information.
  */
-#include <stdio.h>
-#include <signal.h>
 #include "open62541.h"
+#include <signal.h>
 
 UA_Logger logger = UA_Log_Stdout;
 

+ 1 - 2
examples/tutorial_client_events.c

@@ -1,9 +1,8 @@
 /* This work is licensed under a Creative Commons CCZero 1.0 Universal License.
  * See http://creativecommons.org/publicdomain/zero/1.0/ for more information. */
 
-#include <signal.h>
-#include <stdio.h>
 #include "open62541.h"
+#include <signal.h>
 
 #ifdef _MSC_VER
 #pragma warning(disable:4996) // warning C4996: 'UA_Client_Subscriptions_addMonitoredEvent': was declared deprecated

+ 0 - 1
examples/tutorial_client_firststeps.c

@@ -8,7 +8,6 @@
  * provides both a server- and clientside API, so creating a client is as easy as
  * creating a server. Copy the following into a file `myClient.c`: */
 
-#include <stdio.h>
 #include "open62541.h"
 
 int main(void) {

+ 0 - 1
examples/tutorial_datatypes.c

@@ -16,7 +16,6 @@
  * This section shows the basic interaction patterns for data types. Make
  * sure to compare with the type definitions in ``ua_types.h``. */
 
-#include <assert.h>
 #include "open62541.h"
 
 static void

+ 1 - 1
examples/tutorial_server_datasource.c

@@ -25,8 +25,8 @@
  * new value arrives from the underlying process, we can just write into the
  * variable. */
 
-#include <signal.h>
 #include "open62541.h"
+#include <signal.h>
 
 static void
 updateCurrentTime(UA_Server *server) {

+ 1 - 1
examples/tutorial_server_events.c

@@ -1,8 +1,8 @@
 /* This work is licensed under a Creative Commons CCZero 1.0 Universal License.
  * See http://creativecommons.org/publicdomain/zero/1.0/ for more information. */
 
-#include <signal.h>
 #include "open62541.h"
+#include <signal.h>
 
 /**
  * Generating events

+ 1 - 1
examples/tutorial_server_firststeps.c

@@ -20,8 +20,8 @@
  * you have the ``open62541.c/.h`` files in the current folder. Now create a new
  * C source-file called ``myServer.c`` with the following content: */
 
-#include <signal.h>
 #include "open62541.h"
+#include <signal.h>
 
 UA_Boolean running = true;
 static void stopHandler(int sig) {

+ 1 - 1
examples/tutorial_server_method.c

@@ -30,8 +30,8 @@
  * prepended. The type and length of the input arguments is checked internally
  * by the SDK, so that we don't have to verify the arguments in the callback. */
 
-#include <signal.h>
 #include "open62541.h"
+#include <signal.h>
 
 static UA_StatusCode
 helloWorldMethodCallback(UA_Server *server,

+ 1 - 1
examples/tutorial_server_monitoreditems.c

@@ -19,8 +19,8 @@
  * context pointer.
  */
 
-#include <signal.h>
 #include "open62541.h"
+#include <signal.h>
 
 static void
 dataChangeNotificationCallback(UA_Server *server, UA_UInt32 monitoredItemId,

+ 1 - 1
examples/tutorial_server_object.c

@@ -55,8 +55,8 @@
  * setting constraints on the variable values as this is not the focus of this
  * tutorial and was already covered. */
 
-#include <signal.h>
 #include "open62541.h"
+#include <signal.h>
 
 static void
 manuallyDefinePump(UA_Server *server) {

+ 1 - 2
examples/tutorial_server_variable.c

@@ -14,9 +14,8 @@
  * read only. See below for making the variable writable.
  */
 
-#include <signal.h>
-#include <stdio.h>
 #include "open62541.h"
+#include <signal.h>
 
 static void
 addVariable(UA_Server *server) {

+ 1 - 1
examples/tutorial_server_variabletype.c

@@ -18,8 +18,8 @@
  * VariableTypeNode to the hierarchy of variable types.
  */
 
-#include <signal.h>
 #include "open62541.h"
+#include <signal.h>
 
 static UA_NodeId pointTypeId;
 

+ 7 - 233
include/ua_config.h.in

@@ -60,63 +60,6 @@ extern "C" {
 #cmakedefine UA_DEBUG
 #cmakedefine UA_DEBUG_DUMP_PKGS
 
-#include "ua_architecture.h"
-
-/**
- * C99 Definitions
- * --------------- */
-#include <string.h>
-#include <stddef.h>
-
-/* Include stdint.h and stdbool.h or workaround for older Visual Studios */
-#if !defined(_MSC_VER) || _MSC_VER >= 1600
-# include <stdint.h>
-# include <stdbool.h> /* C99 Boolean */
-#else
-# include "ms_stdint.h"
-# if !defined(__bool_true_false_are_defined)
-#  define bool unsigned char
-#  define true 1
-#  define false 0
-#  define __bool_true_false_are_defined
-# endif
-#endif
-
-/**
- * Assertions
- * ----------
- * The assert macro is disabled by defining NDEBUG. It is often forgotten to
- * include -DNDEBUG in the compiler flags when using the single-file release. So
- * we make assertions dependent on the UA_DEBUG definition handled by CMake. */
-#ifdef UA_DEBUG
-# include <assert.h>
-# define UA_assert(ignore) assert(ignore)
-#else
-# define UA_assert(ignore)
-#endif
-
-/* Outputs an error message at compile time if the assert fails.
- * Example usage:
- * UA_STATIC_ASSERT(sizeof(long)==7, use_another_compiler_luke)
- * See: https://stackoverflow.com/a/4815532/869402 */
-#if defined(__cplusplus) && __cplusplus >= 201103L /* C++11 or above */
-# define UA_STATIC_ASSERT(cond,msg) static_assert(cond, #msg)
-#elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L /* C11 or above */
-# define UA_STATIC_ASSERT(cond,msg) _Static_assert(cond, #msg)
-#elif defined(__GNUC__) || defined(__clang__) || defined(_MSC_VER) /* GCC, Clang, MSC */
-# define UA_CTASTR2(pre,post) pre ## post
-# define UA_CTASTR(pre,post) UA_CTASTR2(pre,post)
-# ifndef __COUNTER__ /* PPC GCC fix */
-#  define __COUNTER__ __LINE__
-# endif
-# define UA_STATIC_ASSERT(cond,msg)                             \
-    typedef struct {                                            \
-        int UA_CTASTR(static_assertion_failed_,msg) : !!(cond); \
-    } UA_CTASTR(static_assertion_failed_,__COUNTER__)
-#else /* Everybody else */
-# define UA_STATIC_ASSERT(cond,msg) typedef char static_assertion_##msg[(cond)?1:-1]
-#endif
-
 /**
  * Function Export
  * ---------------
@@ -125,185 +68,16 @@ extern "C" {
  * import symbols from a DLL.*/
 #cmakedefine UA_DYNAMIC_LINKING
 
-#if defined(_WIN32) && defined(UA_DYNAMIC_LINKING)
-# ifdef UA_DYNAMIC_LINKING_EXPORT /* export dll */
-#  ifdef __GNUC__
-#   define UA_EXPORT __attribute__ ((dllexport))
-#  else
-#   define UA_EXPORT __declspec(dllexport)
-#  endif
-# else /* import dll */
-#  ifdef __GNUC__
-#   define UA_EXPORT __attribute__ ((dllimport))
-#  else
-#   define UA_EXPORT __declspec(dllimport)
-#  endif
-# endif
-#else /* non win32 */
-# if __GNUC__ || __clang__
-#  define UA_EXPORT __attribute__ ((visibility ("default")))
+/* Select default architecture if non is selected through CMake or compiler define */
+#if ${UA_ARCHITECTURES_NODEF}
+# ifdef _WIN32
+#  define UA_ARCHITECTURE_WIN32
+# else
+#  define UA_ARCHITECTURE_POSIX
 # endif
 #endif
-#ifndef UA_EXPORT
-# define UA_EXPORT /* fallback to default */
-#endif
-
-/**
- * Inline Functions
- * ---------------- */
-#ifdef _MSC_VER
-# define UA_INLINE __inline
-#else
-# define UA_INLINE inline
-#endif
-
-/**
- * Non-aliasing pointers
- * -------------------- */
-#ifdef _MSC_VER
-# define UA_RESTRICT __restrict
-#elif defined(__GNUC__)
-# define UA_RESTRICT __restrict__
-#else
-# define UA_RESTRICT restrict
-#endif
-
-/**
- * Function attributes
- * ------------------- */
-#if defined(__GNUC__) || defined(__clang__)
-# define UA_FUNC_ATTR_MALLOC __attribute__((malloc))
-# define UA_FUNC_ATTR_PURE __attribute__ ((pure))
-# define UA_FUNC_ATTR_CONST __attribute__((const))
-# define UA_FUNC_ATTR_WARN_UNUSED_RESULT __attribute__((warn_unused_result))
-# define UA_FORMAT(X,Y) __attribute__ ((format (printf, X, Y)))
-#else
-# define UA_FUNC_ATTR_MALLOC
-# define UA_FUNC_ATTR_PURE
-# define UA_FUNC_ATTR_CONST
-# define UA_FUNC_ATTR_WARN_UNUSED_RESULT
-# define UA_FORMAT(X,Y)
-#endif
 
-#if defined(__GNUC__) || defined(__clang__)
-# define UA_DEPRECATED __attribute__((deprecated))
-#elif defined(_MSC_VER)
-# define UA_DEPRECATED __declspec(deprecated)
-#else
-# define UA_DEPRECATED
-#endif
-
-/**
- * Detect Endianness and IEEE 754 floating point
- * ---------------------------------------------
- * Integers and floating point numbers are transmitted in little-endian (IEEE
- * 754 for floating point) encoding. If the target architecture uses the same
- * format, numeral datatypes can be memcpy'd (overlayed) on the network buffer.
- * Otherwise, a slow default encoding routine is used that works for every
- * architecture.
- *
- * Integer Endianness
- * ^^^^^^^^^^^^^^^^^^
- * The definition ``UA_LITTLE_ENDIAN`` is true when the integer representation
- * of the target architecture is little-endian. */
-#if defined(_WIN32)
-# define UA_LITTLE_ENDIAN 1
-#elif defined(__i386__) || defined(__x86_64__) || defined(__amd64__)
-# define UA_LITTLE_ENDIAN 1
-#elif (defined(__BYTE_ORDER__) && defined(__ORDER_LITTLE_ENDIAN__) && \
-      (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__))
-# define UA_LITTLE_ENDIAN 1
-#elif defined(__linux__) /* Linux (including Android) */
-# include <endian.h>
-# if __BYTE_ORDER == __LITTLE_ENDIAN
-#  define UA_LITTLE_ENDIAN 1
-# endif
-#elif defined(__OpenBSD__) /* OpenBSD */
-# include <sys/endian.h>
-# if BYTE_ORDER == LITTLE_ENDIAN
-#  define UA_LITTLE_ENDIAN 1
-# endif
-#elif defined(__NetBSD__) || defined(__FreeBSD__) || defined(__DragonFly__) /* Other BSD */
-# include <sys/endian.h>
-# if _BYTE_ORDER == _LITTLE_ENDIAN
-#  define UA_LITTLE_ENDIAN 1
-# endif
-#elif defined(__APPLE__) /* Apple (MacOS, iOS) */
-# include <libkern/OSByteOrder.h>
-# if defined(__LITTLE_ENDIAN__)
-#  define UA_LITTLE_ENDIAN 1
-# endif
-#elif defined(__QNX__) || defined(__QNXNTO__) /* QNX */
-# include <gulliver.h>
-# if defined(__LITTLEENDIAN__)
-#  define UA_LITTLE_ENDIAN 1
-# endif
-#elif defined(_OS9000) /* OS-9 */
-# if defined(_LIL_END)
-#  define UA_LITTLE_ENDIAN 1
-# endif
-#endif
-#ifndef UA_LITTLE_ENDIAN
-# define UA_LITTLE_ENDIAN 0
-#endif
-
-/* Can the integers be memcpy'd onto the network buffer? Add additional checks
- * here. Some platforms (e.g. QNX) have sizeof(bool) > 1. Manually disable
- * overlayed integer encoding if that is the case. */
-#if (UA_LITTLE_ENDIAN == 1)
-UA_STATIC_ASSERT(sizeof(bool) == 1, cannot_overlay_integers_with_large_bool);
-# define UA_BINARY_OVERLAYABLE_INTEGER 1
-#else
-# define UA_BINARY_OVERLAYABLE_INTEGER 0
-#endif
-
-/**
- * Float Endianness
- * ^^^^^^^^^^^^^^^^
- * The definition ``UA_FLOAT_IEEE754`` is set to true when the floating point
- * number representation of the target architecture is IEEE 754. The definition
- * ``UA_FLOAT_LITTLE_ENDIAN`` is set to true when the floating point number
- * representation is in little-endian encoding. */
-
-#if defined(_WIN32)
-# define UA_FLOAT_IEEE754 1
-#elif defined(__i386__) || defined(__x86_64__) || defined(__amd64__) || \
-    defined(__ia64__) || defined(__powerpc__) || defined(__sparc__) || \
-    defined(__arm__)
-# define UA_FLOAT_IEEE754 1
-#elif defined(__STDC_IEC_559__)
-# define UA_FLOAT_IEEE754 1
-#else
-# define UA_FLOAT_IEEE754 0
-#endif
-
-/* Wikipedia says (https://en.wikipedia.org/wiki/Endianness): Although the
- * ubiquitous x86 processors of today use little-endian storage for all types of
- * data (integer, floating point, BCD), there are a number of hardware
- * architectures where floating-point numbers are represented in big-endian form
- * while integers are represented in little-endian form. */
-#if defined(_WIN32)
-# define UA_FLOAT_LITTLE_ENDIAN 1
-#elif defined(__i386__) || defined(__x86_64__) || defined(__amd64__)
-# define UA_FLOAT_LITTLE_ENDIAN 1
-#elif defined(__FLOAT_WORD_ORDER__) && defined(__ORDER_LITTLE_ENDIAN__) && \
-    (__FLOAT_WORD_ORDER__ == __ORDER_LITTLE_ENDIAN__) /* Defined only in GCC */
-# define UA_FLOAT_LITTLE_ENDIAN 1
-#elif defined(__FLOAT_WORD_ORDER) && defined(__LITTLE_ENDIAN) && \
-    (__FLOAT_WORD_ORDER == __LITTLE_ENDIAN) /* Defined only in GCC */
-# define UA_FLOAT_LITTLE_ENDIAN 1
-#endif
-#ifndef UA_FLOAT_LITTLE_ENDIAN
-# define UA_FLOAT_LITTLE_ENDIAN 0
-#endif
-
-/* Only if the floating points are litle-endian **and** in IEEE 754 format can
- * we memcpy directly onto the network buffer. */
-#if (UA_FLOAT_IEEE754 == 1) && (UA_FLOAT_LITTLE_ENDIAN == 1)
-# define UA_BINARY_OVERLAYABLE_FLOAT 1
-#else
-# define UA_BINARY_OVERLAYABLE_FLOAT 0
-#endif
+#include "ua_architecture.h"
 
 #ifdef __cplusplus
 } // extern "C"

+ 2 - 2
tools/travis/travis_linux_script.sh

@@ -177,8 +177,8 @@ else
     echo -e "\r\n== Building the C++ example =="  && echo -en 'travis_fold:start:script.build.example\\r'
     mkdir -p build && cd build
     cp ../../open62541.* .
-    gcc -std=c99  -DUA_ARCHITECTURE_POSIX  -c open62541.c
-    g++ ../examples/server.cpp -DUA_ARCHITECTURE_POSIX -I./ open62541.o -lrt -o cpp-server
+    gcc -std=c99 -c open62541.c
+    g++ ../examples/server.cpp -I./ open62541.o -lrt -o cpp-server
     if [ $? -ne 0 ] ; then exit 1 ; fi
     cd .. && rm build -rf
     echo -en 'travis_fold:end:script.build.example\\r'