Re: svn commit: r287206 - head/sys/sys

2015-08-27 Thread Pedro Giffuni



On 08/27/15 16:15, Pedro Giffuni wrote:

...



...


The original change to cdefs.h appears to be plain wrong.



Not really, it may appear some day.




I take that back, there is something wrong:

#ifndef __has_feature
#define __has_feature(x) (0)
#endif

#if __has_attribute(alloc_size)
#error Has attribute
#endif

$ cc -E attr-text.c
# 1 "attr-text.c"
# 1 ""
# 1 ""
# 1 "attr-text.c"
attr-text.c:5:20: error: missing binary operator before token "("

$ cc --version
cc (GCC) 4.2.1 20070831 patched [FreeBSD]
Copyright (C) 2007 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Pedro.
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r287206 - head/sys/sys

2015-08-27 Thread Pedro Giffuni



On 08/27/15 12:41, Alexander Kabaev wrote:
...


The existing conditional is not working for lint and I had to shuffle it
under bigger
'#ifdef lint' protection.


And other BSDs are just getting rid of lint. I have no opinion on that
though.


 ... Nor is the condition even well formed enough
to work with any
recent GCC and using __has_attribute in naked form is a mistake:

% cat t.c
#if __has_attribute(alloc_size)
# error Has attribute
#endif



We are not really using __has_attribute() in it's naked form: we are
following the official clang procedure:

http://clang.llvm.org/docs/LanguageExtensions.html#feature-checking-macros

In cdefs.h that corresponds to lines 42-44.

...


% mips-portbld-freebsd11.0-gcc --version
mips-portbld-freebsd11.0-gcc (FreeBSD Ports Collection for mips) 5.2.0
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

% mips-portbld-freebsd11.0-gcc -E t.c
# 1 "t.c"
# 1 ""
# 1 ""
# 1 "t.c"
t.c:2:3: error: #error Has attribute
  # error Has attribute
^

% gcc48 --version
gcc48 (FreeBSD Ports Collection) 4.8.5
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

% gcc48 -E t.c
# 1 "t.c"
# 1 ""
# 1 ""
# 1 "t.c"
t.c:1:20: error: missing binary operator before token "("
  #if __has_attribute(alloc_size)

Modified:
head/sys/sys/cdefs.h

..


   #if !__GNUC_PREREQ__(2, 95)
@@ -371,24 +382,12 @@
   #define   __returns_twice
   #endif

-#if __has_attribute(alloc_size) || __GNUC_PREREQ__(4, 3)
-#define__alloc_size(x) __attribute__((__alloc_size__(x)))
-#else
-#define__alloc_size(x)
-#endif
-


This surely got through in GCC's case through the __GNUC_PREREQ__.
Of course gcc 4.2 has neither attribute but clang has alloc_size
so I wonder why it hasn't affected the lint builds.

Just curiosity, the change is OK but it will be getting ugly if we
have to add all the new attributes in the !lint section.

Regards,

Pedro.


clang in tree does not have the slightest idea about the alloc_size
attribute, and that is why it worked, as demonstrated by the test below:



Ugh yes, it appears it's unsupported still. I though I had seen a bug 
report with a patch but I can't find it anymore. Grepping it in contrib

doesn't show anything.

...


The original change to cdefs.h appears to be plain wrong.



Not really, it may appear some day.

Pedro.
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r287206 - head/sys/sys

2015-08-27 Thread Alexander Kabaev
On Thu, Aug 27, 2015 at 12:04 PM, Pedro Giffuni  wrote:

> Hello kan;
>
> On 08/27/15 09:00, Alexander Kabaev wrote:
>
>> Author: kan
>> Date: Thu Aug 27 14:00:23 2015
>> New Revision: 287206
>> URL: https://svnweb.freebsd.org/changeset/base/287206
>>
>> Log:
>>Repair sys/cdefs.h enough to be usable with GCC 5.x
>>
>>The __alloc_size and __alloc_align need to be defined to
>>nothingness for lint, but the existing check is deficient
>>and allows attributes with working __has_attrubute() to
>>slip through.
>>
>>
> AFAICT GCC hasn't added __has_attribute(), but if they did recently
> that is great news.
>
>

Actually I do not know if they did and I do not think it even matters that
much.
The existing conditional is not working for lint and I had to shuffle it
under bigger
'#ifdef lint' protection. Nor is the condition even well formed enough to
work with any
recent GCC and using __has_attribute in naked form is a mistake:

% cat t.c
#if __has_attribute(alloc_size)
# error Has attribute
#endif

% mips-portbld-freebsd11.0-gcc --version
mips-portbld-freebsd11.0-gcc (FreeBSD Ports Collection for mips) 5.2.0
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

% mips-portbld-freebsd11.0-gcc -E t.c
# 1 "t.c"
# 1 ""
# 1 ""
# 1 "t.c"
t.c:2:3: error: #error Has attribute
 # error Has attribute
   ^

% gcc48 --version
gcc48 (FreeBSD Ports Collection) 4.8.5
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

% gcc48 -E t.c
# 1 "t.c"
# 1 ""
# 1 ""
# 1 "t.c"
t.c:1:20: error: missing binary operator before token "("
 #if __has_attribute(alloc_size)



