From nobody Thu Feb 26 07:41:52 2026 X-Original-To: dev-commits-src-main@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 4fM3Lm5xRhz6SwF6 for ; Thu, 26 Feb 2026 07:41:52 +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 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R12" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4fM3Lm5M88z3l8k for ; Thu, 26 Feb 2026 07:41:52 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1772091712; 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=wxAXAv/8VCCTYZvVAx0AfwA4gzW/aCQLMc/yFdbPBcM=; b=i6d+rDRbJRySqaPzFA/23HtTeS3fDQZ/WzdbjygrykbcJhEiriHojq2dn/+5oHfNjov8G4 COa9A3wHEga3HqoLLxsJO6CgjnjdCvZio2GxNxk1Nuv8LpgKGJIwcBjF4kkQVP7nXPmx8+ 7LLnU7cj3sxEnZrRtU/67n7pLlB+QmfLxJ1x1CyomT7YRLGygfPKfrZp9aAzwjVCw6i+pV KXC0YWCBnUCoOhqVdWrLYHsQxnPXOQHnWWD4fEAR2ts1FIBr5sIjv3LtXZgMxjts/2QaLM dNJ2CaXS4Qn1DFXPeiQe2GeCKAUu1BoQCE/dYuV7w06Z0B5/fqxeOqdrYIzjpg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1772091712; a=rsa-sha256; cv=none; b=uAIYFo5KKrkIpZpk9JS6988NOQFJq27SDZq9uIvyic13Nledf4mLE+DKTTHhskE705Zd3W BZ67+7S/3sSAgaCwxyoobpGuYonaWCoaXNEGRLCHUiih3wZ6e/ewWD0Z4Zafn+KYWnCwMM iF9LsY5IL+TvmGbLDvByU5elDzeAOIPWe1yoDXrWhsqgRjxFiH+eeychi1JOVB1ulhDTNO 7I+kxv7+8KQbGmTl6OdEBdAu0Yw3nPnEqV+e/Ws97WlJ8xweVsMh+AEJRGklvdCtzjby4H 9x/NVrQQKz73qYr2KzxgZheYRQIJqj9HTDWSvOZPlJEICq7DO3kJw0QW0Csvkg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1772091712; 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=wxAXAv/8VCCTYZvVAx0AfwA4gzW/aCQLMc/yFdbPBcM=; b=X/71gHcWKKoWkF7ZEqMsdZ974EKmjTCh8I1jYMvpmzUfEQbA7BlXFmeFw+Q+UHoMlDxE2g F53wlReB2wOqOVJV+x1uGu1Rn0T+fW9KTT/PlLwwVxzP98HtdT8vmsQtkpD3UO+rOIdeL2 oKWxiKsVLjy3Ba9G6JndE/oJiXGz6KAUlMXgQkDQ7a14CHVOiFEzsmoQZH8O4D+BQg7tde +anMr8GFqpW/yGUK3QiuT9vunlSJ2RvCYdo8r1bVpujiNGEpp7MGZRpWG+pKve1NuS/h2c RL2J73tZRpa6868HLEHzsJ3NOYnMCta0nGwsJ/GL+vYd+EQcI7Y6G5sWXmiuOg== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4fM3Lm4gn6z74G for ; Thu, 26 Feb 2026 07:41:52 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 19c99 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Thu, 26 Feb 2026 07:41:52 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Enji Cooper Subject: git: db5344a7445f - main - lib/libnetbsd: bring in `__type_m{ax,in}*` macro family List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: ngie X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: db5344a7445f1a796bc3cacd32a46e88e3e589a7 Auto-Submitted: auto-generated Date: Thu, 26 Feb 2026 07:41:52 +0000 Message-Id: <699ff940.19c99.1af2c339@gitrepo.freebsd.org> The branch main has been updated by ngie: URL: https://cgit.FreeBSD.org/src/commit/?id=db5344a7445f1a796bc3cacd32a46e88e3e589a7 commit db5344a7445f1a796bc3cacd32a46e88e3e589a7 Author: Enji Cooper AuthorDate: 2026-02-26 02:29:49 +0000 Commit: Enji Cooper CommitDate: 2026-02-26 07:41:08 +0000 lib/libnetbsd: bring in `__type_m{ax,in}*` macro family These macros are used by some of the NetBSD tests which calculate the size of types, e.g., `__type_max(time_t)`. This wraps up the set of macros needed in order to update to the a netbsd-tests snapshot from this past month. Obtained from: https://github.com/netbsd/src (55b4b44) MFC after: 1 week --- lib/libnetbsd/sys/cdefs.h | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/lib/libnetbsd/sys/cdefs.h b/lib/libnetbsd/sys/cdefs.h index 78c80735ad01..e4ff4a516519 100644 --- a/lib/libnetbsd/sys/cdefs.h +++ b/lib/libnetbsd/sys/cdefs.h @@ -110,4 +110,34 @@ */ #define __nothing (/*LINTED*/(void)0) +#define __negative_p(x) (!((x) > 0) && ((x) != 0)) + +#define __type_min_s(t) ((t)((1ULL << (sizeof(t) * __CHAR_BIT__ - 1)))) +#define __type_max_s(t) ((t)~((1ULL << (sizeof(t) * __CHAR_BIT__ - 1)))) +#define __type_min_u(t) ((t)0ULL) +#define __type_max_u(t) ((t)~0ULL) +#define __type_is_signed(t) (/*LINTED*/__type_min_s(t) + (t)1 < (t)1) +#define __type_min(t) (__type_is_signed(t) ? __type_min_s(t) : __type_min_u(t)) +#define __type_max(t) (__type_is_signed(t) ? __type_max_s(t) : __type_max_u(t)) + + +#define __type_fit_u(t, a) \ + (/*LINTED*/!__negative_p(a) && \ + ((__UINTMAX_TYPE__)((a) + __zeroull()) <= \ + (__UINTMAX_TYPE__)__type_max_u(t))) + +#define __type_fit_s(t, a) \ + (/*LINTED*/__negative_p(a) \ + ? ((__INTMAX_TYPE__)((a) + __zeroll()) >= \ + (__INTMAX_TYPE__)__type_min_s(t)) \ + : ((__INTMAX_TYPE__)((a) + __zeroll()) >= (__INTMAX_TYPE__)0 && \ + ((__INTMAX_TYPE__)((a) + __zeroll()) <= \ + (__INTMAX_TYPE__)__type_max_s(t)))) + +/* + * return true if value 'a' fits in type 't' + */ +#define __type_fit(t, a) (__type_is_signed(t) ? \ + __type_fit_s(t, a) : __type_fit_u(t, a)) + #endif /* _LIBNETBSD_SYS_CDEFS_H_ */