Skip to content

Commit d8e7375

Browse files
Reland "[libc][NFC] adjust time related implementations"" (llvm#91687)
Reverts llvm#91657 and Relands llvm#91485
1 parent 7237bef commit d8e7375

27 files changed

+331
-75
lines changed

libc/hdr/CMakeLists.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,4 +68,13 @@ add_proxy_header_library(
6868
libc.include.llvm-libc-macros.sys_epoll_macros
6969
)
7070

71+
add_proxy_header_library(
72+
time_macros
73+
HDRS
74+
time_macros.h
75+
FULL_BUILD_DEPENDS
76+
libc.include.time
77+
libc.include.llvm-libc-macros.time_macros
78+
)
79+
7180
add_subdirectory(types)

libc/hdr/time_macros.h

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
//===-- Definition of macros from time.h ----------------------------------===//
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_HDR_TIME_MACROS_H
10+
#define LLVM_LIBC_HDR_TIME_MACROS_H
11+
12+
#ifdef LIBC_FULL_BUILD
13+
14+
#include "include/llvm-libc-macros/time-macros.h"
15+
16+
#else // Overlay mode
17+
18+
#include <time.h>
19+
20+
#endif // LLVM_LIBC_FULL_BUILD
21+
22+
#endif // LLVM_LIBC_HDR_TIME_MACROS_H

libc/hdr/types/CMakeLists.txt

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,3 +63,48 @@ add_proxy_header_library(
6363
libc.include.llvm-libc-types.fexcept_t
6464
libc.include.fenv
6565
)
66+
67+
add_proxy_header_library(
68+
time_t
69+
HDRS
70+
time_t.h
71+
FULL_BUILD_DEPENDS
72+
libc.include.llvm-libc-types.time_t
73+
libc.include.time
74+
)
75+
76+
add_proxy_header_library(
77+
clockid_t
78+
HDRS
79+
clockid_t.h
80+
FULL_BUILD_DEPENDS
81+
libc.include.llvm-libc-types.clockid_t
82+
libc.include.sys_types
83+
)
84+
85+
add_proxy_header_library(
86+
clock_t
87+
HDRS
88+
clock_t.h
89+
FULL_BUILD_DEPENDS
90+
libc.include.llvm-libc-types.clock_t
91+
libc.include.time
92+
)
93+
94+
add_proxy_header_library(
95+
suseconds_t
96+
HDRS
97+
suseconds_t.h
98+
FULL_BUILD_DEPENDS
99+
libc.include.llvm-libc-types.suseconds_t
100+
libc.include.sys_time
101+
)
102+
103+
add_proxy_header_library(
104+
struct_timeval
105+
HDRS
106+
struct_timeval.h
107+
FULL_BUILD_DEPENDS
108+
libc.include.llvm-libc-types.struct_timeval
109+
libc.include.sys_time
110+
)

libc/hdr/types/clock_t.h

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
//===-- Proxy for clock_t -------------------------------------------------===//
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_HDR_TYPES_CLOCK_T_H
10+
#define LLVM_LIBC_HDR_TYPES_CLOCK_T_H
11+
12+
#ifdef LIBC_FULL_BUILD
13+
14+
#include "include/llvm-libc-types/clock_t.h"
15+
16+
#else // Overlay mode
17+
18+
#include <sys/types.h>
19+
20+
#endif // LLVM_LIBC_FULL_BUILD
21+
22+
#endif // LLVM_LIBC_HDR_TYPES_CLOCK_T_H

libc/hdr/types/clockid_t.h

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
//===-- Proxy for clockid_t -----------------------------------------------===//
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_HDR_TYPES_CLOCKID_T_H
10+
#define LLVM_LIBC_HDR_TYPES_CLOCKID_T_H
11+
12+
#ifdef LIBC_FULL_BUILD
13+
14+
#include "include/llvm-libc-types/clockid_t.h"
15+
16+
#else // Overlay mode
17+
18+
#include <sys/types.h>
19+
20+
#endif // LLVM_LIBC_FULL_BUILD
21+
22+
#endif // LLVM_LIBC_HDR_TYPES_CLOCKID_T_H

libc/hdr/types/struct_timeval.h

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
//===-- Proxy for struct timeval ----------------------------------------===//
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+
#ifndef LLVM_LIBC_HDR_TYPES_STRUCT_TIMEVAL_H
9+
#define LLVM_LIBC_HDR_TYPES_STRUCT_TIMEVAL_H
10+
11+
#ifdef LIBC_FULL_BUILD
12+
13+
#include "include/llvm-libc-types/struct_timeval.h"
14+
15+
#else
16+
17+
#include <sys/time.h>
18+
19+
#endif // LIBC_FULL_BUILD
20+
21+
#endif // LLVM_LIBC_HDR_TYPES_STRUCT_TIMEVAL_H

libc/hdr/types/suseconds_t.h

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
//===-- Proxy for suseconds_t ---------------------------------------------===//
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_HDR_TIMES_SUSECONDS_T_H
10+
#define LLVM_LIBC_HDR_TIMES_SUSECONDS_T_H
11+
12+
#ifdef LIBC_FULL_BUILD
13+
14+
#include "include/llvm-libc-types/suseconds_t.h"
15+
16+
#else // Overlay mode
17+
18+
#include <sys/types.h>
19+
20+
#endif // LLVM_LIBC_FULL_BUILD
21+
22+
#endif // #ifndef LLVM_LIBC_HDR_TIMES_SUSECONDS_T_H

libc/hdr/types/time_t.h

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
//===-- Proxy for time_t --------------------------------------------------===//
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_HDR_TYPES_TIME_T_H
10+
#define LLVM_LIBC_HDR_TYPES_TIME_T_H
11+
12+
#ifdef LIBC_FULL_BUILD
13+
14+
#include "include/llvm-libc-types/time_t.h"
15+
16+
#else // Overlay mode
17+
18+
#include <time.h>
19+
20+
#endif // LLVM_LIBC_FULL_BUILD
21+
22+
#endif // LLVM_LIBC_HDR_TYPES_TIME_T_H

libc/src/__support/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,3 +281,5 @@ add_subdirectory(File)
281281
add_subdirectory(HashTable)
282282

283283
add_subdirectory(fixed_point)
284+
285+
add_subdirectory(time)
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${LIBC_TARGET_OS})
2+
add_subdirectory(${LIBC_TARGET_OS})
3+
endif()
4+
5+
add_header_library(
6+
units
7+
HDRS
8+
units.h
9+
DEPENDS
10+
libc.src.__support.common
11+
libc.hdr.types.time_t
12+
)

0 commit comments

Comments
 (0)