From nobody Sat Nov 14 09:42:32 2026 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4jRTgX6gsLz70g8y for ; Sat, 14 Nov 2026 09:42:32 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 4jRTgX4yxQz4dgq for ; Sat, 14 Nov 2026 09:42:32 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1794649352; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=T9Lh+c7RIvLmzzdjTPzp4imWwmjJ16332tga5wuNHq0=; b=D5/ZkqLVcIxUh92EXG/rJgXxiUEdB4RG9BabDuqtZOnuP/VXB2ygf7H+q2mUDet0/IQFiQ 5g/+HSsI19KzHdYQA9arP0jk/kK/4x6BoQlAD7u4zfYTpQNhVOtxuzrlnHp4gtxcuDRKoj C5FK7kiGBTcnSZUFistDArA3JI8bG8T0biQg8hmrTm/WjCEdtentvwYIfxA+ICEItUfiIk pvTSDMv35yth7ijMKjNIK90nbd9HqB9HJQ2NVveSl4O2gOg4HvS31vuDdejQuPOOrmPWMI XezxkUPQvpK6ZKw64MseDeg9FJywDfjHs8tQDohvF3lhMLBZgHuq4sZeqkh04Q== ARC-Seal: i=1; a=rsa-sha256; d=freebsd.org; s=dkim; cv=none; t=1794649352; b=Kn14nrBmxvlJ8kziiYy9TdzIgJCMHXfMDf6GZsJDXnpSQ2Nsz3ehOhQ4UydyKxli8DXiFE WRraZC5LLvb2i+K6X4W/MUhZDZ0BL/DwyY+o0o8VQWJIbWZs6/9bfe369oWBG0vyQ8cgRM 5UmJN32Eb6cCRpfm0leuuIvSUTlR0OEytczlIrdUoOxZmJByB1zzfubuXf3d61EwIQEiKq wPMRjvQBlisWsWxIc0jS0UWXwH2a3Pt9TctVGjk6aOu9OcQguP8pdMcVuzSmxZH+jINszF nyqGEu0U9ZIoaY+9ZrGnEfrTo/L04h2wwszyGeYEvO8Yga/1Aj9Q8sdoNHIxFA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1794649352; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=T9Lh+c7RIvLmzzdjTPzp4imWwmjJ16332tga5wuNHq0=; b=FnNrurogiMsOUDivZw+lFcJ6lTHgLErz9V7VuJTpesp5N8rkFDYHXAb4iw3HIA+xcNHvRa oQR14tE1LOVOB8oWybOHj3x7viOoR2/S9nIT4V8xT0Uj2WIaPOfte0o++G5zwL8ECT8irm z/RfqYVq0oEz22PWnjfApQSoljeucViJFJZx2mhUGIQ1SoZyXnBQXCSty7HWIRBefnWc9g kJM7nzjfg/a/TToKWTffXvXWEKJATNxRIQzmJI1wfT4AyjpgoSQ9JdVDbr0kATFI/2tzMv tcOcqfl+tBXW2R++VM8vXAo7+c2rgppfbSNv9Wq7BesI1ejDXYflpI8t2LS6Nw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4jRTgX4Ky1zGgN for ; Sat, 14 Nov 2026 09:42:32 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 13f46 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Sat, 14 Nov 2026 09:42:32 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Faraz Vahedi Subject: git: 7940130c2e87 - stable/15 - libc: Export timespec_getres(3) and add tests List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all X-BeenThere: dev-commits-src-all@freebsd.org List-Id: Commit messages for all branches of the src repository List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kfv X-Git-Repository: src X-Git-Refname: refs/heads/stable/15 X-Git-Reftype: branch X-Git-Commit: 7940130c2e87f6ac26b594428150b6a53397c488 Auto-Submitted: auto-generated Date: Sat, 14 Nov 2026 09:42:32 +0000 Message-Id: <6af82d08.13f46.6ef31c9a@gitrepo.freebsd.org> The branch stable/15 has been updated by kfv: URL: https://cgit.FreeBSD.org/src/commit/?id=7940130c2e87f6ac26b594428150b6a53397c488 commit 7940130c2e87f6ac26b594428150b6a53397c488 Author: Faraz Vahedi AuthorDate: 2026-11-05 20:09:01 +0000 Commit: Faraz Vahedi CommitDate: 2026-11-14 09:40:38 +0000 libc: Export timespec_getres(3) and add tests timespec_getres() has been declared in and built into libc, but never listed in a symbol map. It is therefore local to libc.so, and dynamically linked callers fail to link. Reviewed by: ziaee, fuz, des Approved by: fuz (mentor) Fixes: 9b5d724cad10 ("libc: Add timespec_getres(3) as per C23.") MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D60799 (cherry picked from commit 3ac9299ee90cc7a6330c560d8c49d5151185f80e) --- lib/libc/gen/Symbol.map | 1 + lib/libc/gen/timespec_getres.3 | 8 +- lib/libc/tests/gen/Makefile | 1 + lib/libc/tests/gen/timespec_getres_test.c | 124 ++++++++++++++++++++++++++++++ 4 files changed, 132 insertions(+), 2 deletions(-) diff --git a/lib/libc/gen/Symbol.map b/lib/libc/gen/Symbol.map index 4d22251f7ec5..b57db0534eec 100644 --- a/lib/libc/gen/Symbol.map +++ b/lib/libc/gen/Symbol.map @@ -482,6 +482,7 @@ FBSD_1.9 { posix_spawnattr_getprocdescp_np; posix_spawnattr_setexecfd_np; posix_spawnattr_setprocdescp_np; + timespec_getres; }; FBSDprivate_1.0 { diff --git a/lib/libc/gen/timespec_getres.3 b/lib/libc/gen/timespec_getres.3 index 1b65cad4a056..7c89b77d5bb8 100644 --- a/lib/libc/gen/timespec_getres.3 +++ b/lib/libc/gen/timespec_getres.3 @@ -3,7 +3,7 @@ .\" .\" SPDX-License-Identifier: BSD-2-Clause .\" -.Dd May 14, 2026 +.Dd October 20, 2026 .Dt TIMESPEC_GETRES 3 .Os .Sh NAME @@ -43,7 +43,11 @@ function conforms to .St -isoC-2023 . .Sh HISTORY This interface first appeared in -.Fx 14 . +.Fx 14.0 , +but it was not exported from the shared C library until +.Fx 14.6 +and +.Fx 15.2 . .Sh AUTHORS The .Nm diff --git a/lib/libc/tests/gen/Makefile b/lib/libc/tests/gen/Makefile index 054b1b426b3d..5e3d0243508b 100644 --- a/lib/libc/tests/gen/Makefile +++ b/lib/libc/tests/gen/Makefile @@ -31,6 +31,7 @@ ATF_TESTS_C+= scandir_blocks_test .endif ATF_TESTS_C+= sig2str_test ATF_TESTS_C+= sigsetops_test +ATF_TESTS_C+= timespec_getres_test ATF_TESTS_C+= wordexp_test # TODO: t_closefrom, t_fmtcheck, t_randomid, diff --git a/lib/libc/tests/gen/timespec_getres_test.c b/lib/libc/tests/gen/timespec_getres_test.c new file mode 100644 index 000000000000..8c5bcf223b35 --- /dev/null +++ b/lib/libc/tests/gen/timespec_getres_test.c @@ -0,0 +1,124 @@ +/* + * Copyright (c) 2026 Faraz Vahedi + * + * SPDX-License-Identifier: BSD-2-Clause + */ + +/* + * Tests for timespec_getres() as per ISO/IEC 9899:2024 ยง7.29.2.7. + */ + +#include +#include +#include + +#include + +static const struct { + int base; + clockid_t clock; +} bases[] = { + { TIME_UTC, CLOCK_REALTIME }, + { TIME_MONOTONIC, CLOCK_MONOTONIC }, +}; + +static const int bad_bases[] = { + INT_MIN, -1, 0, INT_MAX, +}; + +static void +check_res(const struct timespec *ts) +{ + ATF_CHECK(ts->tv_sec >= 0); + ATF_CHECK(ts->tv_nsec >= 0 && ts->tv_nsec < 1000000000); + ATF_CHECK(ts->tv_sec != 0 || ts->tv_nsec != 0); +} + +ATF_TC_WITHOUT_HEAD(timespec_getres_supported); +ATF_TC_BODY(timespec_getres_supported, tc) +{ + struct timespec ts; + + for (size_t i = 0; i < nitems(bases); i++) { + ATF_CHECK_EQ(timespec_getres(&ts, bases[i].base), + bases[i].base); + check_res(&ts); + } +} + +ATF_TC_WITHOUT_HEAD(timespec_getres_clock); +ATF_TC_BODY(timespec_getres_clock, tc) +{ + struct timespec ts, cts; + + for (size_t i = 0; i < nitems(bases); i++) { + ATF_REQUIRE_EQ(timespec_getres(&ts, bases[i].base), + bases[i].base); + ATF_REQUIRE_EQ(clock_getres(bases[i].clock, &cts), 0); + ATF_CHECK_EQ(ts.tv_sec, cts.tv_sec); + ATF_CHECK_EQ(ts.tv_nsec, cts.tv_nsec); + } +} + +ATF_TC_WITHOUT_HEAD(timespec_getres_null); +ATF_TC_BODY(timespec_getres_null, tc) +{ + for (size_t i = 0; i < nitems(bases); i++) + ATF_CHECK_EQ(timespec_getres(NULL, bases[i].base), + bases[i].base); + for (size_t i = 0; i < nitems(bad_bases); i++) + ATF_CHECK_EQ(timespec_getres(NULL, bad_bases[i]), 0); +} + +ATF_TC_WITHOUT_HEAD(timespec_getres_unsupported); +ATF_TC_BODY(timespec_getres_unsupported, tc) +{ + struct timespec ts; + + for (size_t i = 0; i < nitems(bad_bases); i++) { + ts.tv_sec = -1; + ts.tv_nsec = -1; + ATF_CHECK_EQ(timespec_getres(&ts, bad_bases[i]), 0); + ATF_CHECK_EQ(ts.tv_sec, -1); + ATF_CHECK_EQ(ts.tv_nsec, -1); + } +} + +ATF_TC_WITHOUT_HEAD(timespec_getres_timespec_get); +ATF_TC_BODY(timespec_getres_timespec_get, tc) +{ + struct timespec ts; + + for (int base = -1; base <= TIME_MONOTONIC + 8; base++) + ATF_CHECK_EQ_MSG(timespec_getres(&ts, base) != 0, + timespec_get(&ts, base) != 0, "base %d", base); +} + +ATF_TC_WITHOUT_HEAD(timespec_getres_stable); +ATF_TC_BODY(timespec_getres_stable, tc) +{ + struct timespec first, ts; + + for (size_t i = 0; i < nitems(bases); i++) { + ATF_REQUIRE_EQ(timespec_getres(&first, bases[i].base), + bases[i].base); + for (int n = 0; n < 100; n++) { + ATF_REQUIRE_EQ(timespec_getres(&ts, bases[i].base), + bases[i].base); + ATF_CHECK_EQ(ts.tv_sec, first.tv_sec); + ATF_CHECK_EQ(ts.tv_nsec, first.tv_nsec); + } + } +} + +ATF_TP_ADD_TCS(tp) +{ + ATF_TP_ADD_TC(tp, timespec_getres_supported); + ATF_TP_ADD_TC(tp, timespec_getres_clock); + ATF_TP_ADD_TC(tp, timespec_getres_null); + ATF_TP_ADD_TC(tp, timespec_getres_unsupported); + ATF_TP_ADD_TC(tp, timespec_getres_timespec_get); + ATF_TP_ADD_TC(tp, timespec_getres_stable); + + return (atf_no_error()); +}