From owner-svn-src-head@FreeBSD.ORG Mon Apr 29 16:46:14 2013 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id C5B2D595; Mon, 29 Apr 2013 16:46:14 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from mail104.syd.optusnet.com.au (mail104.syd.optusnet.com.au [211.29.132.246]) by mx1.freebsd.org (Postfix) with ESMTP id 09D6A1F80; Mon, 29 Apr 2013 16:46:14 +0000 (UTC) Received: from c211-30-173-106.carlnfd1.nsw.optusnet.com.au (c211-30-173-106.carlnfd1.nsw.optusnet.com.au [211.30.173.106]) by mail104.syd.optusnet.com.au (Postfix) with ESMTPS id 8DEEB421360; Tue, 30 Apr 2013 02:22:02 +1000 (EST) Date: Tue, 30 Apr 2013 02:22:00 +1000 (EST) From: Bruce Evans X-X-Sender: bde@besplex.bde.org To: Ed Schouten Subject: Re: svn commit: r250037 - head/bin/hostname In-Reply-To: Message-ID: <20130430013949.O1819@besplex.bde.org> References: <201304282252.r3SMqiHH009205@svn.freebsd.org> <20130429212227.R1043@besplex.bde.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Optus-CM-Score: 0 X-Optus-CM-Analysis: v=2.0 cv=Gu4aYTJC c=1 sm=1 a=HGXDrXWPGKwA:10 a=kj9zAlcOel0A:10 a=PO7r1zJSAAAA:8 a=JzwRw_2MAAAA:8 a=S8Dq8nDLOMQA:10 a=ElF3g5Y_1pXU53sFaFAA:9 a=CjuIK1q_8ugA:10 a=TEtd8y5WR3g2ypngnwZWYw==:117 Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org, Eitan Adler , Bruce Evans X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.14 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: Mon, 29 Apr 2013 16:46:14 -0000 On Mon, 29 Apr 2013, Ed Schouten wrote: > 2013/4/29 Bruce Evans : >> - usr.bin/rlogin/rlogin.c has it in a gratuitously different form, as >> 'static _Noreturn void usage(void);'. This is bogus since >> _Noreturn is a wrapper for a new C++ feature > > I hate to correct you here, but _Noreturn is not a wrapper for a new > C++ feature, it's a keyword that's part of C11. See: Yes, I misread the ifdef in sys/cdefs.h. So it is a new C feature as well as a new C++ feature. > All C11 keywords can be implemented on top of GCC-specific constructs, > with the exception of _Generic. I would strongly prefer it if we used > these keywords over our FreeBSD-specific solutions. That would mainly churn the source code, and still depend for portability on FreeBSD #defining them in sys/cdefs.h. Just with different spelling. > If the only objection is the spelling of these keywords (underscores, > uppercase, etc), be sure to: > > #include /* For alignas/alignof. */ > #include /* For noreturn. */ > #include /* For thread_local. */ Ideally, new code would just use the new features. Then it would need includes to get the nicer spelling and not depend on FreeBSD features. But it is easier to use the FreeBSD features. I once hoped that the portability hacks in sys/cdefs.h (that is, the whole file) would go away when C became standard. Instead, it grew many more. It is now 7 times larger and many more than 7 times more convoluted than in FreeBSD-1. In FreeBSD-1, it only defined the following macros: __BEGIN_DECLS, __CONCAT(), __END_DECLS, __P(), __STRING(), __dead, __pure, const, inline, signed, volatile where only the last 4 are for corrupting Standard C keywords. `noreturn' (case-insensitive) is now used 9 times in /usr/src/*bin (.c files): - 4 times for hard-coded __attribute__(()) - 3 times in rlogin.c for _Noreturn. I already pointed out some of the syntax problems with these. They are unportable since they give syntax errors with some versions of gcc, while either __dead or __dead2 would not have these syntax errors when correctly placed. I don't know if the C11 keyword can be placed almost anywhere like the attribute can be now. If not, then it would be impossible to replace all the __dead2's by it without changing the syntax, and then it would give syntax errors for the old compilers. - 2 times for NORETURN comments after usage() in fstat. These are just garbage. They are because lint is too stupid to understand __dead2 or _Noreturn, so it needs a comment to tell it that usage() doesn't return. But the comment for this is NOTREACHED, not NORETURN. NORETURN also misdescribes the situtation for human readers, since it is usage() that doesn't return and the code after it that is not reached. I dislike even correct lint comments. Telling the compiler than functions don't return has worked better than telling lint this for more than 20 years. Bruce