From: "Rémi Denis-Courmont" <remi@remlab.net>
To: Mauro Carvalho Chehab <mchehab@redhat.com>
Cc: mchehab@infradead.org, linux-media@vger.kernel.org,
linux-kernel@vger.kernel.org, Alan Cox <alan@lxorguk.ukuu.org.uk>,
Hans Verkuil <hverkuil@xs4all.nl>
Subject: Re: [RFC] [PATCH] v4l2: use unsigned rather than enums in ioctl() structs
Date: Wed, 11 Apr 2012 23:32:21 +0300 [thread overview]
Message-ID: <201204112332.24353.remi@remlab.net> (raw)
In-Reply-To: <4F85E133.4030404@redhat.com>
Le mercredi 11 avril 2012 22:53:23 Mauro Carvalho Chehab, vous avez écrit :
> > But you have been royally ignoring that rule when it
> > comes to extending existing enumerations:
> The existing enumerations can be extended, by adding new values for unused
> values, otherwise API functionality can't be extended.
Yes. That's why they should be some unsigned type.
> Yet, except
> for a gcc bug (or weird optimize option), I fail to see why this would
> break the ABI.
>From the perspective of the compiler, this is a feature not a bug. In C and
C++, loading or storing a value in an enumerated variable whereby the value is
not a member of the enumeration is undefined. In other words, the compiler can
assume that this does not happen, and optimize it away.
> If this is all about some gcc optimization with newer gcc versions, then
> maybe the solution may be to add some pragmas at the code to disable such
> optimization when compiling the structs with enum's at videodev2.h.
Maybe the Linux kernel could be specifically compiled to prevent GCC from
range-optimizing enumerations. But as -fno-jump-table only disables one of
several potential range optimizations, I doubt this is even possible.
Regardless, you cannot require all of Linux userspace to rely on an hypothetic
non-standard GNU C extension. Thus extending enums remains a silent userspace
ABI break in any case.
--
Rémi Denis-Courmont
http://www.remlab.net/
http://fi.linkedin.com/in/remidenis
next prev parent reply other threads:[~2012-04-11 20:32 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-04-05 17:52 [RFC] [PATCH] v4l2: use unsigned rather than enums in ioctl() structs Rémi Denis-Courmont
2012-04-11 17:02 ` Mauro Carvalho Chehab
2012-04-11 18:47 ` Rémi Denis-Courmont
2012-04-11 19:53 ` Mauro Carvalho Chehab
2012-04-11 20:32 ` Rémi Denis-Courmont [this message]
2012-04-12 17:22 ` Nick Bowler
2012-04-11 20:08 ` Mauro Carvalho Chehab
2012-04-12 8:04 ` James Courtier-Dutton
2012-04-12 14:55 ` Mauro Carvalho Chehab
2012-04-12 15:41 ` Rémi Denis-Courmont
2012-04-17 17:50 ` Mauro Carvalho Chehab
2012-04-27 8:24 ` [RFC 1/1] v4l: Implement compat handlers for ioctls containing enums Sakari Ailus
2012-04-13 8:25 ` [RFC] [PATCH] v4l2: use unsigned rather than enums in ioctl() structs James Courtier-Dutton
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=201204112332.24353.remi@remlab.net \
--to=remi@remlab.net \
--cc=alan@lxorguk.ukuu.org.uk \
--cc=hverkuil@xs4all.nl \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@infradead.org \
--cc=mchehab@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.