From 188f72ab20d9523d6ffde8ad8361ecf17bb75946 Mon Sep 17 00:00:00 2001 From: Siva Chandra Reddy Date: Mon, 6 Jan 2020 10:38:45 -0800 Subject: [libc] Move implementations of strcat and strcpy to the string directory. Summary: Now that tests live in separate top-level directory, keeping the implementations of individual functions in a directory of their own is not meaningful. Hence, this change moves them into the higher level string directory. NFC intended. Reviewers: MaskRay Subscribers: mgorny, tschuett, libc-commits Tags: #libc-project Differential Revision: https://reviews.llvm.org/D72295 --- libc/src/string/CMakeLists.txt | 22 ++++++++++++++++++++-- libc/src/string/strcat.cpp | 23 +++++++++++++++++++++++ libc/src/string/strcat.h | 20 ++++++++++++++++++++ libc/src/string/strcat/CMakeLists.txt | 10 ---------- libc/src/string/strcat/strcat.cpp | 23 ----------------------- libc/src/string/strcat/strcat.h | 20 -------------------- libc/src/string/strcpy.cpp | 19 +++++++++++++++++++ libc/src/string/strcpy.h | 20 ++++++++++++++++++++ libc/src/string/strcpy/CMakeLists.txt | 9 --------- libc/src/string/strcpy/strcpy.cpp | 19 ------------------- libc/src/string/strcpy/strcpy.h | 20 -------------------- libc/test/src/string/strcat_test.cpp | 2 +- libc/test/src/string/strcpy_test.cpp | 2 +- 13 files changed, 104 insertions(+), 105 deletions(-) create mode 100644 libc/src/string/strcat.cpp create mode 100644 libc/src/string/strcat.h delete mode 100644 libc/src/string/strcat/CMakeLists.txt delete mode 100644 libc/src/string/strcat/strcat.cpp delete mode 100644 libc/src/string/strcat/strcat.h create mode 100644 libc/src/string/strcpy.cpp create mode 100644 libc/src/string/strcpy.h delete mode 100644 libc/src/string/strcpy/CMakeLists.txt delete mode 100644 libc/src/string/strcpy/strcpy.cpp delete mode 100644 libc/src/string/strcpy/strcpy.h (limited to 'libc') diff --git a/libc/src/string/CMakeLists.txt b/libc/src/string/CMakeLists.txt index 459d9489e3a..b53da211825 100644 --- a/libc/src/string/CMakeLists.txt +++ b/libc/src/string/CMakeLists.txt @@ -1,2 +1,20 @@ -add_subdirectory(strcpy) -add_subdirectory(strcat) +add_entrypoint_object( + strcat + SRCS + strcat.cpp + HDRS + strcat.h + DEPENDS + strcpy + string_h +) + +add_entrypoint_object( + strcpy + SRCS + strcpy.cpp + HDRS + strcpy.h + DEPENDS + string_h +) diff --git a/libc/src/string/strcat.cpp b/libc/src/string/strcat.cpp new file mode 100644 index 00000000000..366b1854e60 --- /dev/null +++ b/libc/src/string/strcat.cpp @@ -0,0 +1,23 @@ +//===-------------------- Implementation of strcat -----------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include "src/string/strcat.h" + +#include "src/__support/common.h" +#include "src/string/strcpy.h" + +namespace __llvm_libc { + +char *LLVM_LIBC_ENTRYPOINT(strcat)(char *dest, const char *src) { + // We do not yet have an implementaion of strlen in so we will use strlen + // from another libc. + __llvm_libc::strcpy(dest + ::strlen(dest), src); + return dest; +} + +} // namespace __llvm_libc diff --git a/libc/src/string/strcat.h b/libc/src/string/strcat.h new file mode 100644 index 00000000000..d3023e9757c --- /dev/null +++ b/libc/src/string/strcat.h @@ -0,0 +1,20 @@ +//===----------------- Implementation header for strcat -------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_LIBC_SRC_STRING_STRCAT_H +#define LLVM_LIBC_SRC_STRING_STRCAT_H + +#include + +namespace __llvm_libc { + +char *strcat(char *dest, const char *src); + +} // namespace __llvm_libc + +#endif // LLVM_LIBC_SRC_STRING_STRCAT_H diff --git a/libc/src/string/strcat/CMakeLists.txt b/libc/src/string/strcat/CMakeLists.txt deleted file mode 100644 index e37e4262b3e..00000000000 --- a/libc/src/string/strcat/CMakeLists.txt +++ /dev/null @@ -1,10 +0,0 @@ -add_entrypoint_object( - strcat - SRCS - strcat.cpp - HDRS - strcat.h - DEPENDS - strcpy - string_h -) diff --git a/libc/src/string/strcat/strcat.cpp b/libc/src/string/strcat/strcat.cpp deleted file mode 100644 index 09cc62d25e2..00000000000 --- a/libc/src/string/strcat/strcat.cpp +++ /dev/null @@ -1,23 +0,0 @@ -//===-------------------- Implementation of strcat -----------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#include "src/string/strcat/strcat.h" - -#include "src/__support/common.h" -#include "src/string/strcpy/strcpy.h" - -namespace __llvm_libc { - -char *LLVM_LIBC_ENTRYPOINT(strcat)(char *dest, const char *src) { - // We do not yet have an implementaion of strlen in so we will use strlen - // from another libc. - __llvm_libc::strcpy(dest + ::strlen(dest), src); - return dest; -} - -} // namespace __llvm_libc diff --git a/libc/src/string/strcat/strcat.h b/libc/src/string/strcat/strcat.h deleted file mode 100644 index d3023e9757c..00000000000 --- a/libc/src/string/strcat/strcat.h +++ /dev/null @@ -1,20 +0,0 @@ -//===----------------- Implementation header for strcat -------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_LIBC_SRC_STRING_STRCAT_H -#define LLVM_LIBC_SRC_STRING_STRCAT_H - -#include - -namespace __llvm_libc { - -char *strcat(char *dest, const char *src); - -} // namespace __llvm_libc - -#endif // LLVM_LIBC_SRC_STRING_STRCAT_H diff --git a/libc/src/string/strcpy.cpp b/libc/src/string/strcpy.cpp new file mode 100644 index 00000000000..22fe4ccffa4 --- /dev/null +++ b/libc/src/string/strcpy.cpp @@ -0,0 +1,19 @@ +//===-------------------- Implementation of strcpy -----------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include "src/string/strcpy.h" + +#include "src/__support/common.h" + +namespace __llvm_libc { + +char *LLVM_LIBC_ENTRYPOINT(strcpy)(char *dest, const char *src) { + return reinterpret_cast(::memcpy(dest, src, ::strlen(src) + 1)); +} + +} // namespace __llvm_libc diff --git a/libc/src/string/strcpy.h b/libc/src/string/strcpy.h new file mode 100644 index 00000000000..67710d8c84b --- /dev/null +++ b/libc/src/string/strcpy.h @@ -0,0 +1,20 @@ +//===----------------- Implementation header for strcpy -------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_LIBC_SRC_STRING_STRCPY_H +#define LLVM_LIBC_SRC_STRING_STRCPY_H + +#include + +namespace __llvm_libc { + +char *strcpy(char *dest, const char *src); + +} // namespace __llvm_libc + +#endif // LLVM_LIBC_SRC_STRING_STRCPY_H diff --git a/libc/src/string/strcpy/CMakeLists.txt b/libc/src/string/strcpy/CMakeLists.txt deleted file mode 100644 index 411333a73a8..00000000000 --- a/libc/src/string/strcpy/CMakeLists.txt +++ /dev/null @@ -1,9 +0,0 @@ -add_entrypoint_object( - strcpy - SRCS - strcpy.cpp - HDRS - strcpy.h - DEPENDS - string_h -) diff --git a/libc/src/string/strcpy/strcpy.cpp b/libc/src/string/strcpy/strcpy.cpp deleted file mode 100644 index 0dfb1e35e41..00000000000 --- a/libc/src/string/strcpy/strcpy.cpp +++ /dev/null @@ -1,19 +0,0 @@ -//===-------------------- Implementation of strcpy -----------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#include "src/string/strcpy/strcpy.h" - -#include "src/__support/common.h" - -namespace __llvm_libc { - -char *LLVM_LIBC_ENTRYPOINT(strcpy)(char *dest, const char *src) { - return reinterpret_cast(::memcpy(dest, src, ::strlen(src) + 1)); -} - -} // namespace __llvm_libc diff --git a/libc/src/string/strcpy/strcpy.h b/libc/src/string/strcpy/strcpy.h deleted file mode 100644 index 67710d8c84b..00000000000 --- a/libc/src/string/strcpy/strcpy.h +++ /dev/null @@ -1,20 +0,0 @@ -//===----------------- Implementation header for strcpy -------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_LIBC_SRC_STRING_STRCPY_H -#define LLVM_LIBC_SRC_STRING_STRCPY_H - -#include - -namespace __llvm_libc { - -char *strcpy(char *dest, const char *src); - -} // namespace __llvm_libc - -#endif // LLVM_LIBC_SRC_STRING_STRCPY_H diff --git a/libc/test/src/string/strcat_test.cpp b/libc/test/src/string/strcat_test.cpp index 3b8a7a7e447..fde432bcec8 100644 --- a/libc/test/src/string/strcat_test.cpp +++ b/libc/test/src/string/strcat_test.cpp @@ -8,7 +8,7 @@ #include -#include "src/string/strcat/strcat.h" +#include "src/string/strcat.h" #include "gtest/gtest.h" TEST(StrCatTest, EmptyDest) { diff --git a/libc/test/src/string/strcpy_test.cpp b/libc/test/src/string/strcpy_test.cpp index e68ea5103db..56f75ac9e5f 100644 --- a/libc/test/src/string/strcpy_test.cpp +++ b/libc/test/src/string/strcpy_test.cpp @@ -8,7 +8,7 @@ #include -#include "src/string/strcpy/strcpy.h" +#include "src/string/strcpy.h" #include "gtest/gtest.h" TEST(StrCpyTest, EmptyDest) { -- cgit v1.2.3