svn commit: r238907 - projects/calloutng/sys/kern
Attilio Rao
attilio at freebsd.org
Wed Sep 19 09:23:14 UTC 2012
On 9/19/12, Bruce Evans <brde at optusnet.com.au> wrote:
> On Wed, 19 Sep 2012, Attilio Rao wrote:
>
>> On Wed, Sep 19, 2012 at 5:18 AM, Konstantin Belousov
>> <kostikbel at 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
More information about the svn-src-projects
mailing list