Skip to content

[libc] Enable 'mktime' for the GPU #133437

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 1 commit into from
Mar 28, 2025
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
8 changes: 6 additions & 2 deletions libc/cmake/modules/LLVMLibCTestRules.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -643,7 +643,7 @@ function(add_libc_hermetic test_name)
cmake_parse_arguments(
"HERMETIC_TEST"
"IS_GPU_BENCHMARK" # Optional arguments
"SUITE" # Single value arguments
"SUITE;CXX_STANDARD" # Single value arguments
"SRCS;HDRS;DEPENDS;ARGS;ENV;COMPILE_OPTIONS;LINK_LIBRARIES;LOADER_ARGS" # Multi-value arguments
${ARGN}
)
Expand Down Expand Up @@ -720,10 +720,14 @@ function(add_libc_hermetic test_name)
${HERMETIC_TEST_SRCS}
${HERMETIC_TEST_HDRS}
)

if(NOT HERMETIC_TEST_CXX_STANDARD)
set(HERMETIC_TEST_CXX_STANDARD ${CMAKE_CXX_STANDARD})
endif()
set_target_properties(${fq_build_target_name}
PROPERTIES
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
#OUTPUT_NAME ${fq_target_name}
CXX_STANDARD ${HERMETIC_TEST_CXX_STANDARD}
)

target_include_directories(${fq_build_target_name} SYSTEM PRIVATE ${LIBC_INCLUDE_DIR})
Expand Down
1 change: 1 addition & 0 deletions libc/config/gpu/amdgpu/entrypoints.txt
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,7 @@ set(TARGET_LIBC_ENTRYPOINTS
libc.src.time.nanosleep
libc.src.time.strftime
libc.src.time.strftime_l
libc.src.time.mktime

# wchar.h entrypoints
libc.src.wchar.wcslen
Expand Down
1 change: 1 addition & 0 deletions libc/config/gpu/nvptx/entrypoints.txt
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,7 @@ set(TARGET_LIBC_ENTRYPOINTS
libc.src.time.nanosleep
libc.src.time.strftime
libc.src.time.strftime_l
libc.src.time.mktime

# wchar.h entrypoints
libc.src.wchar.wcslen
Expand Down
2 changes: 1 addition & 1 deletion libc/test/src/time/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ add_libc_unittest(
libc.src.time.time_constants
)

add_libc_unittest(
add_libc_test(
mktime_test
SUITE
libc_time_unittests
Expand Down
4 changes: 4 additions & 0 deletions libc/test/src/time/mktime_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ using LIBC_NAMESPACE::testing::ErrnoSetterMatcher::Fails;
using LIBC_NAMESPACE::testing::ErrnoSetterMatcher::Succeeds;
using LIBC_NAMESPACE::time_constants::Month;

#ifndef EOVERFLOW
#define EOVERFLOW 0
#endif

static inline constexpr int tm_year(int year) {
return year - LIBC_NAMESPACE::time_constants::TIME_YEAR_BASE;
}
Expand Down
Loading