[libc-commits] [libc] 3cc2161 - [libc] Move the x86_64 syscall functions to OSUtil.
Siva Chandra Reddy via libc-commits
libc-commits at lists.llvm.org
Wed Dec 22 13:49:05 PST 2021
Author: Siva Chandra Reddy
Date: 2021-12-22T21:48:57Z
New Revision: 3cc2161c897ca6c9f1ff09fbc610a6ae40b3b566
URL: https://github.com/llvm/llvm-project/commit/3cc2161c897ca6c9f1ff09fbc610a6ae40b3b566
DIFF: https://github.com/llvm/llvm-project/commit/3cc2161c897ca6c9f1ff09fbc610a6ae40b3b566.diff
LOG: [libc] Move the x86_64 syscall functions to OSUtil.
Reviewed By: michaelrj, lntue
Differential Revision: https://reviews.llvm.org/D116177
Added:
libc/src/__support/OSUtil/linux/syscall.h
libc/src/__support/OSUtil/linux/x86_64/CMakeLists.txt
libc/src/__support/OSUtil/linux/x86_64/syscall.h
libc/src/__support/OSUtil/syscall.h
libc/test/src/__support/OSUtil/CMakeLists.txt
libc/test/src/__support/OSUtil/linux/CMakeLists.txt
libc/test/src/__support/OSUtil/linux/x86_64/CMakeLists.txt
libc/test/src/__support/OSUtil/linux/x86_64/syscall_test.cpp
Modified:
libc/config/linux/CMakeLists.txt
libc/loader/linux/x86_64/CMakeLists.txt
libc/loader/linux/x86_64/start.cpp
libc/src/__support/OSUtil/CMakeLists.txt
libc/src/__support/OSUtil/linux/CMakeLists.txt
libc/src/__support/OSUtil/linux/io.h
libc/src/__support/OSUtil/linux/quick_exit.h
libc/src/assert/CMakeLists.txt
libc/src/assert/__assert_fail.cpp
libc/src/signal/linux/CMakeLists.txt
libc/src/signal/linux/__restore.cpp
libc/src/signal/linux/signal.h
libc/src/stdlib/linux/CMakeLists.txt
libc/src/stdlib/linux/_Exit.cpp
libc/src/sys/mman/linux/CMakeLists.txt
libc/src/sys/mman/linux/mmap.cpp
libc/src/sys/mman/linux/munmap.cpp
libc/src/threads/linux/CMakeLists.txt
libc/src/threads/linux/CndVar.h
libc/src/threads/linux/Mutex.h
libc/src/threads/linux/call_once.cpp
libc/src/threads/linux/thrd_create.cpp
libc/src/threads/linux/thrd_join.cpp
libc/src/unistd/linux/CMakeLists.txt
libc/src/unistd/linux/write.cpp
libc/test/CMakeLists.txt
libc/test/src/__support/CMakeLists.txt
Removed:
libc/config/linux/syscall.h.def
libc/config/linux/x86_64/syscall.h.inc
libc/test/config/CMakeLists.txt
libc/test/config/linux/CMakeLists.txt
libc/test/config/linux/x86_64/CMakeLists.txt
libc/test/config/linux/x86_64/syscall_test.cpp
################################################################################
diff --git a/libc/config/linux/CMakeLists.txt b/libc/config/linux/CMakeLists.txt
index e3a00189a2ad8..bc42557f3db95 100644
--- a/libc/config/linux/CMakeLists.txt
+++ b/libc/config/linux/CMakeLists.txt
@@ -1,15 +1,3 @@
-add_gen_header(
- linux_syscall_h
- DEF_FILE syscall.h.def
- GEN_HDR syscall.h
- PARAMS
- inline_syscalls=${LIBC_TARGET_ARCHITECTURE}/syscall.h.inc
- DATA_FILES
- ${LIBC_TARGET_ARCHITECTURE}/syscall.h.inc
- DEPENDS
- libc.src.__support.common
-)
-
add_header(
app_h
HDR
diff --git a/libc/loader/linux/x86_64/CMakeLists.txt b/libc/loader/linux/x86_64/CMakeLists.txt
index ceaa94ee11a32..75b8a23802e7b 100644
--- a/libc/loader/linux/x86_64/CMakeLists.txt
+++ b/libc/loader/linux/x86_64/CMakeLists.txt
@@ -3,9 +3,9 @@ add_loader_object(
SRC
start.cpp
DEPENDS
- libc.config.linux.linux_syscall_h
libc.config.linux.app_h
libc.include.sys_syscall
+ libc.src.__support.OSUtil.osutil
libc.src.string.memcpy
libc.src.sys.mman.mmap
COMPILE_OPTIONS
diff --git a/libc/loader/linux/x86_64/start.cpp b/libc/loader/linux/x86_64/start.cpp
index 320fda96105bf..55ae003919270 100644
--- a/libc/loader/linux/x86_64/start.cpp
+++ b/libc/loader/linux/x86_64/start.cpp
@@ -7,9 +7,9 @@
//===----------------------------------------------------------------------===//
#include "config/linux/app.h"
-#include "config/linux/syscall.h"
#include "include/sys/mman.h"
#include "include/sys/syscall.h"
+#include "src/__support/OSUtil/syscall.h"
#include "src/string/memcpy.h"
#include "src/sys/mman/mmap.h"
diff --git a/libc/src/__support/OSUtil/CMakeLists.txt b/libc/src/__support/OSUtil/CMakeLists.txt
index b0f7ac86ffa55..028a9c06123c0 100644
--- a/libc/src/__support/OSUtil/CMakeLists.txt
+++ b/libc/src/__support/OSUtil/CMakeLists.txt
@@ -5,6 +5,7 @@ add_header_library(
HDRS
io.h
quick_exit.h
+ syscall.h
DEPENDS
libc.src.__support.OSUtil.linux.linux_util
)
diff --git a/libc/src/__support/OSUtil/linux/CMakeLists.txt b/libc/src/__support/OSUtil/linux/CMakeLists.txt
index 38286147a9141..4b0f5d70a0a24 100644
--- a/libc/src/__support/OSUtil/linux/CMakeLists.txt
+++ b/libc/src/__support/OSUtil/linux/CMakeLists.txt
@@ -1,10 +1,12 @@
+add_subdirectory(x86_64)
+
add_header_library(
linux_util
HDRS
io.h
quick_exit.h
+ syscall.h
DEPENDS
- libc.config.linux.linux_syscall_h
- libc.include.sys_syscall
- libc.src.string.string_utils
+ .x86_64.linux_x86_64_util
+ libc.src.__support.common
)
diff --git a/libc/src/__support/OSUtil/linux/io.h b/libc/src/__support/OSUtil/linux/io.h
index 5aaa544b51421..71830476bfff1 100644
--- a/libc/src/__support/OSUtil/linux/io.h
+++ b/libc/src/__support/OSUtil/linux/io.h
@@ -9,9 +9,9 @@
#ifndef LLVM_LIBC_SRC_SUPPORT_OSUTIL_LINUX_IO_H
#define LLVM_LIBC_SRC_SUPPORT_OSUTIL_LINUX_IO_H
-#include "config/linux/syscall.h" // For internal syscall function.
-#include "include/sys/syscall.h" // For syscall numbers.
+#include "include/sys/syscall.h" // For syscall numbers.
#include "src/string/string_utils.h"
+#include "syscall.h" // For internal syscall function.
namespace __llvm_libc {
diff --git a/libc/src/__support/OSUtil/linux/quick_exit.h b/libc/src/__support/OSUtil/linux/quick_exit.h
index 932959d265b14..eb9d86f446cfe 100644
--- a/libc/src/__support/OSUtil/linux/quick_exit.h
+++ b/libc/src/__support/OSUtil/linux/quick_exit.h
@@ -9,8 +9,8 @@
#ifndef LLVM_LIBC_SRC_SUPPORT_OSUTIL_LINUX_QUICK_EXIT_H
#define LLVM_LIBC_SRC_SUPPORT_OSUTIL_LINUX_QUICK_EXIT_H
-#include "config/linux/syscall.h" // For internal syscall function.
-#include "include/sys/syscall.h" // For syscall numbers.
+#include "include/sys/syscall.h" // For syscall numbers.
+#include "syscall.h" // For internal syscall function.
namespace __llvm_libc {
diff --git a/libc/src/__support/OSUtil/linux/syscall.h b/libc/src/__support/OSUtil/linux/syscall.h
new file mode 100644
index 0000000000000..754883e8a667f
--- /dev/null
+++ b/libc/src/__support/OSUtil/linux/syscall.h
@@ -0,0 +1,18 @@
+//===----------------------- Linux syscalls ---------------------*- 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_SRC_SUPPORT_OSUTIL_LINUX_SYSCALL_H
+#define LLVM_LIBC_SRC_SUPPORT_OSUTIL_LINUX_SYSCALL_H
+
+#include "src/__support/architectures.h"
+
+#ifdef LLVM_LIBC_ARCH_X86_64
+#include "x86_64/syscall.h"
+#endif
+
+#endif // LLVM_LIBC_SRC_SUPPORT_OSUTIL_LINUX_SYSCALL_H
diff --git a/libc/src/__support/OSUtil/linux/x86_64/CMakeLists.txt b/libc/src/__support/OSUtil/linux/x86_64/CMakeLists.txt
new file mode 100644
index 0000000000000..a7f2d74e6353e
--- /dev/null
+++ b/libc/src/__support/OSUtil/linux/x86_64/CMakeLists.txt
@@ -0,0 +1,7 @@
+add_header_library(
+ linux_x86_64_util
+ HDRS
+ syscall.h
+ DEPENDS
+ libc.src.__support.common
+)
diff --git a/libc/config/linux/x86_64/syscall.h.inc b/libc/src/__support/OSUtil/linux/x86_64/syscall.h
similarity index 93%
rename from libc/config/linux/x86_64/syscall.h.inc
rename to libc/src/__support/OSUtil/linux/x86_64/syscall.h
index ee3b5e5bfc0d7..77d139806271f 100644
--- a/libc/config/linux/x86_64/syscall.h.inc
+++ b/libc/src/__support/OSUtil/linux/x86_64/syscall.h
@@ -1,4 +1,4 @@
-//===------------ inline implementation of x86_64 syscalls ----------------===//
+//===---------- inline implementation of x86_64 syscalls ----------* C++ *-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -6,7 +6,8 @@
//
//===----------------------------------------------------------------------===//
-%%begin()
+#ifndef LLVM_LIBC_SRC_SUPPORT_OSUTIL_LINUX_X86_64_SYSCALL_H
+#define LLVM_LIBC_SRC_SUPPORT_OSUTIL_LINUX_X86_64_SYSCALL_H
#include "src/__support/common.h"
@@ -100,7 +101,8 @@ __attribute__((always_inline)) inline long syscall(long __number, Ts... ts) {
return syscall(__number, (long)ts...);
}
-
#undef SYSCALL_CLOBBER_LIST
} // namespace __llvm_libc
+
+#endif // LLVM_LIBC_SRC_SUPPORT_OSUTIL_LINUX_X86_64_SYSCALL_H
diff --git a/libc/config/linux/syscall.h.def b/libc/src/__support/OSUtil/syscall.h
similarity index 65%
rename from libc/config/linux/syscall.h.def
rename to libc/src/__support/OSUtil/syscall.h
index 0daceaf00dded..b1137275a86f0 100644
--- a/libc/config/linux/syscall.h.def
+++ b/libc/src/__support/OSUtil/syscall.h
@@ -6,9 +6,11 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLVM_LIBC_CONFIG_LINUX_SYSCALL_H
-#define LLVM_LIBC_CONFIG_LINUX_SYSCALL_H
+#ifndef LLVM_LIBC_SRC_SUPPORT_OSUTIL_SYSCALL_H
+#define LLVM_LIBC_SRC_SUPPORT_OSUTIL_SYSCALL_H
-%%include_file(${inline_syscalls})
+#ifdef __unix__
+#include "linux/syscall.h"
+#endif
-#endif // LLVM_LIBC_CONFIG_LINUX_SYSCALL_H
+#endif // LLVM_LIBC_SRC_SUPPORT_OSUTIL_SYSCALL_H
diff --git a/libc/src/assert/CMakeLists.txt b/libc/src/assert/CMakeLists.txt
index 36123cc6bd41c..7f82017e51c54 100644
--- a/libc/src/assert/CMakeLists.txt
+++ b/libc/src/assert/CMakeLists.txt
@@ -8,7 +8,7 @@ add_entrypoint_object(
DEPENDS
# These two dependencies are temporary and should be replaced by fprintf
# later.
- libc.config.linux.linux_syscall_h
+ libc.src.__support.OSUtil.osutil
libc.include.sys_syscall
libc.src.stdlib.abort
)
diff --git a/libc/src/assert/__assert_fail.cpp b/libc/src/assert/__assert_fail.cpp
index 0fe2ca6da87c1..93c176a622316 100644
--- a/libc/src/assert/__assert_fail.cpp
+++ b/libc/src/assert/__assert_fail.cpp
@@ -10,8 +10,8 @@
#include "src/stdlib/abort.h"
// These includes are temporary.
-#include "config/linux/syscall.h" // For internal syscall function.
#include "include/sys/syscall.h" // For syscall numbers.
+#include "src/__support/OSUtil/syscall.h" // For internal syscall function.
namespace __llvm_libc {
diff --git a/libc/src/signal/linux/CMakeLists.txt b/libc/src/signal/linux/CMakeLists.txt
index fc4a7aa32bf2a..419146f5bd447 100644
--- a/libc/src/signal/linux/CMakeLists.txt
+++ b/libc/src/signal/linux/CMakeLists.txt
@@ -7,9 +7,9 @@ add_entrypoint_object(
signal.h
../raise.h
DEPENDS
- libc.config.linux.linux_syscall_h
libc.include.signal
libc.include.sys_syscall
+ libc.src.__support.OSUtil.osutil
)
add_object_library(
@@ -25,8 +25,8 @@ add_object_library(
# asan creates asan.module_ctor which uses stack space, causing warnings.
-fno-sanitize=address
DEPENDS
- libc.config.linux.linux_syscall_h
libc.include.sys_syscall
+ libc.src.__support.OSUtil.osutil
)
add_entrypoint_object(
@@ -38,9 +38,9 @@ add_entrypoint_object(
../sigaction.h
DEPENDS
.__restore
- libc.config.linux.linux_syscall_h
libc.include.signal
libc.include.sys_syscall
+ libc.src.__support.OSUtil.osutil
libc.src.errno.__errno_location
)
@@ -52,9 +52,9 @@ add_entrypoint_object(
signal.h
../sigprocmask.h
DEPENDS
- libc.config.linux.linux_syscall_h
libc.include.signal
libc.include.sys_syscall
+ libc.src.__support.OSUtil.osutil
libc.src.errno.__errno_location
)
diff --git a/libc/src/signal/linux/__restore.cpp b/libc/src/signal/linux/__restore.cpp
index 8ce848f4960b5..c648ddb4cb150 100644
--- a/libc/src/signal/linux/__restore.cpp
+++ b/libc/src/signal/linux/__restore.cpp
@@ -10,8 +10,8 @@
// strongly control the options this file is compiled with. __restore_rt cannot
// make any stack allocations so we must ensure this.
-#include "config/linux/syscall.h"
#include "include/sys/syscall.h"
+#include "src/__support/OSUtil/syscall.h"
namespace __llvm_libc {
diff --git a/libc/src/signal/linux/signal.h b/libc/src/signal/linux/signal.h
index a59a56ced5d6a..fd312d79ed72e 100644
--- a/libc/src/signal/linux/signal.h
+++ b/libc/src/signal/linux/signal.h
@@ -9,8 +9,8 @@
#ifndef LLVM_LIBC_SRC_SIGNAL_LINUX_SIGNAL_H
#define LLVM_LIBC_SRC_SIGNAL_LINUX_SIGNAL_H
-#include "config/linux/syscall.h" // For internal syscall function.
-#include "include/sys/syscall.h" // For syscall numbers.
+#include "include/sys/syscall.h" // For syscall numbers.
+#include "src/__support/OSUtil/syscall.h" // For internal syscall function.
#include "include/signal.h"
diff --git a/libc/src/stdlib/linux/CMakeLists.txt b/libc/src/stdlib/linux/CMakeLists.txt
index 27e00a35c70f3..c5130c11ed915 100644
--- a/libc/src/stdlib/linux/CMakeLists.txt
+++ b/libc/src/stdlib/linux/CMakeLists.txt
@@ -6,6 +6,6 @@ add_entrypoint_object(
../_Exit.h
DEPENDS
libc.include.sys_syscall
- libc.config.linux.linux_syscall_h
libc.include.stdlib
+ libc.src.__support.OSUtil.osutil
)
diff --git a/libc/src/stdlib/linux/_Exit.cpp b/libc/src/stdlib/linux/_Exit.cpp
index 7fdd60ffe9bc6..51b0a48c7521b 100644
--- a/libc/src/stdlib/linux/_Exit.cpp
+++ b/libc/src/stdlib/linux/_Exit.cpp
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#include "config/linux/syscall.h" // For internal syscall function.
-#include "include/sys/syscall.h" // For syscall numbers.
+#include "include/sys/syscall.h" // For syscall numbers.
+#include "src/__support/OSUtil/syscall.h" // For internal syscall function.
#include "src/__support/common.h"
#include "src/stdlib/_Exit.h"
diff --git a/libc/src/sys/mman/linux/CMakeLists.txt b/libc/src/sys/mman/linux/CMakeLists.txt
index 7bf7c2f96d2d0..949d965fdbe91 100644
--- a/libc/src/sys/mman/linux/CMakeLists.txt
+++ b/libc/src/sys/mman/linux/CMakeLists.txt
@@ -5,9 +5,9 @@ add_entrypoint_object(
HDRS
../mmap.h
DEPENDS
- libc.config.linux.linux_syscall_h
libc.include.sys_mman
libc.include.sys_syscall
+ libc.src.__support.OSUtil.osutil
libc.src.errno.__errno_location
)
@@ -18,8 +18,8 @@ add_entrypoint_object(
HDRS
../munmap.h
DEPENDS
- libc.config.linux.linux_syscall_h
libc.include.sys_mman
libc.include.sys_syscall
+ libc.src.__support.OSUtil.osutil
libc.src.errno.__errno_location
)
diff --git a/libc/src/sys/mman/linux/mmap.cpp b/libc/src/sys/mman/linux/mmap.cpp
index 31e114a7f66b9..0447ef1298915 100644
--- a/libc/src/sys/mman/linux/mmap.cpp
+++ b/libc/src/sys/mman/linux/mmap.cpp
@@ -8,8 +8,8 @@
#include "src/sys/mman/mmap.h"
-#include "config/linux/syscall.h" // For internal syscall function.
-#include "include/sys/syscall.h" // For syscall numbers.
+#include "include/sys/syscall.h" // For syscall numbers.
+#include "src/__support/OSUtil/syscall.h" // For internal syscall function.
#include "src/__support/common.h"
#include "src/errno/llvmlibc_errno.h"
diff --git a/libc/src/sys/mman/linux/munmap.cpp b/libc/src/sys/mman/linux/munmap.cpp
index fd89773cc8291..7801a637f23f1 100644
--- a/libc/src/sys/mman/linux/munmap.cpp
+++ b/libc/src/sys/mman/linux/munmap.cpp
@@ -8,8 +8,8 @@
#include "src/sys/mman/munmap.h"
-#include "config/linux/syscall.h" // For internal syscall function.
-#include "include/sys/syscall.h" // For syscall numbers.
+#include "include/sys/syscall.h" // For syscall numbers.
+#include "src/__support/OSUtil/syscall.h" // For internal syscall function.
#include "src/__support/common.h"
#include "src/errno/llvmlibc_errno.h"
diff --git a/libc/src/threads/linux/CMakeLists.txt b/libc/src/threads/linux/CMakeLists.txt
index e9fc8d2d9c443..fcc3381e68bb7 100644
--- a/libc/src/threads/linux/CMakeLists.txt
+++ b/libc/src/threads/linux/CMakeLists.txt
@@ -16,9 +16,9 @@ add_entrypoint_object(
../call_once.h
DEPENDS
.threads_utils
- libc.config.linux.linux_syscall_h
libc.include.sys_syscall
libc.include.threads
+ libc.src.__support.OSUtil.osutil
)
add_header_library(
@@ -30,9 +30,9 @@ add_header_library(
Thread.h
DEPENDS
.thread_start_args_h
- libc.config.linux.linux_syscall_h
libc.include.sys_syscall
libc.include.threads
+ libc.src.__support.OSUtil.osutil
)
add_entrypoint_object(
@@ -43,11 +43,11 @@ add_entrypoint_object(
../thrd_create.h
DEPENDS
.threads_utils
- libc.config.linux.linux_syscall_h
libc.include.errno
libc.include.sys_syscall
libc.include.threads
libc.src.__support.common
+ libc.src.__support.OSUtil.osutil
libc.src.errno.__errno_location
libc.src.sys.mman.mmap
COMPILE_OPTIONS
@@ -64,11 +64,11 @@ add_entrypoint_object(
../thrd_join.h
DEPENDS
.threads_utils
- libc.config.linux.linux_syscall_h
libc.include.sys_syscall
libc.include.threads
- libc.src.sys.mman.munmap
libc.src.__support.common
+ libc.src.__support.OSUtil.osutil
+ libc.src.sys.mman.munmap
)
add_entrypoint_object(
diff --git a/libc/src/threads/linux/CndVar.h b/libc/src/threads/linux/CndVar.h
index 5d9ced5d64576..7e531c87ff1f8 100644
--- a/libc/src/threads/linux/CndVar.h
+++ b/libc/src/threads/linux/CndVar.h
@@ -12,9 +12,9 @@
#include "Futex.h"
#include "Mutex.h"
-#include "config/linux/syscall.h" // For syscall functions.
-#include "include/sys/syscall.h" // For syscall numbers.
-#include "include/threads.h" // For values like thrd_success etc.
+#include "include/sys/syscall.h" // For syscall numbers.
+#include "include/threads.h" // For values like thrd_success etc.
+#include "src/__support/OSUtil/syscall.h" // For syscall functions.
#include <linux/futex.h> // For futex operations.
#include <stdatomic.h> // For atomic operations
diff --git a/libc/src/threads/linux/Mutex.h b/libc/src/threads/linux/Mutex.h
index f6033c92eaf6e..a7b06d4c2babf 100644
--- a/libc/src/threads/linux/Mutex.h
+++ b/libc/src/threads/linux/Mutex.h
@@ -11,9 +11,9 @@
#include "Futex.h"
-#include "config/linux/syscall.h" // For syscall functions.
-#include "include/sys/syscall.h" // For syscall numbers.
-#include "include/threads.h" // For values like thrd_success etc.
+#include "include/sys/syscall.h" // For syscall numbers.
+#include "include/threads.h" // For values like thrd_success etc.
+#include "src/__support/OSUtil/syscall.h" // For syscall functions.
#include <linux/futex.h> // For futex operations.
#include <stdatomic.h>
diff --git a/libc/src/threads/linux/call_once.cpp b/libc/src/threads/linux/call_once.cpp
index 1bcb46f6b0a3b..9b9664634a1f3 100644
--- a/libc/src/threads/linux/call_once.cpp
+++ b/libc/src/threads/linux/call_once.cpp
@@ -7,9 +7,9 @@
//===----------------------------------------------------------------------===//
#include "src/threads/call_once.h"
-#include "config/linux/syscall.h" // For syscall functions.
-#include "include/sys/syscall.h" // For syscall numbers.
-#include "include/threads.h" // For call_once related type definition.
+#include "include/sys/syscall.h" // For syscall numbers.
+#include "include/threads.h" // For call_once related type definition.
+#include "src/__support/OSUtil/syscall.h" // For syscall functions.
#include "src/__support/common.h"
#include "src/threads/linux/Futex.h"
diff --git a/libc/src/threads/linux/thrd_create.cpp b/libc/src/threads/linux/thrd_create.cpp
index f2464d4075eaa..5421c96775b7f 100644
--- a/libc/src/threads/linux/thrd_create.cpp
+++ b/libc/src/threads/linux/thrd_create.cpp
@@ -7,11 +7,11 @@
//===----------------------------------------------------------------------===//
#include "src/threads/thrd_create.h"
-#include "config/linux/syscall.h" // For syscall function.
-#include "include/errno.h" // For E* error values.
-#include "include/sys/mman.h" // For PROT_* and MAP_* definitions.
-#include "include/sys/syscall.h" // For syscall numbers.
-#include "include/threads.h" // For thrd_* type definitions.
+#include "include/errno.h" // For E* error values.
+#include "include/sys/mman.h" // For PROT_* and MAP_* definitions.
+#include "include/sys/syscall.h" // For syscall numbers.
+#include "include/threads.h" // For thrd_* type definitions.
+#include "src/__support/OSUtil/syscall.h" // For syscall function.
#include "src/__support/common.h"
#include "src/errno/llvmlibc_errno.h"
#include "src/sys/mman/mmap.h"
diff --git a/libc/src/threads/linux/thrd_join.cpp b/libc/src/threads/linux/thrd_join.cpp
index 3c779495def58..f55f5a3af3f5f 100644
--- a/libc/src/threads/linux/thrd_join.cpp
+++ b/libc/src/threads/linux/thrd_join.cpp
@@ -7,9 +7,9 @@
//===----------------------------------------------------------------------===//
#include "src/threads/thrd_join.h"
-#include "config/linux/syscall.h" // For syscall function.
-#include "include/sys/syscall.h" // For syscall numbers.
-#include "include/threads.h" // For thrd_* type definitions.
+#include "include/sys/syscall.h" // For syscall numbers.
+#include "include/threads.h" // For thrd_* type definitions.
+#include "src/__support/OSUtil/syscall.h" // For syscall function.
#include "src/__support/common.h"
#include "src/sys/mman/munmap.h"
#include "src/threads/linux/Futex.h"
diff --git a/libc/src/unistd/linux/CMakeLists.txt b/libc/src/unistd/linux/CMakeLists.txt
index bd2cba708e69d..1c3fdf15a6a7b 100644
--- a/libc/src/unistd/linux/CMakeLists.txt
+++ b/libc/src/unistd/linux/CMakeLists.txt
@@ -6,7 +6,7 @@ add_entrypoint_object(
../write.h
DEPENDS
libc.include.unistd
- libc.config.linux.linux_syscall_h
libc.include.sys_syscall
+ libc.src.__support.OSUtil.osutil
libc.src.errno.__errno_location
)
diff --git a/libc/src/unistd/linux/write.cpp b/libc/src/unistd/linux/write.cpp
index de0efb9bf8deb..3554e3030943b 100644
--- a/libc/src/unistd/linux/write.cpp
+++ b/libc/src/unistd/linux/write.cpp
@@ -8,8 +8,8 @@
#include "src/unistd/write.h"
-#include "config/linux/syscall.h" // For internal syscall function.
-#include "include/sys/syscall.h" // For syscall numbers.
+#include "include/sys/syscall.h" // For syscall numbers.
+#include "src/__support/OSUtil/syscall.h" // For internal syscall function.
#include "src/__support/common.h"
#include "src/errno/llvmlibc_errno.h"
diff --git a/libc/test/CMakeLists.txt b/libc/test/CMakeLists.txt
index 3cf1f8d59d953..850d69345d29d 100644
--- a/libc/test/CMakeLists.txt
+++ b/libc/test/CMakeLists.txt
@@ -18,6 +18,5 @@ if(NOT LLVM_LIBC_FULL_BUILD)
return()
endif()
-add_subdirectory(config)
add_subdirectory(integration)
add_subdirectory(loader)
diff --git a/libc/test/config/CMakeLists.txt b/libc/test/config/CMakeLists.txt
deleted file mode 100644
index 52824d2705833..0000000000000
--- a/libc/test/config/CMakeLists.txt
+++ /dev/null
@@ -1 +0,0 @@
-add_subdirectory(${LIBC_TARGET_OS})
diff --git a/libc/test/config/linux/CMakeLists.txt b/libc/test/config/linux/CMakeLists.txt
deleted file mode 100644
index b449a33ec94c1..0000000000000
--- a/libc/test/config/linux/CMakeLists.txt
+++ /dev/null
@@ -1,5 +0,0 @@
-add_libc_testsuite(libc_linux_tests)
-
-if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${LIBC_TARGET_ARCHITECTURE})
- add_subdirectory(${LIBC_TARGET_ARCHITECTURE})
-endif()
diff --git a/libc/test/config/linux/x86_64/CMakeLists.txt b/libc/test/config/linux/x86_64/CMakeLists.txt
deleted file mode 100644
index 0436736eefd04..0000000000000
--- a/libc/test/config/linux/x86_64/CMakeLists.txt
+++ /dev/null
@@ -1,7 +0,0 @@
-add_libc_unittest(
- libc_linux_x86_64_syscall_unittest
- SUITE libc_linux_tests
- SRCS syscall_test.cpp
- DEPENDS
- libc.config.linux.linux_syscall_h
-)
diff --git a/libc/test/src/__support/CMakeLists.txt b/libc/test/src/__support/CMakeLists.txt
index d2367ef52f692..20d0e2d757459 100644
--- a/libc/test/src/__support/CMakeLists.txt
+++ b/libc/test/src/__support/CMakeLists.txt
@@ -48,3 +48,5 @@ add_custom_command(TARGET libc_str_to_float_comparison_test
DEPENDS ${float_test_file}
COMMENT "Test the strtof and strtod implementations against precomputed results."
VERBATIM)
+
+add_subdirectory(OSUtil)
diff --git a/libc/test/src/__support/OSUtil/CMakeLists.txt b/libc/test/src/__support/OSUtil/CMakeLists.txt
new file mode 100644
index 0000000000000..494218b4bb122
--- /dev/null
+++ b/libc/test/src/__support/OSUtil/CMakeLists.txt
@@ -0,0 +1,3 @@
+add_libc_testsuite(libc_osutil_tests)
+
+add_subdirectory(linux)
diff --git a/libc/test/src/__support/OSUtil/linux/CMakeLists.txt b/libc/test/src/__support/OSUtil/linux/CMakeLists.txt
new file mode 100644
index 0000000000000..7e2608e595f5b
--- /dev/null
+++ b/libc/test/src/__support/OSUtil/linux/CMakeLists.txt
@@ -0,0 +1 @@
+add_subdirectory(x86_64)
diff --git a/libc/test/src/__support/OSUtil/linux/x86_64/CMakeLists.txt b/libc/test/src/__support/OSUtil/linux/x86_64/CMakeLists.txt
new file mode 100644
index 0000000000000..b6f57eb41f729
--- /dev/null
+++ b/libc/test/src/__support/OSUtil/linux/x86_64/CMakeLists.txt
@@ -0,0 +1,7 @@
+add_libc_unittest(
+ syscall_unittest
+ SUITE libc_osutil_tests
+ SRCS syscall_test.cpp
+ DEPENDS
+ libc.src.__support.OSUtil.osutil
+)
diff --git a/libc/test/config/linux/x86_64/syscall_test.cpp b/libc/test/src/__support/OSUtil/linux/x86_64/syscall_test.cpp
similarity index 97%
rename from libc/test/config/linux/x86_64/syscall_test.cpp
rename to libc/test/src/__support/OSUtil/linux/x86_64/syscall_test.cpp
index eb2205aa4fb65..2f9816e968291 100644
--- a/libc/test/config/linux/x86_64/syscall_test.cpp
+++ b/libc/test/src/__support/OSUtil/linux/x86_64/syscall_test.cpp
@@ -6,10 +6,9 @@
//
//===----------------------------------------------------------------------===//
-#include "config/linux/syscall.h"
-#include "utils/UnitTest/Test.h"
-
#include "src/__support/CPP/Functional.h"
+#include "src/__support/OSUtil/syscall.h"
+#include "utils/UnitTest/Test.h"
TEST(LlvmLibcX86_64_SyscallTest, APITest) {
// We only do a signature test here. Actual functionality tests are
More information about the libc-commits
mailing list