Преглед изворни кода

encoding without thread-local variables

Julius Pfrommer пре 6 година
родитељ
комит
432cc0c85e
3 измењених фајлова са 475 додато и 573 уклоњено
  1. 4 1
      include/ua_config.h.in
  2. 464 566
      src/ua_types_encoding_binary.c
  3. 7 6
      src/ua_util.h

+ 4 - 1
include/ua_config.h.in

@@ -254,7 +254,10 @@ extern "C" {
  * The definition ``UA_BINARY_OVERLAYABLE_FLOAT`` is true when the floating
  * point number representation of the target architecture is IEEE 754. Note that
  * this cannot be reliable detected with macros for the clang compiler
- * (beginning of 2017). Just override if necessary. */
+ * (beginning of 2017). ``UA_BINARY_OVERLAYABLE_FLOAT`` can be manually set if
+ * the target is known to be little endian with floats in the IEEE 754
+ * format. */
+
 #if defined(_WIN32)
 # define UA_BINARY_OVERLAYABLE_FLOAT 1
 #elif defined(__FLOAT_WORD_ORDER__) && defined(__ORDER_LITTLE_ENDIAN__) && \

Разлика између датотеке није приказан због своје велике величине
+ 464 - 566
src/ua_types_encoding_binary.c


+ 7 - 6
src/ua_util.h

@@ -19,21 +19,22 @@ extern "C" {
 
 /* Thread-Local Storage
  * --------------------
- * Thread-local variables are always enabled. Also when the library is built
- * with ``UA_ENABLE_MULTITHREADING`` disabled. Otherwise, if multiple clients
- * run in separate threads, race conditions may occur via global variables in
- * the encoding layer. */
+ * If thread-local storage is not supported but still detected with the
+ * following macros, it can be manually disabled by defining
+ * ``UA_NO_THREAD_LOCAL``. This can result in some minor slowdowns. */
+
 #if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L
 # define UA_THREAD_LOCAL _Thread_local /* C11 */
 #elif defined(__cplusplus) && __cplusplus > 199711L
 # define UA_THREAD_LOCAL thread_local /* C++11 */
-#elif defined(__GNUC__) && !defined(_WRS_KERNEL) //defining __thread gave error of missing __tls_lookup in VxWorks
+#elif defined(__GNUC__)
 # define UA_THREAD_LOCAL __thread /* GNU extension */
 #elif defined(_MSC_VER)
 # define UA_THREAD_LOCAL __declspec(thread) /* MSVC extension */
 #else
-# warning The compiler does not support thread-local variables
+# define UA_NO_THREAD_LOCAL
 # define UA_THREAD_LOCAL
+# warning The compiler does not support thread-local variables
 #endif
 
 /* Integer Shortnames