Author: Schrodinger ZHU Yifan
Date: 2024-05-09T21:42:30-04:00
New Revision: ad34b7954b7e1ca82660108709c793b251785728

URL: 
https://github.com/llvm/llvm-project/commit/ad34b7954b7e1ca82660108709c793b251785728
DIFF: 
https://github.com/llvm/llvm-project/commit/ad34b7954b7e1ca82660108709c793b251785728.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
    libc/src/time/gpu/CMakeLists.txt
    libc/src/time/gpu/clock.cpp
    libc/src/time/gpu/time_utils.h

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

diff  --git a/libc/src/time/gpu/CMakeLists.txt 
b/libc/src/time/gpu/CMakeLists.txt
index bb79d92399b37..088271d881911 100644
--- a/libc/src/time/gpu/CMakeLists.txt
+++ b/libc/src/time/gpu/CMakeLists.txt
@@ -4,6 +4,9 @@ add_object_library(
     time_utils.cpp
   HDRS
     time_utils.h
+  DEPENDS
+    libc.hdr.types.clock_t
+    libc.hdr.time_macros
 )
 
 add_entrypoint_object(

diff  --git a/libc/src/time/gpu/clock.cpp b/libc/src/time/gpu/clock.cpp
index 86cc97e2a3bfb..8ddfc27975bba 100644
--- a/libc/src/time/gpu/clock.cpp
+++ b/libc/src/time/gpu/clock.cpp
@@ -6,9 +6,8 @@
 //
 
//===----------------------------------------------------------------------===//
 
-#include "time_utils.h"
-
 #include "src/time/clock.h"
+#include "src/time/gpu/time_utils.h"
 
 namespace LIBC_NAMESPACE {
 

diff  --git a/libc/src/time/gpu/time_utils.h b/libc/src/time/gpu/time_utils.h
index 8a9a5f0f65b89..3f1fd11c1791c 100644
--- a/libc/src/time/gpu/time_utils.h
+++ b/libc/src/time/gpu/time_utils.h
@@ -9,8 +9,9 @@
 #ifndef LLVM_LIBC_SRC_TIME_GPU_TIME_UTILS_H
 #define LLVM_LIBC_SRC_TIME_GPU_TIME_UTILS_H
 
+#include "hdr/time_macros.h"
+#include "hdr/types/clock_t.h"
 #include "src/__support/GPU/utils.h"
-
 namespace LIBC_NAMESPACE {
 
 #if defined(LIBC_TARGET_ARCH_IS_AMDGPU)


        
_______________________________________________
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits

Reply via email to