[llvm-branch-commits] [libc] c8d3f1c - fix

Schrodinger ZHU Yifan via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Thu May 9 18:20:48 PDT 2024


Author: Schrodinger ZHU Yifan
Date: 2024-05-09T21:20:40-04:00
New Revision: c8d3f1c80b8b1d2caf53174539c0f17f24a80bef

URL: https://github.com/llvm/llvm-project/commit/c8d3f1c80b8b1d2caf53174539c0f17f24a80bef
DIFF: https://github.com/llvm/llvm-project/commit/c8d3f1c80b8b1d2caf53174539c0f17f24a80bef.diff

LOG: fix

Added: 
    libc/src/__support/time/linux/clock_gettime.h

Modified: 
    libc/src/__support/time/CMakeLists.txt
    libc/src/__support/time/clock_gettime.h
    libc/src/__support/time/linux/CMakeLists.txt
    libc/src/__support/time/linux/clock_gettime.cpp

Removed: 
    


################################################################################
diff  --git a/libc/src/__support/time/CMakeLists.txt b/libc/src/__support/time/CMakeLists.txt
index 36ce4f9dadb2c..e934ef7b9224a 100644
--- a/libc/src/__support/time/CMakeLists.txt
+++ b/libc/src/__support/time/CMakeLists.txt
@@ -2,9 +2,10 @@ if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${LIBC_TARGET_OS})
   add_subdirectory(${LIBC_TARGET_OS})
 endif()
 
-add_object_library(
+add_header_library(
   clock_gettime
-  ALIAS
+  HDRS
+    clock_gettime.h
   DEPENDS
     .${LIBC_TARGET_OS}.clock_gettime
 )

diff  --git a/libc/src/__support/time/clock_gettime.h b/libc/src/__support/time/clock_gettime.h
index 0655ccdc0028b..ef99339a4805e 100644
--- a/libc/src/__support/time/clock_gettime.h
+++ b/libc/src/__support/time/clock_gettime.h
@@ -8,16 +8,11 @@
 
 #ifndef LLVM_LIBC_SRC___SUPPORT_TIME_CLOCK_GETTIME_H
 #define LLVM_LIBC_SRC___SUPPORT_TIME_CLOCK_GETTIME_H
-#include "hdr/types/clockid_t.h"
-#include "hdr/types/struct_timespec.h"
-#include "src/__support/common.h"
 
-#include "src/__support/error_or.h"
-
-namespace LIBC_NAMESPACE {
-namespace internal {
-ErrorOr<int> clock_gettime(clockid_t clockid, timespec *ts);
-}
-} // namespace LIBC_NAMESPACE
+#ifdef __linux__
+#include "src/__support/time/linux/clock_gettime.h"
+#else
+#error "clock_gettime is not supported on this platform"
+#endif
 
 #endif // LLVM_LIBC_SRC___SUPPORT_TIME_CLOCK_GETTIME_H

diff  --git a/libc/src/__support/time/linux/CMakeLists.txt b/libc/src/__support/time/linux/CMakeLists.txt
index 034fa317ff6df..f04d550555e19 100644
--- a/libc/src/__support/time/linux/CMakeLists.txt
+++ b/libc/src/__support/time/linux/CMakeLists.txt
@@ -1,7 +1,7 @@
 add_object_library(
   clock_gettime
   HDRS
-    ../clock_gettime.h
+    clock_gettime.h
   SRCS
     clock_gettime.cpp
   DEPENDS

diff  --git a/libc/src/__support/time/linux/clock_gettime.cpp b/libc/src/__support/time/linux/clock_gettime.cpp
index 6a131df9ba593..7f266b282a391 100644
--- a/libc/src/__support/time/linux/clock_gettime.cpp
+++ b/libc/src/__support/time/linux/clock_gettime.cpp
@@ -6,9 +6,7 @@
 //
 //===----------------------------------------------------------------------===//
 
-#ifndef LLVM_LIBC_SRC___SUPPORT_TIME_LINUX_CLOCK_GETTIME_H
-#define LLVM_LIBC_SRC___SUPPORT_TIME_LINUX_CLOCK_GETTIME_H
-#include "src/__support/time/clock_gettime.h"
+#include "src/__support/time/linux/clock_gettime.h"
 #include "src/__support/OSUtil/syscall.h"
 #include <sys/syscall.h>
 namespace LIBC_NAMESPACE {
@@ -35,5 +33,3 @@ ErrorOr<int> clock_gettime(clockid_t clockid, timespec *ts) {
 
 } // namespace internal
 } // namespace LIBC_NAMESPACE
-
-#endif // LLVM_LIBC_SRC___SUPPORT_TIME_LINUX_CLOCK_GETTIME_H

diff  --git a/libc/src/__support/time/linux/clock_gettime.h b/libc/src/__support/time/linux/clock_gettime.h
new file mode 100644
index 0000000000000..b1572726f6301
--- /dev/null
+++ b/libc/src/__support/time/linux/clock_gettime.h
@@ -0,0 +1,23 @@
+//===--- clock_gettime linux implementation ---------------------*- 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_TIME_LINUX_CLOCK_GETTIME_H
+#define LLVM_LIBC_SRC___SUPPORT_TIME_LINUX_CLOCK_GETTIME_H
+#include "hdr/types/clockid_t.h"
+#include "hdr/types/struct_timespec.h"
+#include "src/__support/common.h"
+
+#include "src/__support/error_or.h"
+
+namespace LIBC_NAMESPACE {
+namespace internal {
+ErrorOr<int> clock_gettime(clockid_t clockid, timespec *ts);
+}
+} // namespace LIBC_NAMESPACE
+
+#endif // LLVM_LIBC_SRC___SUPPORT_TIME_LINUX_CLOCK_GETTIME_H


        


More information about the llvm-branch-commits mailing list