From: Mike Frysinger <vapier@gentoo.org>
To: Karel Zak <kzak@redhat.com>
Cc: kerolasa@gmail.com, util-linux@vger.kernel.org
Subject: Re: [PATCH 03/19] write: stop using MAXHOSTNAMELEN
Date: Mon, 22 Oct 2012 16:03:01 -0400 [thread overview]
Message-ID: <201210221603.02244.vapier@gentoo.org> (raw)
In-Reply-To: <20121022080624.GA21724@x2.net.home>
[-- Attachment #1: Type: Text/Plain, Size: 3019 bytes --]
On Monday 22 October 2012 04:06:24 Karel Zak wrote:
> On Mon, Oct 22, 2012 at 02:01:01AM -0400, Mike Frysinger wrote:
> > On Thursday 18 October 2012 16:06:28 Sami Kerola wrote:
> > > On Mon, Oct 15, 2012 at 3:14 AM, Mike Frysinger wrote:
> > > > On Sunday 14 October 2012 16:20:59 Sami Kerola wrote:
> > > >> POSIX.1-2001 declares usleep is obsolete.
> > > >
> > > > this is true, but it seems like a better answer would be to add a
> > > > usleep test to configure and provide a local fallback using nanosleep
> > > > if it doesn't exist.
> > >
> > > Is that necessary? There has been for example in old mount since March
> > > 2007[1] nanosleep() call, and I cannot remember anyone complaining it
> > > causing problems.
> > >
> > > [1] commit dc8fdc57cd3ba0658cf4ab05031695c2d2965f93
> >
> > i think you misinterpreted my objection. i don't have a problem with
> > calling nanosleep() -- when it makes sense. replacing a simple call to
> > a function that, while no longer part of the latest standard, was
> > mandated for many many years, and will most likely never be removed from
> > C libraries that have already been providing it (since it'd be an ABI
> > break), with a more complicated call for no real reason is pointless
> > imo. further, you'd be fighting a losing battle: developers will most
> > likely be working & testing on a glibc system where usleep does exist
> > and works fine, so they won't notice if it were added again.
> >
> > hence i suggested a trivial middle ground that is future proof and
> > doesn't penalize systems that do include usleep (i.e. glibc i.e. what
> > the majority of people run): if you actually have a system that lacks
> > usleep, then add usleep to the AC_CHECK_FUNCS tests in configure.ac, and
> > then add the simple replacement to include/c.h:
> > #ifndef HAVE_USLEEP
> > static inline int usleep(useconds_t usec)
> > {
> >
> > struct timespec waittime;
> > waittime.tv_sec = usec / 1000000L;
> > waittime.tv_nsec = (usec % 1000000L) * 1000;
> > return nanosleep(&waittime, NULL);
> >
> > }
> > #endif
> >
> > now everything should "just work".
>
> Exactly this solution we use for now (since 2009):
heh. too fast!
> $ cat include/usleep.h
>
> #ifndef UTIL_LINUX_USLEEP_H
> #define UTIL_LINUX_USLEEP_H
>
> #ifndef HAVE_USLEEP
> /*
> * This function is marked obsolete in POSIX.1-2001 and removed in
> * POSIX.1-2008. It is replaced with nanosleep().
> */
> # define usleep(x) \
> do { \
> struct timespec xsleep; \
> xsleep.tv_sec = x / 1000 / 1000; \
> xsleep.tv_nsec = (x - xsleep.tv_sec * 1000 * 1000) * 1000; \
> nanosleep(&xsleep, NULL); \
> } while (0)
> #endif
>
> #endif /* UTIL_LINUX_USLEEP_H */
if you were to do something like:
int foo = 10;
usleep(foo++);
this define macro would misbehave because it expands x twice. not that the
current code base does.
> ... so I don't think we have to check change anything.
indeed
-mike
[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
next prev parent reply other threads:[~2012-10-22 20:03 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-10-14 20:20 [PATCH 00/19] compliancy fixes Sami Kerola
2012-10-14 20:20 ` [PATCH 01/19] last: stop using MAXHOSTNAMELEN Sami Kerola
2012-10-15 1:46 ` Mike Frysinger
2012-10-14 20:20 ` [PATCH 02/19] login: " Sami Kerola
2012-10-14 20:20 ` [PATCH 03/19] write: " Sami Kerola
2012-10-15 2:12 ` Mike Frysinger
[not found] ` <20121015152558.GK18377@x2.net.home>
2012-10-18 20:06 ` Sami Kerola
2012-10-22 6:01 ` Mike Frysinger
2012-10-22 8:06 ` Karel Zak
2012-10-22 8:09 ` Karel Zak
2012-10-22 20:03 ` Mike Frysinger [this message]
2012-10-22 20:22 ` Karel Zak
2012-10-14 20:20 ` [PATCH 04/19] agetty: " Sami Kerola
2012-10-14 20:20 ` [PATCH 05/19] c.h: remove unnecessary MAXHOSTNAMELEN fallback definition Sami Kerola
2012-10-14 20:20 ` [PATCH 06/19] docs: add line breaks to whereis.1 Sami Kerola
2012-10-14 20:20 ` [PATCH 07/19] sd-daemon: fix cppcheck warnings Sami Kerola
2012-10-14 22:10 ` Dave Reisner
2012-10-15 8:32 ` Sami Kerola
2012-10-14 20:20 ` [PATCH 08/19] libmount: replace usleep with nanosleep Sami Kerola
2012-10-15 2:14 ` Mike Frysinger
2012-10-14 20:21 ` [PATCH 09/19] include/all-io: " Sami Kerola
2012-10-14 20:21 ` [PATCH 10/19] hwclock: " Sami Kerola
2012-10-14 20:21 ` [PATCH 11/19] rtcwake: " Sami Kerola
2012-10-14 20:21 ` [PATCH 12/19] agetty: " Sami Kerola
2012-10-14 20:21 ` [PATCH 13/19] tailf: " Sami Kerola
2012-10-14 20:21 ` [PATCH 14/19] include/usleep: remove remaining references to usleep Sami Kerola
2012-10-14 20:21 ` [PATCH 15/19] libmount, eject: replace index() and rindex() with strrch() or strrchr() Sami Kerola
2012-10-15 2:14 ` Mike Frysinger
2012-10-14 20:21 ` [PATCH 16/19] logger: replace gethostbyname() with getaddrinfo() Sami Kerola
2012-10-14 20:21 ` [PATCH 17/19] agetty: " Sami Kerola
2012-10-14 20:21 ` [PATCH 18/19] build-sys: remove gethostbyname() check Sami Kerola
2012-10-14 20:21 ` [PATCH 19/19] fsck.cramfs: replace utime() with utimensat() Sami Kerola
2012-10-15 2:17 ` Mike Frysinger
2012-10-15 8:36 ` Sami Kerola
2012-10-15 17:39 ` Mike Frysinger
2012-10-22 9:07 ` [PATCH 00/19] compliancy fixes Karel Zak
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=201210221603.02244.vapier@gentoo.org \
--to=vapier@gentoo.org \
--cc=kerolasa@gmail.com \
--cc=kzak@redhat.com \
--cc=util-linux@vger.kernel.org \
/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).