Skip to content

[libc] Allow time conversions to compile on bare metal #102014

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions libc/config/baremetal/arm/entrypoints.txt
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,12 @@ set(TARGET_LIBC_ENTRYPOINTS
libc.src.stdlib.strtoull

# time.h entrypoints
libc.src.time.asctime
libc.src.time.asctime_r
libc.src.time.difftime
libc.src.time.gmtime
libc.src.time.gmtime_r
libc.src.time.mktime

# internal entrypoints
libc.startup.baremetal.init
Expand Down
5 changes: 5 additions & 0 deletions libc/config/baremetal/riscv/entrypoints.txt
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,12 @@ set(TARGET_LIBC_ENTRYPOINTS
libc.src.stdlib.strtoull

# time.h entrypoints
libc.src.time.asctime
libc.src.time.asctime_r
libc.src.time.difftime
libc.src.time.gmtime
libc.src.time.gmtime_r
libc.src.time.mktime

# internal entrypoints
libc.startup.baremetal.init
Expand Down
5 changes: 5 additions & 0 deletions libc/src/time/time_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,12 @@ extern int64_t update_from_seconds(int64_t total_seconds, struct tm *tm);

// POSIX.1-2017 requires this.
LIBC_INLINE time_t out_of_range() {
#ifdef EOVERFLOW
// For non-POSIX uses of the standard C time functions, where EOVERFLOW is
// not defined, it's OK not to set errno at all. The plain C standard doesn't
// require it.
libc_errno = EOVERFLOW;
#endif
return TimeConstants::OUT_OF_RANGE_RETURN_VALUE;
}

Expand Down
Loading