> Modified:
>>head/sys/sys/cdefs.h
>>
>> ..
>
>
>   #if !__GNUC_PREREQ__(2, 95)
>> @@ -371,24 +382,12 @@
>>   #define   __returns_twice
>>   #endif
>>
>> -#if __has_attribute(alloc_size) || __GNUC_PREREQ__(4, 3)
>> -#define__alloc_size(x) __attribute__((__alloc_size__(x)))
>> -#else
>> -#define__alloc_size(x)
>> -#endif
>> -
>>
>
> This surely got through in GCC's case through the __GNUC_PREREQ__.
> Of course gcc 4.2 has neither attribute but clang has alloc_size
> so I wonder why it hasn't affected the lint builds.
>
> Just curiosity, the change is OK but it will be getting ugly if we
> have to add all the new attributes in the !lint section.
>
> Regards,
>
> Pedro.
>

clang in tree does not have the slightest idea about the alloc_size
attribute, and that is why it worked, as demonstrated by the test below:

% cc --version
FreeBSD clang version 3.6.1 (tags/RELEASE_361/final 237755) 20150525
Target: x86_64-unknown-freebsd11.0
Thread model: posix

% cc -E t.c
# 1 "t.c"
# 1 "" 1
# 1 "" 3
# 311 "" 3
# 1 "" 1
# 1 "" 2
# 1 "t.c" 2

The original change to cdefs.h appears to be plain wrong.

-- 
Alexander Kabaev
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r287206 - head/sys/sys

2015-08-27 Thread Pedro Giffuni

Hello kan;

On 08/27/15 09:00, Alexander Kabaev wrote:

Author: kan
Date: Thu Aug 27 14:00:23 2015
New Revision: 287206
URL: https://svnweb.freebsd.org/changeset/base/287206

Log:
   Repair sys/cdefs.h enough to be usable with GCC 5.x

   The __alloc_size and __alloc_align need to be defined to
   nothingness for lint, but the existing check is deficient
   and allows attributes with working __has_attrubute() to
   slip through.



AFAICT GCC hasn't added __has_attribute(), but if they did recently
that is great news.


Modified:
   head/sys/sys/cdefs.h


..



  #if !__GNUC_PREREQ__(2, 95)
@@ -371,24 +382,12 @@
  #define   __returns_twice
  #endif

-#if __has_attribute(alloc_size) || __GNUC_PREREQ__(4, 3)
-#define__alloc_size(x) __attribute__((__alloc_size__(x)))
-#else
-#define__alloc_size(x)
-#endif
-


This surely got through in GCC's case through the __GNUC_PREREQ__.
Of course gcc 4.2 has neither attribute but clang has alloc_size
so I wonder why it hasn't affected the lint builds.

Just curiosity, the change is OK but it will be getting ugly if we
have to add all the new attributes in the !lint section.

Regards,

Pedro.
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r287206 - head/sys/sys

2015-08-27 Thread Alexander Kabaev
Author: kan
Date: Thu Aug 27 14:00:23 2015
New Revision: 287206
URL: https://svnweb.freebsd.org/changeset/base/287206

Log:
  Repair sys/cdefs.h enough to be usable with GCC 5.x
  
  The __alloc_size and __alloc_align need to be defined to
  nothingness for lint, but the existing check is deficient
  and allows attributes with working __has_attrubute() to
  slip through.

Modified:
  head/sys/sys/cdefs.h

Modified: head/sys/sys/cdefs.h
==
--- head/sys/sys/cdefs.hThu Aug 27 14:00:20 2015(r287205)
+++ head/sys/sys/cdefs.hThu Aug 27 14:00:23 2015(r287206)
@@ -39,7 +39,6 @@
 /*
  * Testing against Clang-specific extensions.
  */
-
 #ifndef__has_attribute
 #define__has_attribute(x)  0
 #endif
@@ -212,6 +211,8 @@
 #define__unused
 #define__packed
 #define__aligned(x)
+#define__alloc_align(x)
+#define__alloc_size(x)
 #define__section(x)
 #define__weak_symbol
 #else
@@ -236,6 +237,16 @@
 #define__aligned(x)__attribute__((__aligned__(x)))
 #define__section(x)__attribute__((__section__(x)))
 #endif
+#if __has_attribute(alloc_size) || __GNUC_PREREQ__(4, 3)
+#define__alloc_size(x) __attribute__((__alloc_size__(x)))
+#else
+#define__alloc_size(x)
+#endif
+#if __has_attribute(alloc_align) || __GNUC_PREREQ__(4, 9)
+#define__alloc_align(x)__attribute__((__alloc_align__(x)))
+#else
+#define__alloc_align(x)
+#endif
 #endif /* lint */
 
 #if !__GNUC_PREREQ__(2, 95)
@@ -371,24 +382,12 @@
 #define__returns_twice
 #endif
 
-#if __has_attribute(alloc_size) || __GNUC_PREREQ__(4, 3)
-#define__alloc_size(x) __attribute__((__alloc_size__(x)))
-#else
-#define__alloc_size(x)
-#endif
-
 #if __has_builtin(__builtin_unreachable) || __GNUC_PREREQ__(4, 6)
 #define__unreachable() __builtin_unreachable()
 #else
 #define__unreachable() ((void)0)
 #endif
 
-#if __has_attribute(alloc_align) || __GNUC_PREREQ__(4, 9)
-#define__alloc_align(x)__attribute__((__alloc_align__(x)))
-#else
-#define__alloc_align(x)
-#endif
-
 /* XXX: should use `#if __STDC_VERSION__ < 199901'. */
 #if !__GNUC_PREREQ__(2, 7) && !defined(__INTEL_COMPILER)
 #define__func__NULL
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"