All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] HACKING: List areas where we may rely on impdef C behaviour
@ 2012-10-30 15:09 Peter Maydell
  2012-10-30 15:40 ` malc
  0 siblings, 1 reply; 4+ messages in thread
From: Peter Maydell @ 2012-10-30 15:09 UTC (permalink / raw)
  To: qemu-devel; +Cc: Blue Swirl, Paolo Bonzini, Anthony Liguori, patches

Add a section to HACKING describing the bits of implementation
defined C compiler behaviour which C code in QEMU is allowed
to rely on.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
Since the issue just came up. Have I missed anything off the list?

 HACKING | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/HACKING b/HACKING
index 89a6b3a..1e17ac7 100644
--- a/HACKING
+++ b/HACKING
@@ -123,3 +123,19 @@ gcc's printf attribute directive in the prototype.
 This makes it so gcc's -Wformat and -Wformat-security options can do
 their jobs and cross-check format strings with the number and types
 of arguments.
+
+6. Implementation defined and undefined behaviours
+
+The C language specification defines regions of undefined behaviour and
+implementation defined behaviour (to give compiler authors enough
+leeway to produce better code). In general, code in QEMU should
+follow the language specification and avoid both undefined and
+implementation defined constructs. ("It works fine on the gcc
+I tested it with" is not a valid argument...) However there are
+a few areas where we allow ourselves to assume certain behaviours
+because in practice all the platforms we care about behave in the
+same way and writing strictly conformant code would be painful.
+These are:
+ * you may assume that integers are 2s complement representation
+ * you may assume that right shift of a signed integer duplicates
+   the sign bit (ie it is an arithmetic shift, not a logical shift)
-- 
1.7.11.4

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [Qemu-devel] [PATCH] HACKING: List areas where we may rely on impdef C behaviour
  2012-10-30 15:09 [Qemu-devel] [PATCH] HACKING: List areas where we may rely on impdef C behaviour Peter Maydell
@ 2012-10-30 15:40 ` malc
  2012-10-30 16:15   ` Peter Maydell
  0 siblings, 1 reply; 4+ messages in thread
From: malc @ 2012-10-30 15:40 UTC (permalink / raw)
  To: Peter Maydell
  Cc: Blue Swirl, Paolo Bonzini, Anthony Liguori, qemu-devel, patches

On Tue, 30 Oct 2012, Peter Maydell wrote:

> Add a section to HACKING describing the bits of implementation
> defined C compiler behaviour which C code in QEMU is allowed
> to rely on.

People who will desperately do a text search for "behaviour" in
relevant standards will soon learn that the british spelling is
not favoured by WG14. Other than that this addition to the document
looks fine (a link to the freely available drafts and/or wikipedia
reference would be nice)

[..snip..]

-- 
mailto:av1474@comtv.ru

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Qemu-devel] [PATCH] HACKING: List areas where we may rely on impdef C behaviour
  2012-10-30 15:40 ` malc
@ 2012-10-30 16:15   ` Peter Maydell
  2012-10-30 16:55     ` malc
  0 siblings, 1 reply; 4+ messages in thread
From: Peter Maydell @ 2012-10-30 16:15 UTC (permalink / raw)
  To: malc; +Cc: Blue Swirl, Paolo Bonzini, Anthony Liguori, qemu-devel, patches

On 30 October 2012 16:40, malc <av1474@comtv.ru> wrote:
> On Tue, 30 Oct 2012, Peter Maydell wrote:
>
>> Add a section to HACKING describing the bits of implementation
>> defined C compiler behaviour which C code in QEMU is allowed
>> to rely on.
>
> People who will desperately do a text search for "behaviour" in
> relevant standards will soon learn that the british spelling is
> not favoured by WG14. Other than that this addition to the document
> looks fine (a link to the freely available drafts and/or wikipedia
> reference would be nice)

This one, right?
http://www.open-std.org/jtc1/sc22/WG14/www/docs/n1256.pdf
("Final version of the C99 standard with corrigenda TC1, TC2, and
TC3 included, formatted as a draft", to borrow wikipedia's description).

I guess I should also say we code to C99 in particular (ie not
C89 or C11).

-- PMM

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Qemu-devel] [PATCH] HACKING: List areas where we may rely on impdef C behaviour
  2012-10-30 16:15   ` Peter Maydell
@ 2012-10-30 16:55     ` malc
  0 siblings, 0 replies; 4+ messages in thread
From: malc @ 2012-10-30 16:55 UTC (permalink / raw)
  To: Peter Maydell
  Cc: Blue Swirl, Paolo Bonzini, Anthony Liguori, qemu-devel, patches

On Tue, 30 Oct 2012, Peter Maydell wrote:

> On 30 October 2012 16:40, malc <av1474@comtv.ru> wrote:
> > On Tue, 30 Oct 2012, Peter Maydell wrote:
> >
> >> Add a section to HACKING describing the bits of implementation
> >> defined C compiler behaviour which C code in QEMU is allowed
> >> to rely on.
> >
> > People who will desperately do a text search for "behaviour" in
> > relevant standards will soon learn that the british spelling is
> > not favoured by WG14. Other than that this addition to the document
> > looks fine (a link to the freely available drafts and/or wikipedia
> > reference would be nice)
> 
> This one, right?

Yes.

> http://www.open-std.org/jtc1/sc22/WG14/www/docs/n1256.pdf
> ("Final version of the C99 standard with corrigenda TC1, TC2, and
> TC3 included, formatted as a draft", to borrow wikipedia's description).
> 
> I guess I should also say we code to C99 in particular (ie not
> C89 or C11).


-- 
mailto:av1474@comtv.ru

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2012-10-30 16:55 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-10-30 15:09 [Qemu-devel] [PATCH] HACKING: List areas where we may rely on impdef C behaviour Peter Maydell
2012-10-30 15:40 ` malc
2012-10-30 16:15   ` Peter Maydell
2012-10-30 16:55     ` malc

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.