Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 19 Sep 2012 10:23:10 +0100
From:      Attilio Rao <attilio@freebsd.org>
To:        Bruce Evans <brde@optusnet.com.au>
Cc:        Davide Italiano <davide@freebsd.org>, src-committers@freebsd.org, John Baldwin <jhb@freebsd.org>, Jeff Roberson <jeff@freebsd.org>, Dimitry Andric <dim@freebsd.org>, svn-src-projects@freebsd.org, Konstantin Belousov <kostikbel@gmail.com>
Subject:   Re: svn commit: r238907 - projects/calloutng/sys/kern
Message-ID:  <CAJ-FndAAifjnNHavXBBxxfitx8devs6zLyTgifvHbwdxJVcP9A@mail.gmail.com>
In-Reply-To: <20120919190309.R1306@besplex.bde.org>
References:  <201207301350.q6UDobCI099069@svn.freebsd.org> <CAJ-FndBj8tpC_BJXs_RH8sG2TBG8yA=Lxu3-GTVT9Ap_zOCuVQ@mail.gmail.com> <CAJ-FndDnO7wjnWPV0tTu%2BUGHjsxa3YDarMxmyei3ZmjLAFvRkQ@mail.gmail.com> <201207301732.33474.jhb@freebsd.org> <CAJ-FndD5EO12xsWOAe6u0EvX00q33wxO4OivnGjzj0=T2Oe8uA@mail.gmail.com> <CAJ-FndCRg0UCThFkatp=tw7rUWWCvhsApLE=iztLpxpGBC1F9w@mail.gmail.com> <20120918083324.GX37286@deviant.kiev.zoral.com.ua> <CAJ-FndAXw6zjXr=zB3gAVQDKUV_K4=SF39iYQQOV23NkfJ=MPw@mail.gmail.com> <CAJ-FndCmg-GdTf9FWQGZPYB-iGuEt-JH8HrCL%2BwaOqJ%2B8ZUbHQ@mail.gmail.com> <20120919041811.GM37286@deviant.kiev.zoral.com.ua> <CAJ-FndD90M2BAEcrjWG0YFCUrNu5Yad-5sRv=n8QXFbtYmo%2BjQ@mail.gmail.com> <20120919190309.R1306@besplex.bde.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On 9/19/12, Bruce Evans <brde@optusnet.com.au> wrote:
> On Wed, 19 Sep 2012, Attilio Rao wrote:
>
>> On Wed, Sep 19, 2012 at 5:18 AM, Konstantin Belousov
>> <kostikbel@gmail.com> 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.

I see.
So definitively what version do you prefer? The one using the external
definition or the one without anything?

Attilio


-- 
Peace can only be achieved by understanding - A. Einstein



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAJ-FndAAifjnNHavXBBxxfitx8devs6zLyTgifvHbwdxJVcP9A>