From nobody Thu Sep 15 16:59:21 2022 X-Original-To: dev-commits-src-branches@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 4MT3MZ1RF0z4cpCG; Thu, 15 Sep 2022 16:59:22 +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 "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4MT3MZ0rsfz3TTb; Thu, 15 Sep 2022 16:59:22 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1663261162; 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=0dBTjNtlQUlGxGpl0AmVCCJwqMI2hlAk4pELUPsKByw=; b=r7YM17EP3ZvrFOf1Tg6LgzNQoFqZHy3KRoyePIqUZhYbwfka6zZNvebmcmYL42WqLWD2dA o6Ohksu8Re4VsbNvLgdV0/vvyphP7+/C8AyZLKDs8rrX8ObhCg/3iCme/WRPueTDsX0QEM 4b0i4Qsxu+sficRvQK+zrR0dMPjVmAG4TcRGrLJ38FngmfTSwJBn0kR55h6Jck/GCUtZ5Z HzJFsq6U5TmkDU0Ipz4KEw7F90bFylwmpB/P7HUx1qI4NrfsCNOyjkw+fayj0cR+sGfAas VR9yxpDKZhYnuXL/g3Yk413ifdN4rGYHRfEQPEcugXsmisfxUqNx0AF9vA4KJg== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (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 did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4MT3MY71kxz14b2; Thu, 15 Sep 2022 16:59:21 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 28FGxLIZ073279; Thu, 15 Sep 2022 16:59:21 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 28FGxLvx073278; Thu, 15 Sep 2022 16:59:21 GMT (envelope-from git) Date: Thu, 15 Sep 2022 16:59:21 GMT Message-Id: <202209151659.28FGxLvx073278@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Doug Moore Subject: git: 68ec84dc1bb6 - stable/13 - tree(3): allow the compare function to return any signed type List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: dougm X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 68ec84dc1bb6a7a26120d44c07825f4e8341e9b9 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1663261162; 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=0dBTjNtlQUlGxGpl0AmVCCJwqMI2hlAk4pELUPsKByw=; b=R1M/i4Dzt73WNw6F76wiaJtMpA66GNV3vvDbffcn+R6l7iCK++09X8d66bKtKjMj0PtZRG hgueQfBgkwhRil4blcLp2g5rOM6TBbjOFlb4vg2y/pcBpC9K8yyUNjS7caILh7RE3JMi0t GrgaZ+MBHFrKAdVKBEMCnA1VZTWwwxElVccu5MQdy4Uh/d6cXiyywsPj6KZJKDKn+33YiO 9yXRtTKYPG82uvZKQKDvejDThLEx8ECDPgN4VViOVXYowVXskeFAX1OOLW6CIHjpLnc2Bl +7Gu/6L0d++BqehUn9To0QArc1ssm2kGkWElxjc5yKJTjWBmEfCzawAWqLjMpQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1663261162; a=rsa-sha256; cv=none; b=x1OlWZHY2IL9qASy9qBujJgijEqwr7ZNA/Q0o+GPj3quSgTsK7zzhN9tQMn/f0KY59kBUl IedbH+6eHhtwVp07OhBCC4bq1/ZA8qu1YY20OVpCScLI+iPokZUalqGTNhRbkv5g8OeCA6 Uo6MN74amfiMqm+NkgacVzGzheA36tY0D1dWXNx1cLGuxakkpRflv7R0E7lEWhdlKuYO+t GteNBc2RwqCBac4b0knBKuJt2YA7jJjjH30pm9qXf4BMMd884OMDRGH/8bcYWCqSeZ2cnY XygRM8KUOlTsGW8b/untZ9RsjgXhv8JK9ZapwBO5dVKDs0ntwOOfxm/O12LOWw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by dougm: URL: https://cgit.FreeBSD.org/src/commit/?id=68ec84dc1bb6a7a26120d44c07825f4e8341e9b9 commit 68ec84dc1bb6a7a26120d44c07825f4e8341e9b9 Author: Gleb Smirnoff AuthorDate: 2022-07-07 05:19:08 +0000 Commit: Doug Moore CommitDate: 2022-09-15 16:58:06 +0000 tree(3): allow the compare function to return any signed type This allows to write very short comparison function when we are comparing just pointer values: return ((intptr_t)((uintptr_t)a->ptr/2 - (uintptr_t)b->ptr/2)); Reviewed by: dougm, alc Differential revision: https://reviews.freebsd.org/D35722 (cherry picked from commit 86cdadbed44ecd36469dfbc4f1e492dfe51fcd4e) --- sys/sys/tree.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/sys/sys/tree.h b/sys/sys/tree.h index db5de3b8ec87..1f0a260e25a7 100644 --- a/sys/sys/tree.h +++ b/sys/sys/tree.h @@ -176,7 +176,7 @@ name##_SPLAY_INSERT(struct name *head, struct type *elm) \ if (SPLAY_EMPTY(head)) { \ SPLAY_LEFT(elm, field) = SPLAY_RIGHT(elm, field) = NULL; \ } else { \ - int __comp; \ + __typeof(cmp(NULL, NULL)) __comp; \ name##_SPLAY(head, elm); \ __comp = (cmp)(elm, (head)->sph_root); \ if(__comp < 0) { \ @@ -219,7 +219,7 @@ void \ name##_SPLAY(struct name *head, struct type *elm) \ { \ struct type __node, *__left, *__right, *__tmp; \ - int __comp; \ + __typeof(cmp(NULL, NULL)) __comp; \ \ SPLAY_LEFT(&__node, field) = SPLAY_RIGHT(&__node, field) = NULL;\ __left = __right = &__node; \ @@ -729,7 +729,7 @@ name##_RB_INSERT(struct name *head, struct type *elm) \ { \ struct type *tmp; \ struct type *parent = NULL; \ - int comp = 0; \ + __typeof(cmp(NULL, NULL)) comp = 0; \ tmp = RB_ROOT(head); \ while (tmp) { \ parent = tmp; \ @@ -759,7 +759,7 @@ attr struct type * \ name##_RB_FIND(struct name *head, struct type *elm) \ { \ struct type *tmp = RB_ROOT(head); \ - int comp; \ + __typeof(cmp(NULL, NULL)) comp; \ while (tmp) { \ comp = cmp(elm, tmp); \ if (comp < 0) \ @@ -779,7 +779,7 @@ name##_RB_NFIND(struct name *head, struct type *elm) \ { \ struct type *tmp = RB_ROOT(head); \ struct type *res = NULL; \ - int comp; \ + __typeof(cmp(NULL, NULL)) comp; \ while (tmp) { \ comp = cmp(elm, tmp); \ if (comp < 0) { \