Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 21 Apr 2016 13:25:55 -0500
From:      Pedro Giffuni <pfg@FreeBSD.org>
To:        Hans Petter Selasky <hps@selasky.org>, Juli Mallett <juli@clockworksquid.com>
Cc:        Ngie Cooper <yaneurabeya@gmail.com>, "src-committers@freebsd.org" <src-committers@freebsd.org>, "svn-src-all@freebsd.org" <svn-src-all@freebsd.org>, "svn-src-head@freebsd.org" <svn-src-head@freebsd.org>
Subject:   Re: svn commit: r298412 - head/sys/ofed/drivers/infiniband/core
Message-ID:  <57191B33.7070406@FreeBSD.org>
In-Reply-To: <5719180F.90509@selasky.org>
References:  <201604211604.u3LG4wmT035874@repo.freebsd.org> <CAGHfRMC3UW6dAy6cW%2B8EJ1f=RxQy%2BTJV1dvHozGhaSmUWqAdNA@mail.gmail.com> <57190C47.8070106@selasky.org> <CACVs6=-iKVChHOiJjbn%2BOft-uUE603rwnfnk=fhZFtRVW0mfHg@mail.gmail.com> <5719150F.7030200@FreeBSD.org> <5719180F.90509@selasky.org>

next in thread | previous in thread | raw e-mail | index | archive | help


On 21/04/2016 13:12, Hans Petter Selasky wrote:
> On 04/21/16 19:59, Pedro Giffuni wrote:
>>
>>
>> On 21/04/2016 12:52, Juli Mallett wrote:
>>> On Thu, Apr 21, 2016 at 10:22 AM, Hans Petter Selasky
>>> <hps@selasky.org> wrote:
>>>> On 04/21/16 19:12, Ngie Cooper wrote:
>
> Hi,
>
>>> Then there should be an assertion or something else of that sort (I
>>> forget if we have a __builtin_unreachable()-alike macro in the kernel;
>>> the lint(1)y NOTREACHED isn't as nice as actual code) so that it is
>>> apparent to a human that this case cannot be reached.  The presence of
>>> a do-nothing default case is not typically indicative of unreachable
>>> code.
>>
>> We do have __unreachable() in cdefs.h
>>
>> It should work with both GCC and clang.
>>
>> Pedro.
>>
>
> I don't see anyone using __unreachable() yet in the kernel. Do you 
> recommend it over a KASSERT() ?
>

It's a rather recent addition (I added it after checking NetBSD's cdefs).

It is meant mostly for the compiler/static analyzers.

 From the clang documentation:
"The __builtin_unreachable() builtin has completely undefined behavior. 
Since it has undefined behavior, it is a statement that it is never 
reached and the optimizer can take advantage of this to produce better 
code. This builtin takes no arguments and produces a void result."

There was some discussion before it was introduced about turning
it into an assertion, but I recall it was not possible.

hth,

Pedro.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?57191B33.7070406>