From nobody Sat Nov 14 17:26:25 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 4jRgyp1F1zz6y17R for ; Sat, 14 Nov 2026 17:26:26 +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 4jRgyn6QRbz4nk9 for ; Sat, 14 Nov 2026 17:26:25 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1794677185; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=gslqDg+bRNvcjDZ9QNt22jaJDCjQUYVtdAzhlw3DyTs=; b=Q9AzuQbbZ/Bkgx40yKsJ/XKkzOmgdsWL/vLx+BCG5rH6dqXFd3HKkw+A5gWBEJA/6NSxh1 IPLkajn0Ah3TgtrNnS0gFE7HqRLLbthHfB7q9TloajW4wx4RMw2Cps50mRYfIOoXnnvReV /PwzTIG4WgzpYyYWAlfSmG+Fg3IoY9Zc90tITaYmoS9TW1Yy/KnR2AdfW8v55FxcBNZ+IK roVVuahdPZueSgr57yiaQp9Ch056zIRlYm0BYeZ/72fEZFYTans1Y62VT3liYqN83S2WGx DCNlhK9XWD81sb0raDm7Y28vuqkSWnwneblt745zZWufQhZCVYAGnLk4GwfJ3A== ARC-Seal: i=1; a=rsa-sha256; d=freebsd.org; s=dkim; cv=none; t=1794677185; b=dLVlA2aEREV773aoN8dIO2qnR50rBtmdDYABNX1wZzBwU/ZFxsWAwkfR+jB+DguiWqFnnu XWGxzJY2tEGgmxqKOmHYLoY+zihaqDt5d7CNTAvtibfYy1cM/dtdVhKtoBqgWMAFZnerP6 OfM3r5hI3oTsRNxCn/VCeStqujdCybPiLS1qujeqBORaC4lWRatKnpL0/PTZTros7uydNx IZHrL40CChG1sgqy5zFs7FF6TqaP7IugqnO4+ZoRtEBzR0bH4K6QN+NbahjGR+cu8K4TEd +Ut40vVD43ifokdUWSjD/rFqFEujv71wrGBcBCVYfa3t8gmIFZWZmWWiMSseiQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1794677185; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=gslqDg+bRNvcjDZ9QNt22jaJDCjQUYVtdAzhlw3DyTs=; b=FHMRK2IZF9nzLue4XMcATwHOCT2X0HCuCV8ZIPm74q+P06OCPSDobQy8ijzGftaTpkQRVb ouHNrxEH9Q6C4gH01AvR4k9c1Y+CDzog9IJnqKRzudssbN743uAv+hb16wLP5FQyvng3Yr LSjO+JrYcZDj14aI7YltOLq33udcox0QtN3ClQyeP544NO8TcjCV8En8rcbHSiV9p/7905 b6EcSaJg3rz5BhZP3lWIONa/keIJVn29hhuldEzJ0NgGhY1FvlPuXjCewKN+XJZujhUtOv XqEfCD/l8fYIjF3lCzCwmIoWOB3s3lxpNAYZtczesjnKEytVFk9WYiImXK9n7A== 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 4jRgyn5gXJzTCM for ; Sat, 14 Nov 2026 17:26:25 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 1c4ae by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Sat, 14 Nov 2026 17:26:25 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org Cc: Faraz Vahedi From: Colin Percival Subject: git: dc87da505a08 - releng/15.2 - 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: cperciva X-Git-Repository: src X-Git-Refname: refs/heads/releng/15.2 X-Git-Reftype: branch X-Git-Commit: dc87da505a0875671e75b4f55f78e20eecdf73dd Auto-Submitted: auto-generated Date: Sat, 14 Nov 2026 17:26:25 +0000 Message-Id: <6af899c1.1c4ae.7eb3f36d@gitrepo.freebsd.org> The branch releng/15.2 has been updated by cperciva: URL: https://cgit.FreeBSD.org/src/commit/?id=dc87da505a0875671e75b4f55f78e20eecdf73dd commit dc87da505a0875671e75b4f55f78e20eecdf73dd Author: Faraz Vahedi AuthorDate: 2026-11-05 20:09:01 +0000 Commit: Colin Percival CommitDate: 2026-11-14 17:25:52 +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. Approved by: re (cperciva) 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) (cherry picked from commit 7940130c2e87f6ac26b594428150b6a53397c488) --- 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()); +}