mailing list of musl libc
 help / color / mirror / code / Atom feed
From: ibid.ag@gmail.com
To: musl@lists.openwall.com
Subject: Re: Left-shift of negative number
Date: Sat, 18 Jul 2015 13:01:43 -0700	[thread overview]
Message-ID: <20150718200142.GB1999@Caracal> (raw)
In-Reply-To: <20150717213521.GD1173@brightrain.aerifal.cx>

On Fri, Jul 17, 2015 at 05:35:22PM -0400, Rich Felker wrote:
> > What worries me more than the shift of a negative value, is that this
> > code is erroneous if `int` is only 16 bit wide. Whereas we can
> > reasonably assume that a shift of a negative value in two's complement
> > is the same as an unsigned shift, compilers tend to produce just crap
> > if the shift exceeds the width.
> > 
> > So I would feel much more comfortable if we'd use UINT32_C(0x40)
> > inside the R macro.
> 
> The entire internal API here uses the type unsigned for character
> codes and state, so like the rest of musl there is an assumption
> (guaranteed by POSIX) that int is at least 32-bit. Since the
> UTF-8/multibyte code is written to be largely self-contained and
> independent of musl, we could look into enhancing the code to be
> portable to systems with 16-bit int, but I suspect this would be
> rather useless in practice. If we did that, we would need to use
> something ugly like uint_least32_t rather than uint32_t to gain any
> portability since the latter need not even exist.

As far as I know, 16-bit int is applicable to the following platforms:
-Some ports of certain RTOSes to 8 or 16 bit microcontrollers
 (ie, FreeRTOS and perhaps eCos)
-DOS, when *not* using GCC (DJGPP uses 32-bit int); this boils down to
 OpenWatcom, the old C89 compilers, and even older K&R-ish compilers.
-FUZIX
-ELKS
-Minix (8086 version)
-Xenix and other old commercial 16-bit *nixes

FUZIX uses sdcc, which is an incomplete C89-ish compiler.
ELKS uses a K&R compiler that can be used with a preprocessor
to compile some C89 code.
Old *nixes use K&R C.
8086 Minix uses ACK, which is C89; there's an experimental port of
PCC to the 8086, but that's a long way from being useable right now.
(Alan Cox is working on it part time so he can port FUZIX to the PC.)

In short, the possible compilers are OpenWatcom, or various bits
that are C89 at best (can't rely on uint* being available at all,
short of a custom "limits.h").

I'm not sure if OpenWatcom uses 16-bit int when building in 32-bit mode;
the compatability with HXRT would suggest that it doesn't.
So to make it meaningful, you would have to make it work with segmented
memory and probably C89.

Odd as it may sound, there are people using UTF on DOS (the Blocek text
editor comes to mind); but I'm not aware of interest in UTF on 16-bit DOS.


Thanks,
Isaac Dunham





  reply	other threads:[~2015-07-18 20:01 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-17 18:28 Loïc Runarvot
2015-07-17 19:02 ` Jens Gustedt
2015-07-17 19:38   ` Alex
2015-07-17 21:35   ` Rich Felker
2015-07-18 20:01     ` ibid.ag [this message]
2015-07-17 21:28 ` Rich Felker
2015-07-25  3:22   ` Rich Felker
2015-07-25 18:26     ` Alexander Cherepanov
2015-07-26 16:53       ` Rich Felker
2015-07-26 21:23         ` Alexander Cherepanov
2015-07-17 19:55 Pascal Cuoq

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=20150718200142.GB1999@Caracal \
    --to=ibid.ag@gmail.com \
    --cc=musl@lists.openwall.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.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

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).