mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Rich Felker <dalias@aerifal.cx>
To: musl@lists.openwall.com
Subject: Re: sign (in)consistency between architectures
Date: Wed, 1 May 2013 18:41:32 -0400	[thread overview]
Message-ID: <20130501224132.GN20323@brightrain.aerifal.cx> (raw)
In-Reply-To: <20130501200007.GM20323@brightrain.aerifal.cx>

On Wed, May 01, 2013 at 04:00:07PM -0400, Rich Felker wrote:
> On Wed, May 01, 2013 at 08:00:15PM +0200, Szabolcs Nagy wrote:
> > * Z. Gilboa <zg7s@eservices.virginia.edu> [2013-05-01 13:05:03 -0400]:
> > > The current architecture-specific type definitions
> > > (arch/*/bits/alltypes.h) seem to entail the following inconsistent
> > > signed/unsigned types:
> > > 
> > > type      x86_64        i386
> > > -------------------------------
> > > uid_t     unsigned      signed
> > > gid_t     unsigned      signed
> > > dev_t     unsigned      signed
> > > clock_t   signed        unsigned
> > 
> > 
> > i can verify that glibc uses unsigned
> > uid_t,gid_t,dev_t and signed clock_t
> > 
> > of course applications should not depend on
> > the signedness, but if they appear in a c++
> > api then the difference can cause problems
> > 
> > and cock_t may be used in arithmetics where
> > signedness matters
> 
> uid_t, gid_t, and dev_t we can consider changing; I don't think it
> matters a whole lot and like you said they affect C++ ABI. clock_t
> cannot be changed without making the clock() function unusable. See
> glibc bug #13080 (WONTFIX):
> 
> http://sourceware.org/bugzilla/show_bug.cgi?id=13080

I just posted a followup on this bug: from what I can tell, it's
questionable whether having the return value of clock() wrap is
conforming even if clock_t is an unsigned type, and definitely
non-conforming if it's a signed type. As such, I see three possible
solutions:

1. Leave things along and do it the way musl does it now, where
subtracting (unsigned) results works. We should probably add a check
to see if the return value would be equal to (clock_t)-1, and if so,
either add or subtract 1, so that the caller does not interpret the
return value as an error.

2. Change clock_t to a signed type, and have clock() check for
overflow and permanently return -1 once the process has used more than
2147 seconds of cpu time. This seems undesirable to applications.

3. Change clock_t to long long on 32-bit targets. This would be
formally incompatible with the the glibc/LSB ABI, but in practice the
worst that would happen is that the register containing the upper bits
would get ignored.

Any opinions on the issue?

Rich


  reply	other threads:[~2013-05-01 22:41 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-01 17:05 Z. Gilboa
2013-05-01 18:00 ` Szabolcs Nagy
2013-05-01 20:00   ` Rich Felker
2013-05-01 22:41     ` Rich Felker [this message]
2013-05-02  1:39       ` Z. Gilboa
2013-05-02  2:47         ` Rich Felker
2013-05-02  8:12           ` Jens Gustedt
2013-05-02 10:13             ` Szabolcs Nagy
2013-05-02 12:12               ` Jens Gustedt
2013-05-02 13:08                 ` Szabolcs Nagy

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=20130501224132.GN20323@brightrain.aerifal.cx \
    --to=dalias@aerifal.cx \
    --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).