Skip to content

Commit ad34b79

Browse files
fix
1 parent a102e89 commit ad34b79

File tree

8 files changed

+39
-21
lines changed

8 files changed

+39
-21
lines changed

libc/src/__support/time/CMakeLists.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@ if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${LIBC_TARGET_OS})
22
add_subdirectory(${LIBC_TARGET_OS})
33
endif()
44

5-
add_object_library(
5+
add_header_library(
66
clock_gettime
7-
ALIAS
7+
HDRS
8+
clock_gettime.h
89
DEPENDS
910
.${LIBC_TARGET_OS}.clock_gettime
1011
)

libc/src/__support/time/clock_gettime.h

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,11 @@
88

99
#ifndef LLVM_LIBC_SRC___SUPPORT_TIME_CLOCK_GETTIME_H
1010
#define LLVM_LIBC_SRC___SUPPORT_TIME_CLOCK_GETTIME_H
11-
#include "hdr/types/clockid_t.h"
12-
#include "hdr/types/struct_timespec.h"
13-
#include "src/__support/common.h"
1411

15-
#include "src/__support/error_or.h"
16-
17-
namespace LIBC_NAMESPACE {
18-
namespace internal {
19-
ErrorOr<int> clock_gettime(clockid_t clockid, timespec *ts);
20-
}
21-
} // namespace LIBC_NAMESPACE
12+
#ifdef __linux__
13+
#include "src/__support/time/linux/clock_gettime.h"
14+
#else
15+
#error "clock_gettime is not supported on this platform"
16+
#endif
2217

2318
#endif // LLVM_LIBC_SRC___SUPPORT_TIME_CLOCK_GETTIME_H

libc/src/__support/time/linux/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
add_object_library(
22
clock_gettime
33
HDRS
4-
../clock_gettime.h
4+
clock_gettime.h
55
SRCS
66
clock_gettime.cpp
77
DEPENDS

libc/src/__support/time/linux/clock_gettime.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@
66
//
77
//===----------------------------------------------------------------------===//
88

9-
#ifndef LLVM_LIBC_SRC___SUPPORT_TIME_LINUX_CLOCK_GETTIME_H
10-
#define LLVM_LIBC_SRC___SUPPORT_TIME_LINUX_CLOCK_GETTIME_H
11-
#include "src/__support/time/clock_gettime.h"
9+
#include "src/__support/time/linux/clock_gettime.h"
1210
#include "src/__support/OSUtil/syscall.h"
1311
#include <sys/syscall.h>
1412
namespace LIBC_NAMESPACE {
@@ -35,5 +33,3 @@ ErrorOr<int> clock_gettime(clockid_t clockid, timespec *ts) {
3533

3634
} // namespace internal
3735
} // namespace LIBC_NAMESPACE
38-
39-
#endif // LLVM_LIBC_SRC___SUPPORT_TIME_LINUX_CLOCK_GETTIME_H
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
//===--- clock_gettime linux implementation ---------------------*- C++ -*-===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
#ifndef LLVM_LIBC_SRC___SUPPORT_TIME_LINUX_CLOCK_GETTIME_H
10+
#define LLVM_LIBC_SRC___SUPPORT_TIME_LINUX_CLOCK_GETTIME_H
11+
#include "hdr/types/clockid_t.h"
12+
#include "hdr/types/struct_timespec.h"
13+
#include "src/__support/common.h"
14+
15+
#include "src/__support/error_or.h"
16+
17+
namespace LIBC_NAMESPACE {
18+
namespace internal {
19+
ErrorOr<int> clock_gettime(clockid_t clockid, timespec *ts);
20+
}
21+
} // namespace LIBC_NAMESPACE
22+
23+
#endif // LLVM_LIBC_SRC___SUPPORT_TIME_LINUX_CLOCK_GETTIME_H

libc/src/time/gpu/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ add_object_library(
44
time_utils.cpp
55
HDRS
66
time_utils.h
7+
DEPENDS
8+
libc.hdr.types.clock_t
9+
libc.hdr.time_macros
710
)
811

912
add_entrypoint_object(

libc/src/time/gpu/clock.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,8 @@
66
//
77
//===----------------------------------------------------------------------===//
88

9-
#include "time_utils.h"
10-
119
#include "src/time/clock.h"
10+
#include "src/time/gpu/time_utils.h"
1211

1312
namespace LIBC_NAMESPACE {
1413

libc/src/time/gpu/time_utils.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@
99
#ifndef LLVM_LIBC_SRC_TIME_GPU_TIME_UTILS_H
1010
#define LLVM_LIBC_SRC_TIME_GPU_TIME_UTILS_H
1111

12+
#include "hdr/time_macros.h"
13+
#include "hdr/types/clock_t.h"
1214
#include "src/__support/GPU/utils.h"
13-
1415
namespace LIBC_NAMESPACE {
1516

1617
#if defined(LIBC_TARGET_ARCH_IS_AMDGPU)

0 commit comments

Comments
 (0)