about summary refs log tree commit diff homepage
diff options
context:
space:
mode:
authorJulian Büning <julian.buening@rwth-aachen.de>2019-08-31 23:44:56 +0200
committerMartinNowack <martin.nowack@gmail.com>2019-10-31 15:35:05 +0000
commita4f386919bee975c05eced0e56e99dc0d59599ef (patch)
treece674435f9345d9d40427629d083f18a837641f4
parente32ae5ae50165593b82cffb6e946532618000933 (diff)
downloadklee-a4f386919bee975c05eced0e56e99dc0d59599ef.tar.gz
klee-libc: add bcmp
-rw-r--r--runtime/klee-libc/bcmp.c19
-rw-r--r--test/Runtime/FreeStanding/freestanding_only.c1
2 files changed, 20 insertions, 0 deletions
diff --git a/runtime/klee-libc/bcmp.c b/runtime/klee-libc/bcmp.c
new file mode 100644
index 00000000..23e1c233
--- /dev/null
+++ b/runtime/klee-libc/bcmp.c
@@ -0,0 +1,19 @@
+/*===-- bcmp.c ------------------------------------------------------------===//
+//
+//                     The KLEE Symbolic Virtual Machine
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===*/
+
+#include <strings.h>
+
+int bcmp(const void *s1, const void *s2, size_t n) {
+  const unsigned char *p1 = s1, *p2 = s2;
+  while (--n != 0) {
+    if (*p1++ != *p2++)
+      return 1;
+  }
+  return 0;
+}
diff --git a/test/Runtime/FreeStanding/freestanding_only.c b/test/Runtime/FreeStanding/freestanding_only.c
index 0f03c84c..a6d1b0d4 100644
--- a/test/Runtime/FreeStanding/freestanding_only.c
+++ b/test/Runtime/FreeStanding/freestanding_only.c
@@ -26,6 +26,7 @@ int main(int argc, char **argv) {
 
   assert(memcmp(src, dst, LENGTH) == 0);
   // CHECK-NOT: calling external: memcmp
+  // CHECK-NOT: calling external: bcmp
 
   assert(*src == 42);
   assert(*src == *dst);