Re: [PATCH 4/4] cpu: Avoid c99 style of assembler

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Apr 27, 2017 at 09:22:04AM +0100, Daniel P. Berrange wrote:
> On Thu, Apr 27, 2017 at 09:24:54AM +0200, Peter Krempa wrote:
> > On Thu, Apr 27, 2017 at 09:02:00 +0200, Michal Privoznik wrote:
> > > In c89 - the standard we claim to support - there is no asm()
> > 
> > I'm not quite sure about the truth of this statement. Especially after
> > commits like:
> > 
> > 0f6c46c3d virsh.c: Switch to C99 initialization of vshCmdOptDef
> > 879d409e9 Convert all driver struct intializers to C99 style
> > 
> > and quite a lot more ...
> 
> Yep the C99 struct member initializers are a very valuable feature.
> I'd say, we aim for c89, plus selected c99 features.
> 
> We explicitly try to avoid some other c99 features though, such variables
> declared in the middle of functions.

Looking at the gcc/clang docs...

By default GCC applies a C standard called gnu89/gnu90, which is basically
c89/c90, but with a tonne of GCC extensions, many of which are present in
the newer c99.  Actually using c89 is impractical since it lacks even
basic things like  "inline" and var-args for macros.

CLang aims to be compatible with GCC extensions, but in fact defaults to
the even newer gnu11 standard, which is C11 + GCC extensions

It looks like the only GCC extensions we rely on from gnu89, are all
present in c99 - at least build succeeds with both std=gnu89 and std=c99

So, it is probably accurate to say we're compliant with c99, and if a
compiler doesn't support c99, it must support the GNU extensions to
c89.

In practice we only care about GCC & CLang.

So I guess the question from thsi patch series is mostly, which c99
features do we wish to explicitly avoid using.

Variable declarations in the middle of blocks is one we avoid, just
because it harms readability and understanding of code when goto is
just to jump over a variable declaration.

I see no problem using c99 asm statements, unless we're using a mix
of different asm syntaxes across the code base, in which case we
should standardize on one.

I tend to think it is worth avoiding C++ comments, just for sake of
having a consistent style across the code base.

Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]
  Powered by Linux