svn commit: r280636 - head/include
Pedro Giffuni
pfg at FreeBSD.org
Fri Mar 27 14:31:03 UTC 2015
On 03/27/15 06:01, Bruce Evans wrote:
> On Thu, 26 Mar 2015, Tijl Coosemans wrote:
>
>> On Thu, 26 Mar 2015 17:37:53 +1100 (EST) Bruce Evans
>> <brde at optusnet.com.au> wrote:
>>> On Wed, 25 Mar 2015, Pedro Giffuni wrote:
>>>> On 03/25/15 21:14, Bruce Evans wrote:
>>>>> On Wed, 25 Mar 2015, Pedro F. Giffuni wrote:
>>>>>> Log:
>>>>>> Temporarily revert 280458.
>>>>>>
>>>>>> GCC is still carries an old version of cdefs.h which doesn't
>>>>>> accept multiple parameters for the nonnull attribute.
>>>>>> Since this issue probably affects many ports in the tree
>>>>>> we will revert it for now until gcc gets fixed.
>>>>>
>>>>> Note that sys/cdefs.h is supposed to work with any version of
>>>>> gcc back to gcc-1, and does mostly work back to at least gcc-2.95.
>>>>> The whole point of sys/cdefs.h is to provide compatibity macros
>>>>> for old and other non-default compilers. Standard compilers don't
>>>>> even have __attribute__(()). So no changes in future versions
>>>>> of gcc will fix the previous commit.
>>>>
>>>> cdefs.h still works for all versions of gcc back to gcc-1 AFAICT.
>>>
>>> I now remember other bugs in it. I think you put the varargs stuff
>>> in the non-gcc version. That won't work compilers that don't support
>>> varargs for macros. Neither will not changing the non-gcc version.
>
> I confirmed the complete brokenness of the varargs stuff for the
> non-C99 case.
>
Hmm ... disabling existing compiler features to get a -Wall error
doesn't qualify as complete brokenness. since gcc 2.95 C99 supports
vararg macros we are basically talking about support for gcc 2.8 here.
>>> glibc (2.6 at least) avoids using varargs in its __nonnull() macro
>>> by using the same portable method that is used in many optional
>>> debugging statements including FreeBSD's KASSERT(). ...
>>
>> Maybe introduce a __nonnull_all macro and leave __nonnull varargs-free:
>>
>> #define __nonnull(x) __attribute__((__nonnull__(x)))
>> #define __nonnull_all __attribute__((__nonnull__))
>>
>> Then in the rare cases where multiple arguments must be nonnull but
>> __nonnull_all doesn't apply you can use multiple __nonnull:
>>
>> int f(void *, void *, void *) __nonnull(1) __nonnull(2);
>
> Good idea. There aren't many functions that accept null for some
> pointer args but not others.
>
> The multiple __nonnull() method is already used a lot. E.g., in
> sys/systm.h it is used 11 times. systm.h also gives many examples
> where __nonnull_all cannot be used. It cannot be used for the
> strto* family because endptr can be null, or for the copyinstr()
> family for similar reasons (a value may be returned indirectly
> but the pointer for this is null if this value is not needed).
>
This would become very long for some of the functions in pthread.h.
I can accept reverting the variadic macro merge in 10-stable but I
really think FreeBSD 11 has to move on.
Pedro.
More information about the svn-src-all
mailing list