svn commit: r238907 - projects/calloutng/sys/kern
Bruce Evans
brde at optusnet.com.au
Wed Sep 19 09:14:30 UTC 2012
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.
Bruce
More information about the svn-src-projects
mailing list