[libc-commits] [PATCH] D77948: [libc] Remove <functional> dependency in syscall_test.cpp
Alex Brachet via Phabricator via libc-commits
libc-commits at lists.llvm.org
Tue Apr 14 00:29:37 PDT 2020
This revision was automatically updated to reflect the committed changes.
Closed by commit rG54d13b5b2d92: [libc] Remove <functional> dependency in syscall_test.cpp (authored by abrachet).
Herald added a project: libc-project.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D77948/new/
https://reviews.llvm.org/D77948
Files:
libc/test/config/linux/x86_64/syscall_test.cpp
libc/utils/CPP/CMakeLists.txt
libc/utils/CPP/Functional.h
Index: libc/utils/CPP/Functional.h
===================================================================
--- /dev/null
+++ libc/utils/CPP/Functional.h
@@ -0,0 +1,30 @@
+//===-- Self contained functional header ------------------------*- C++ -*-===//
+//
+// 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_UTILS_CPP_FUNCTIONAL_H
+#define LLVM_LIBC_UTILS_CPP_FUNCTIONAL_H
+
+namespace __llvm_libc {
+namespace cpp {
+
+template <typename Func> class function;
+
+template <typename Ret, typename... Params> class function<Ret(Params...)> {
+ Ret (*func)(Params...) = nullptr;
+
+public:
+ constexpr function() = default;
+ template <typename Func> constexpr function(Func &&f) : func(f) {}
+
+ constexpr Ret operator()(Params... params) { return func(params...); }
+};
+
+} // namespace cpp
+} // namespace __llvm_libc
+
+#endif // LLVM_LIBC_UTILS_CPP_FUNCTIONAL_H
Index: libc/utils/CPP/CMakeLists.txt
===================================================================
--- libc/utils/CPP/CMakeLists.txt
+++ libc/utils/CPP/CMakeLists.txt
@@ -3,5 +3,7 @@
HDRS
Array.h
ArrayRef.h
+ Functional.h
+ StringRef.h
TypeTraits.h
)
Index: libc/test/config/linux/x86_64/syscall_test.cpp
===================================================================
--- libc/test/config/linux/x86_64/syscall_test.cpp
+++ libc/test/config/linux/x86_64/syscall_test.cpp
@@ -9,36 +9,36 @@
#include "config/linux/syscall.h"
#include "utils/UnitTest/Test.h"
-#include <functional>
+#include "utils/CPP/Functional.h"
TEST(X86_64_SyscallTest, APITest) {
// We only do a signature test here. Actual functionality tests are
// done by the unit tests of the syscall wrappers like mmap.
- std::function<long(long)> f([](long n) { return __llvm_libc::syscall(n); });
- std::function<long(long, long)> f1(
+ using __llvm_libc::cpp::function;
+
+ function<long(long)> f([](long n) { return __llvm_libc::syscall(n); });
+ function<long(long, long)> f1(
[](long n, long a1) { return __llvm_libc::syscall(n, a1); });
- std::function<long(long, long, long)> f2(
+ function<long(long, long, long)> f2(
[](long n, long a1, long a2) { return __llvm_libc::syscall(n, a1, a2); });
- std::function<long(long, long, long, long)> f3(
+ function<long(long, long, long, long)> f3(
[](long n, long a1, long a2, long a3) {
return __llvm_libc::syscall(n, a1, a2, a3);
});
- std::function<long(long, long, long, long, long)> f4(
+ function<long(long, long, long, long, long)> f4(
[](long n, long a1, long a2, long a3, long a4) {
return __llvm_libc::syscall(n, a1, a2, a3, a4);
});
- std::function<long(long, long, long, long, long, long)> f5(
+ function<long(long, long, long, long, long, long)> f5(
[](long n, long a1, long a2, long a3, long a4, long a5) {
return __llvm_libc::syscall(n, a1, a2, a3, a4, a5);
});
- std::function<long(long, long, long, long, long, long, long)> f6(
+ function<long(long, long, long, long, long, long, long)> f6(
[](long n, long a1, long a2, long a3, long a4, long a5, long a6) {
return __llvm_libc::syscall(n, a1, a2, a3, a4, a5, a6);
});
- std::function<long(long, void *)> notLongType(
- [](long n, void *a1) {
- return __llvm_libc::syscall(n, a1);
- });
+ function<long(long, void *)> notLongType(
+ [](long n, void *a1) { return __llvm_libc::syscall(n, a1); });
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D77948.257212.patch
Type: text/x-patch
Size: 3695 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libc-commits/attachments/20200414/98b1806c/attachment-0001.bin>
More information about the libc-commits
mailing list