From owner-svn-src-projects@FreeBSD.ORG Wed Sep 19 09:14:29 2012 Return-Path: Delivered-To: svn-src-projects@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E85811065670; Wed, 19 Sep 2012 09:14:29 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from mail16.syd.optusnet.com.au (mail16.syd.optusnet.com.au [211.29.132.197]) by mx1.freebsd.org (Postfix) with ESMTP id 72E7C8FC0A; Wed, 19 Sep 2012 09:14:28 +0000 (UTC) Received: from c122-106-157-84.carlnfd1.nsw.optusnet.com.au (c122-106-157-84.carlnfd1.nsw.optusnet.com.au [122.106.157.84]) by mail16.syd.optusnet.com.au (8.13.1/8.13.1) with ESMTP id q8J9EHem012584 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 19 Sep 2012 19:14:19 +1000 Date: Wed, 19 Sep 2012 19:14:17 +1000 (EST) From: Bruce Evans X-X-Sender: bde@besplex.bde.org To: Attilio Rao In-Reply-To: Message-ID: <20120919190309.R1306@besplex.bde.org> References: <201207301350.q6UDobCI099069@svn.freebsd.org> <201207301732.33474.jhb@freebsd.org> <20120918083324.GX37286@deviant.kiev.zoral.com.ua> <20120919041811.GM37286@deviant.kiev.zoral.com.ua> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Cc: Davide Italiano , src-committers@freebsd.org, John Baldwin , Jeff Roberson , Dimitry Andric , svn-src-projects@freebsd.org, Konstantin Belousov Subject: Re: svn commit: r238907 - projects/calloutng/sys/kern X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 19 Sep 2012 09:14:30 -0000 On Wed, 19 Sep 2012, Attilio Rao wrote: > On Wed, Sep 19, 2012 at 5:18 AM, Konstantin Belousov > wrote: >> On Tue, Sep 18, 2012 at 08:00:48PM +0100, Attilio Rao wrote: >>> ... >>> Here is the patch. I didn't use a real extern function body for it, >>> but just went with an empty macro. >>> ... >>> +/* >>> + * Compiler memory barriers, specific to gcc and clang. >>> + */ >>> +#if defined(__GNUC__) >>> +#define __compiler_membar() __asm __volatile(" " : : : "memory") >>> +#else >>> +#define __compiler_membar() struct __hack >>> +#endif >> >> I would not call this an empty macro. If this works at all, it requires >> c99 compiler. Why not just do >> extern void __compiler_membar(void); >> for !GNUC. Note that we never supplied actual implementation for the >> placeholders, as evidenced e.g. by cpufunc.h or fpu.c. > > So the main reason for this is to keep compliancy with c'89? Are you > sure it is so important nowadays? > I'm always under the impression that we are already using c'99 > specific features, like structs initializers, etc. 'struct __hack' requires a c83 compiler. It is used extensively and worked in 1993. One point of using an extern function is to break properly when a feature is missing. For a random compiler, you wouldn't know if it needs the feature. OTOH, your original version with no support breaks even better, by giving a spew of error messages (at least with -Wmumble-prototypes). Many of the features in sys/cdefs.h are handled in this way. E.g., using __packed is a syntax error unless it is known to work (for __GNUC_PREREQ(2, 7) || __INTEL_COMPILER), except for lint it is bogusly stubbed out so that it is not properly broken for line. Bruce