qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Martin Guy" <martinwguy@yahoo.it>
To: qemu-devel@nongnu.org
Cc: schwab@suse.de
Subject: Re: [Qemu-devel] [PATCH] Fix char signedness
Date: Sat, 28 Oct 2006 11:46:05 +0100	[thread overview]
Message-ID: <56d259a00610280346j5b88de07p203dd6f82c3543c2@mail.gmail.com> (raw)
In-Reply-To: <20061027.122311.-365734984.imp@bsdimp.com>

> gcc on ARM systems default to unsigned.  The C standard specifically
> states that char is either signed or unsigned at the whim of the
> implementor

Or, more to the point, at the behest of the machine architecture.
Having to generate code to sign-extend the hard way every time you do
char-integer promotion if the hardware doesn't do it automatically
would be long and inefficient, specially since it happens all the
time.
This has been a problem since the "All the world's a VAX" days, the
classic boob being

char c;
while ((c = getchar()) != EOF) {
     ...
}

of course, 255 always != -1 so it loops forever.
Check how many of your C primers get this wrong!
The flipside of that boob is that on a signed char architecture, the
loop will exit prematurely when it meets a 255 character.

These days instead, all the world's a 386 and anything different is broken...

24-bit integers, anyone? :)

   M

  reply	other threads:[~2006-10-28 10:46 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-10-27 17:07 [Qemu-devel] [PATCH] Fix char signedness Andreas Schwab
2006-10-27 17:40 ` Johannes Schindelin
2006-10-27 17:54   ` andrzej zaborowski
2006-10-27 17:58   ` Andreas Schwab
2006-10-27 18:23     ` M. Warner Losh
2006-10-28 10:46       ` Martin Guy [this message]
2006-10-28 19:04         ` Rob Landley
2006-10-27 22:57     ` Johannes Schindelin
2006-10-27 23:09       ` Paul Brook
2006-10-28 18:58         ` Rob Landley
2006-10-27 23:12       ` Thiemo Seufer
2006-10-27 23:17       ` M. Warner Losh
2006-10-28 10:14       ` Laurent Desnogues

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=56d259a00610280346j5b88de07p203dd6f82c3543c2@mail.gmail.com \
    --to=martinwguy@yahoo.it \
    --cc=qemu-devel@nongnu.org \
    --cc=schwab@suse.de \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).