Skip to content

build: ensure time_t is consistent across all supported platforms #92274

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

Closed
Closed
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
2 changes: 2 additions & 0 deletions arch/posix/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ else() # Linux.x86_64
zephyr_compile_options(-m32)
zephyr_link_libraries(-m32)

zephyr_compile_options(-D__USE_TIME_BITS64=1)

target_link_options(native_simulator INTERFACE "-m32")
target_compile_options(native_simulator INTERFACE "-m32")

Expand Down
4 changes: 2 additions & 2 deletions cmake/modules/unittest.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ if(M64_MODE)
set (CMAKE_C_FLAGS "-m64")
set (CMAKE_CXX_FLAGS "-m64")
else()
set (CMAKE_C_FLAGS "-m32") #deprecated on macOS
set (CMAKE_CXX_FLAGS "-m32") #deprecated on macOS
set (CMAKE_C_FLAGS "-m32 -D__USE_TIME_BITS64=1") #deprecated on macOS
set (CMAKE_CXX_FLAGS "-m32 -D__USE_TIME_BITS64=1") #deprecated on macOS
endif(M64_MODE)

endif()
Expand Down
8 changes: 0 additions & 8 deletions tests/lib/timespec_util/CMakeLists.txt

This file was deleted.

1 change: 0 additions & 1 deletion tests/lib/timespec_util/prj.conf

This file was deleted.

36 changes: 0 additions & 36 deletions tests/lib/timespec_util/testcase.yaml

This file was deleted.

1 change: 1 addition & 0 deletions tests/unit/timeutil/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@ target_sources(testbinary
test_s32.c
test_s64.c
test_sync.c
timespec.c
)
4 changes: 3 additions & 1 deletion tests/unit/timeutil/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
#include "timeutil_test.h"
#include "../../../lib/utils/timeutil.c"

extern void *setup(void);

void timeutil_check(const struct timeutil_test_data *tp,
size_t count)
{
Expand Down Expand Up @@ -52,4 +54,4 @@ void timeutil_check(const struct timeutil_test_data *tp,
}
}

ZTEST_SUITE(timeutil_api, NULL, NULL, NULL, NULL, NULL);
ZTEST_SUITE(timeutil_api, NULL, setup, NULL, NULL, NULL);
8 changes: 8 additions & 0 deletions tests/unit/timeutil/testcase.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,11 @@ tests:

utilities.time.64bit:
extra_args: M64_MODE=1

utilities.time.timeout32:
extra_configs:
- CONFIG_TIMEOUT_64BIT=n

utilities.time.timeout64:
extra_configs:
- CONFIG_TIMEOUT_64BIT=y
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ ZTEST(timeutil_api, test_timespec_equal)
zexpect_false(timespec_equal(&a, &b));
}

#define K_TICK_MAX ((uint64_t)(CONFIG_TIMEOUT_64BIT ? (INT64_MAX) : (UINT32_MAX)))
#define K_TICK_MAX ((uint64_t)(IS_ENABLED(CONFIG_TIMEOUT_64BIT) ? (INT64_MAX) : (UINT32_MAX)))
#define NS_PER_TICK (NSEC_PER_SEC / CONFIG_SYS_CLOCK_TICKS_PER_SEC)

/* 0 := lower limit, 2 := upper limit */
Expand Down Expand Up @@ -365,9 +365,10 @@ ZTEST(timeutil_api, test_timespec_to_timeout)
}
}

static void *setup(void)
void *setup(void)
{
printk("CONFIG_TIMEOUT_64BIT=%c\n", CONFIG_TIMEOUT_64BIT ? 'y' : 'n');
printk("CONFIG_64BIT=%c\n", IS_ENABLED(CONFIG_64BIT) ? 'y' : 'n');
printk("CONFIG_TIMEOUT_64BIT=%c\n", IS_ENABLED(CONFIG_TIMEOUT_64BIT) ? 'y' : 'n');
printk("K_TICK_MAX: %lld\n", (long long)K_TICK_MAX);
printk("minimum timeout: {%lld, %lld}\n", (long long)k_timeout_limits[0].tv_sec,
(long long)k_timeout_limits[0].tv_nsec);
Expand All @@ -376,5 +377,3 @@ static void *setup(void)

return NULL;
}

ZTEST_SUITE(timeutil_api, NULL, setup, NULL, NULL, NULL);