From owner-svn-src-head@freebsd.org Thu Feb 6 16:37:05 2020 Return-Path: Delivered-To: svn-src-head@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 7100F22FE81; Thu, 6 Feb 2020 16:37:05 +0000 (UTC) (envelope-from cse.cem@gmail.com) Received: from mail-oi1-f170.google.com (mail-oi1-f170.google.com [209.85.167.170]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1O1" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 48D3xF2RJpz4Dhv; Thu, 6 Feb 2020 16:37:05 +0000 (UTC) (envelope-from cse.cem@gmail.com) Received: by mail-oi1-f170.google.com with SMTP id i1so5193843oie.8; Thu, 06 Feb 2020 08:37:05 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:reply-to :from:date:message-id:subject:to:cc; bh=p/B4m4ujEYtxzn2pFIzTHOi1n4Z89BZROEX4d3i6/YE=; b=PUuV4TEuL0jv1zBJsYKXTakAwIG2AHW8930n34KJmxIelOZt70vfME4M4qPBkfG1Gp MtXyQjDpYo8HINfA4KhpiJ6CT2tOBdrNZ5iTph7A5xST2tYhECBXny6tFGOXMnw36yvI 2gQggH2dG7dbkq5rcyKY38/wmaZvQZBBI4GNPdRnXDGDoJwyPFxWlSY2DYInSXjS8DhI IGn9bIr5oeVcR7cvf1EfA2FJQZDmx0+LulSZl28aN74c0NOvBT5yQt/xUr9hvBBYoGoh lDWkekMrGK1ox4iOdiHKDnEDT71Em+Zs4HoSGq0tx/jbBPC235dVo/Z3KaPnLAaZAxN4 8wKw== X-Gm-Message-State: APjAAAUV53c0Pogu4JW51lg5zyiL3GPCu1Rq3A0gxRRUuIemFQAb0g12 Bxh8PiX9yAdfLJl2Grxtk7B89crS X-Google-Smtp-Source: APXvYqzv51lGg2VE+uYnxzI0L+UqW6Xs7//1ST7QhM6PCGfN69UAhBBQ1W7QkRQniainlt+VReO0dA== X-Received: by 2002:a05:6808:8e1:: with SMTP id d1mr7499238oic.68.1581007024096; Thu, 06 Feb 2020 08:37:04 -0800 (PST) Received: from mail-ot1-f46.google.com (mail-ot1-f46.google.com. [209.85.210.46]) by smtp.gmail.com with ESMTPSA id x22sm23025otk.23.2020.02.06.08.37.03 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 06 Feb 2020 08:37:03 -0800 (PST) Received: by mail-ot1-f46.google.com with SMTP id b18so6095232otp.0; Thu, 06 Feb 2020 08:37:03 -0800 (PST) X-Received: by 2002:a05:6830:15d2:: with SMTP id j18mr178169otr.216.1581007023414; Thu, 06 Feb 2020 08:37:03 -0800 (PST) MIME-Version: 1.0 References: <202002061245.016CjwTi096374@repo.freebsd.org> In-Reply-To: <202002061245.016CjwTi096374@repo.freebsd.org> Reply-To: cem@freebsd.org From: Conrad Meyer Date: Thu, 6 Feb 2020 08:36:52 -0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: svn commit: r357614 - in head/sys: kern sys To: Pawel Biernacki Cc: src-committers , svn-src-all , svn-src-head Content-Type: text/plain; charset="UTF-8" X-Rspamd-Queue-Id: 48D3xF2RJpz4Dhv X-Spamd-Bar: ----- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-6.00 / 15.00]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; REPLY(-4.00)[]; TAGGED_FROM(0.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 06 Feb 2020 16:37:05 -0000 Hi Pawel, I don't think the (notyet) static assertion is quite right. On Thu, Feb 6, 2020 at 4:46 AM Pawel Biernacki wrote: > > Author: kaktus > Date: Thu Feb 6 12:45:58 2020 > New Revision: 357614 > URL: https://svnweb.freebsd.org/changeset/base/357614 > > Log: > sysctl(9): add CTLFLAG_NEEDGIANT flag > ... > Modified: head/sys/sys/sysctl.h > ============================================================================== > --- head/sys/sys/sysctl.h Thu Feb 6 10:11:41 2020 (r357613) > +++ head/sys/sys/sysctl.h Thu Feb 6 12:45:58 2020 (r357614) > @@ -105,6 +105,13 @@ struct ctlname { > ... > + * One, and only one of CTLFLAG_MPSAFE or CTLFLAG_NEEDGIANT is required > + * for SYSCTL_PROC and SYSCTL_NODE. > ... > @@ -263,6 +270,14 @@ TAILQ_HEAD(sysctl_ctx_list, sysctl_ctx_entry); > #define __DESCR(d) "" > #endif > > +#ifdef notyet > +#define SYSCTL_ENFORCE_FLAGS(x) \ > + _Static_assert(((CTLFLAG_MPSAFE ^ CTLFLAG_NEEDGIANT) & (x)), \ > + "Has to be either CTLFLAG_MPSAFE or CTLFLAG_NEEDGIANT") The current (notyet) assertion checks for one or both flags being set, but you want to disallow both being set. The XOR operator here is meaningless; it is the same as OR for different bit flags. That would be something like: #define _CTLFLAG_MUTUALLY_EXCLUSIVE (CTLFLAG_MPSAFE | CTLFLAG_NEEDGIANT); #define SYSCTL_ENFORCE_FLAGS(x) do { \ _Static_assert(((x) & _CTLFLAG_MUTUALLY_EXCLUSIVE) != 0 && \ ((x) & _CTLFLAG_MUTUALLY_EXCLUSIVE) != _CTLFLAG_MUTUALLY_EXCLUSIVE, \ "Must set exactly one of CTLFLAG_MPSAFE, CTLFLAG_NEEDGIANT"); \ } while (0) Best, Conrad