From: Szabolcs Nagy <nsz@port70.net>
To: musl@lists.openwall.com
Subject: Re: gettimeofday
Date: Mon, 14 Apr 2014 12:16:15 +0200 [thread overview]
Message-ID: <20140414101615.GY3034@port70.net> (raw)
In-Reply-To: <CAGDMk9GmZBgQZtxhG4OSqH3gzMt=pjRVnbmXTSdHRFMnfvXo=A@mail.gmail.com>
* John Mudd <johnbmudd@gmail.com> [2014-04-13 22:03:10 -0400]:
> I ran into trouble when I built Postgres using musl on a modern Linux and
> tried to run it on an old Linux. The problem seemed to
> involve gettimeofday() so I tried this sample program.
...
> $ strace test_time
> execve("/home/jmudd/musl/test_time", ["test_time"], [/* 27 vars */]) = 0
> clock_gettime(0, 0xbfffae48) = -1 ENOSYS (Function not
> implemented)
> gettimeofday(NULL, {300, 0}) = 0
> ioctl(1, TCGETS, {B38400 opost isig icanon echo ...}) = 0
> writev(1, [{"gettimeofday() successful.", 26}, {"\n", 1}], 2gettimeofday()
> successful.
> ) = 27
> writev(1, [{"time = 300.000000", 17}, {"\n", 1}], 2time = 300.000000
> ) = 18
this is a bug in the (untested) clock_gettime fallback code
here is a fix:
diff --git a/src/time/clock_gettime.c b/src/time/clock_gettime.c
index ad5c09d..ce9f220 100644
--- a/src/time/clock_gettime.c
+++ b/src/time/clock_gettime.c
@@ -10,7 +10,7 @@ static int sc_clock_gettime(clockid_t clk, struct timespec *ts)
if (!r) return r;
if (r == -ENOSYS) {
if (clk == CLOCK_REALTIME) {
- __syscall(SYS_gettimeofday, clk, ts, 0);
+ __syscall(SYS_gettimeofday, ts, 0);
ts->tv_nsec = (int)ts->tv_nsec * 1000;
return 0;
}
next prev parent reply other threads:[~2014-04-14 10:16 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-04-14 2:03 gettimeofday John Mudd
2014-04-14 10:16 ` Szabolcs Nagy [this message]
2014-04-15 2:53 ` gettimeofday John Mudd
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=20140414101615.GY3034@port70.net \
--to=nsz@port70.net \
--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).