Skip to content

Commit 8f878c5

Browse files
authored
[libc] Include time.h in baremetal targets (#85026)
These types and conversion functions are used in embedded development. Note that we cannot yet include other entrypoints such as asctime because `src/time/time_utils.h` unconditionally uses `EOVERFLOW`, which is only defined in POSIX and not in C standard. This issue is tracked by #85556.
1 parent d33d563 commit 8f878c5

File tree

5 files changed

+17
-0
lines changed

5 files changed

+17
-0
lines changed

libc/config/baremetal/api.td

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,15 @@ def StringAPI : PublicAPI<"string.h"> {
7676
let Types = ["size_t"];
7777
}
7878

79+
def TimeAPI : PublicAPI<"time.h"> {
80+
let Types = [
81+
"clock_t",
82+
"time_t",
83+
"struct tm",
84+
"struct timespec",
85+
];
86+
}
87+
7988
def UCharAPI : PublicAPI<"uchar.h"> {
8089
let Types = ["mbstate_t"];
8190
}

libc/config/baremetal/arm/entrypoints.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,9 @@ set(TARGET_LIBC_ENTRYPOINTS
180180
libc.src.stdlib.strtoll
181181
libc.src.stdlib.strtoul
182182
libc.src.stdlib.strtoull
183+
184+
# time.h entrypoints
185+
libc.src.time.difftime
183186
)
184187

185188
set(TARGET_LIBM_ENTRYPOINTS

libc/config/baremetal/arm/headers.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,6 @@ set(TARGET_PUBLIC_HEADERS
1313
libc.include.string
1414
libc.include.strings
1515
libc.include.sys_queue
16+
libc.include.time
1617
libc.include.uchar
1718
)

libc/config/baremetal/riscv/entrypoints.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,9 @@ set(TARGET_LIBC_ENTRYPOINTS
180180
libc.src.stdlib.strtoll
181181
libc.src.stdlib.strtoul
182182
libc.src.stdlib.strtoull
183+
184+
# time.h entrypoints
185+
libc.src.time.difftime
183186
)
184187

185188
set(TARGET_LIBM_ENTRYPOINTS

libc/config/baremetal/riscv/headers.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,6 @@ set(TARGET_PUBLIC_HEADERS
1313
libc.include.string
1414
libc.include.strings
1515
libc.include.sys_queue
16+
libc.include.time
1617
libc.include.uchar
1718
)

0 commit comments

Comments
 (0)