From owner-svn-src-all@freebsd.org Thu Aug 27 17:41:12 2015 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id C4A6C9C3EC3; Thu, 27 Aug 2015 17:41:12 +0000 (UTC) (envelope-from kabaev@gmail.com) Received: from mail-wi0-x233.google.com (mail-wi0-x233.google.com [IPv6:2a00:1450:400c:c05::233]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 52BBB142; Thu, 27 Aug 2015 17:41:12 +0000 (UTC) (envelope-from kabaev@gmail.com) Received: by wicge2 with SMTP id ge2so283244wic.0; Thu, 27 Aug 2015 10:41:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=V2sMI9QqtRc349SNoScCxUDRvj1pXHZz/NgJfYXO3xc=; b=ubxwSF+bzmZ+PuHl+vR9kHYJ/V2ZeUHjqB898NVAwRIddsMelg8Hme3egYVyOMQlYH oYSjSWAOT3yynWwq+/luOIeMiEsDtgshn2WcCK1nI8P8XIGTHS81jAperkp/hm11/6UX okDK8TvWBNeSDg/nYFHT5L+fKNFVcsbqwkSY9oBuppRzJRyysJmPK/8V0x9JnctFep7d XayTXRX6RLY4d/CZspYeQFvNHcl5lD+L3dG0DKA6fYXBsNiNqMG35PSeYi3bGy1wQyJR xeqI0ZDgPD7qp4TU2eKJhhyu+fgzoK9d7m7+pRYT+KvrH0jGp3QfnMz3ujvsj5pZzDef T4Gg== MIME-Version: 1.0 X-Received: by 10.194.85.163 with SMTP id i3mr6314862wjz.75.1440697269814; Thu, 27 Aug 2015 10:41:09 -0700 (PDT) Received: by 10.28.92.130 with HTTP; Thu, 27 Aug 2015 10:41:09 -0700 (PDT) In-Reply-To: <55DF3519.1000106@FreeBSD.org> References: <201508271400.t7RE0Nbc071389@repo.freebsd.org> <55DF3519.1000106@FreeBSD.org> Date: Thu, 27 Aug 2015 13:41:09 -0400 Message-ID: Subject: Re: svn commit: r287206 - head/sys/sys From: Alexander Kabaev To: Pedro Giffuni Cc: "src-committers@freebsd.org" , "svn-src-all@freebsd.org" , "svn-src-head@freebsd.org" Content-Type: text/plain; charset=UTF-8 X-Content-Filtered-By: Mailman/MimeDel 2.1.20 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 27 Aug 2015 17:41:13 -0000 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