mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Rich Felker <dalias@libc.org>
To: musl@lists.openwall.com
Subject: Re: [UGLY PATCH v2] Support for no-legacy-syscalls archs
Date: Mon, 26 May 2014 18:46:55 -0400	[thread overview]
Message-ID: <20140526224655.GB507@brightrain.aerifal.cx> (raw)
In-Reply-To: <20140526223924.GK12324@port70.net>

On Tue, May 27, 2014 at 12:39:24AM +0200, Szabolcs Nagy wrote:
> * Rich Felker <dalias@libc.org> [2014-05-26 17:54:12 -0400]:
> > On Mon, May 26, 2014 at 11:13:49PM +0200, Szabolcs Nagy wrote:
> > > > +	if (tv) {
> > > > +		ts.tv_sec = tv->tv_sec;
> > > > +		ts.tv_nsec = tv->tv_usec > 999999 ?
> > > > +			999999999 : tv->tv_usec * 1000;
> > > > +	}
> > > > +	return syscall_cp(SYS_pselect6, n, rfds, wfds, efds, tv ? &ts : 0, data);
> > > > +#endif
> > > 
> > > tv_usec may be negative
> > 
> > Then the kernel should generate the EINVAL for us.
> 
> but the multiplication may overflow

Indeed, I missed that.

> > > isnt it better to adjust tv_sec if usec is large?
> > > or fail with EINVAL like in futimensat:
> > 
> > POSIX allows implementation-defined limits on the duration, but now
> > that you say it, what I wrote above is not not a correct
> > implementation of such a limit. I'm not clear on whether we should
> > renormalize into timespec or just reject out-of-range usec values;
> > unlike in some other places where timespec is used, POSIX is missing
> > text on select and pselect regarding how out-of-range timespec and
> > timeval structs should be handled...
> > 
> 
> fwiw the kernel fixes large tv_usec in select:
> 
> ....
>   tv.tv_sec + (tv.tv_usec / USEC_PER_SEC),

Does it handle the overflow here? :)

In any case, doing what the kernel does is probably desirable to
minimize differences between archs.

Rich


  reply	other threads:[~2014-05-26 22:46 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-25  5:42 [UGLY PATCH] " Rich Felker
2014-05-25  9:52 ` Szabolcs Nagy
2014-05-25  9:57   ` Justin Cormack
2014-05-25 11:45   ` Rich Felker
2014-05-26  4:28 ` Rich Felker
2014-05-26 18:40 ` [UGLY PATCH v2] " Rich Felker
2014-05-26 21:13   ` Szabolcs Nagy
2014-05-26 21:54     ` Rich Felker
2014-05-26 22:39       ` Szabolcs Nagy
2014-05-26 22:46         ` Rich Felker [this message]
2014-05-27  5:26 ` [UGLY PATCH v3] " Rich Felker
2014-05-27 11:29   ` Szabolcs Nagy
2014-05-27 19:01     ` Rich Felker
2014-05-29 21:46   ` Rich Felker
2014-05-29 23:04   ` Rich Felker

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=20140526224655.GB507@brightrain.aerifal.cx \
    --to=dalias@libc.org \
    --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).