浏览代码

assume that string.h can always be used

Julius Pfrommer 6 年之前
父节点
当前提交
d942544371
共有 4 个文件被更改,包括 3 次插入61 次删除
  1. 0 7
      CMakeLists.txt
  2. 0 34
      deps/libc_string.c
  3. 0 2
      doc/building.rst
  4. 3 18
      include/ua_config.h.in

+ 0 - 7
CMakeLists.txt

@@ -88,9 +88,6 @@ mark_as_advanced(UA_ENABLE_STATUSCODE_DESCRIPTIONS)
 option(UA_ENABLE_TYPENAMES "Add the type and member names to the UA_DataType structure" ON)
 mark_as_advanced(UA_ENABLE_TYPENAMES)
 
-option(UA_ENABLE_EMBEDDED_LIBC "Use a custom implementation of some libc functions that might be missing on embedded targets (e.g. string handling)." OFF)
-mark_as_advanced(UA_ENABLE_EMBEDDED_LIBC)
-
 option(UA_ENABLE_DETERMINISTIC_RNG "Do not seed the random number generator (e.g. for unit tests)." OFF)
 mark_as_advanced(UA_ENABLE_DETERMINISTIC_RNG)
 
@@ -369,10 +366,6 @@ if(UA_DEBUG_DUMP_PKGS)
     list(APPEND lib_sources ${PROJECT_SOURCE_DIR}/plugins/ua_debug_dump_pkgs.c)
 endif()
 
-if(UA_ENABLE_EMBEDDED_LIBC)
-  list(APPEND lib_sources ${PROJECT_SOURCE_DIR}/deps/libc_string.c)
-endif()
-
 if(UA_ENABLE_NONSTANDARD_UDP)
     list(APPEND exported_headers ${PROJECT_SOURCE_DIR}/plugins/ua_network_udp.h)
 endif()

+ 0 - 34
deps/libc_string.c

@@ -1,34 +0,0 @@
-/*
- * 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 "ua_config.h"
-
-void *memcpy(void *UA_RESTRICT dest, const void *UA_RESTRICT src, size_t n) {
-    unsigned char *d = dest;
-    const unsigned char *s = src;
-    while(n--)
-        *d++ = *s++;
-    return dest;
-}
-
-void *memset(void *dest, int c, size_t n) {
-    unsigned char c8 = (unsigned char)c;
-    unsigned char *target = dest;
-    while(n--)
-        *target++ = c8;
-    return dest;
-}
-
-size_t strlen(const char *str) {
-    size_t len = 0;
-    for(const char *s = str; *s; s++, len++);
-    return len;
-}
-
-int memcmp(const void *vl, const void *vr, size_t n) {
-    const unsigned char *l = vl, *r = vr;
-    for(; n && *l == *r; n--, l++, r++);
-    return n ? *l-*r : 0;
-}

+ 0 - 2
doc/building.rst

@@ -196,8 +196,6 @@ be visible in the cmake GUIs.
 **UA_ENABLE_GENERATE_NAMESPACE0**
    Generate and load UA XML Namespace 0 definition
    ``UA_GENERATE_NAMESPACE0_FILE`` is used to specify the file for NS0 generation from namespace0 folder. Default value is ``Opc.Ua.NodeSet2.xml``
-**UA_ENABLE_EMBEDDED_LIBC**
-   Use a custom implementation of some libc functions that might be missing on embedded targets (e.g. string handling).
 **UA_ENABLE_NONSTANDARD_UDP**
    Enable udp extension
 

+ 3 - 18
include/ua_config.h.in

@@ -31,7 +31,6 @@ extern "C" {
 /* Advanced Options */
 #cmakedefine UA_ENABLE_STATUSCODE_DESCRIPTIONS
 #cmakedefine UA_ENABLE_TYPENAMES
-#cmakedefine UA_ENABLE_EMBEDDED_LIBC
 #cmakedefine UA_ENABLE_DETERMINISTIC_RNG
 #cmakedefine UA_ENABLE_GENERATE_NAMESPACE0
 #cmakedefine UA_ENABLE_NONSTANDARD_UDP
@@ -44,8 +43,9 @@ extern "C" {
 #cmakedefine UA_DEBUG_DUMP_PKGS
 
 /**
- * C99 Integers
- * ------------ */
+ * C99 Definitions
+ * --------------- */
+#include <string.h>
 #include <stddef.h>
 
 /* Include stdint.h and stdbool.h or workaround for older Visual Studios */
@@ -188,21 +188,6 @@ extern "C" {
 # define UA_DEPRECATED
 #endif
 
-/**
- * Basic Libc Definitions
- * ------------------------
- * The header ``string.h`` is defined in the C-standard. If no libc is provided
- * (e.g. on some embedded target), use the following definitions and the
- * implementation in ``/deps/libc_string.c`` */
-#ifndef UA_ENABLE_EMBEDDED_LIBC
-# include <string.h>
-#else
-  void *memcpy(void *UA_RESTRICT dest, const void *UA_RESTRICT src, size_t n);
-  void *memset(void *dest, int c, size_t n);
-  size_t strlen(const char *s);
-  int memcmp(const void *vl, const void *vr, size_t n);
-#endif
-
 /**
  * Detect Binary Overlaying for Encoding
  * -------------------------------------