* gettimeofday
@ 2014-04-14 2:03 John Mudd
2014-04-14 10:16 ` gettimeofday Szabolcs Nagy
2014-04-15 2:53 ` gettimeofday John Mudd
0 siblings, 2 replies; 3+ messages in thread
From: John Mudd @ 2014-04-14 2:03 UTC (permalink / raw)
To: musl
[-- Attachment #1: Type: text/plain, Size: 1894 bytes --]
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.
$ cat test_time.c
#include <sys/time.h>
#include <stdio.h>
#include <errno.h>
int main(int argc, char *argv[])
{
struct timeval now;
int rc;
rc=gettimeofday(&now, NULL);
if(rc==0) {
printf("gettimeofday() successful.\n");
printf("time = %u.%06u\n",
now.tv_sec, now.tv_usec);
}
else {
printf("gettimeofday() failed, errno = %d\n",
errno);
return -1;
}
return 0;
}
$
I compiled the following and ran it on Ubuntu 13.10. Looks good.
$ test_time
gettimeofday() successful.
time = 1397440671.749296
$ strace test_time
execve("/home/mudd/musl/test_time", ["test_time"], [/* 32 vars */]) = 0
clock_gettime(CLOCK_REALTIME, {1397440676, 660111683}) = 0
ioctl(1, SNDCTL_TMR_TIMEBASE or TCGETS, {B38400 opost isig icanon echo
...}) = 0
writev(1, [{"gettimeofday() successful.", 26}, {"\n", 1}], 2gettimeofday()
successful.
) = 27
writev(1, [{"time = 1397440676.660111", 24}, {"\n", 1}], 2time =
1397440676.660111
) = 25
exit_group(0) = ?
$
Then I moved the executable to my old Linux and got this. Similar to what
happened with Postgres.
$ test_time
gettimeofday() successful.
time = 300.000000
$ 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
exit_group(0) = ?
$
John
[-- Attachment #2: Type: text/html, Size: 2837 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: gettimeofday
2014-04-14 2:03 gettimeofday John Mudd
@ 2014-04-14 10:16 ` Szabolcs Nagy
2014-04-15 2:53 ` gettimeofday John Mudd
1 sibling, 0 replies; 3+ messages in thread
From: Szabolcs Nagy @ 2014-04-14 10:16 UTC (permalink / raw)
To: musl
* 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;
}
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: gettimeofday
2014-04-14 2:03 gettimeofday John Mudd
2014-04-14 10:16 ` gettimeofday Szabolcs Nagy
@ 2014-04-15 2:53 ` John Mudd
1 sibling, 0 replies; 3+ messages in thread
From: John Mudd @ 2014-04-15 2:53 UTC (permalink / raw)
To: musl
[-- Attachment #1: Type: text/plain, Size: 1097 bytes --]
Thanks for the patch! I rebuilt the musl libc, copied the lib to my old
linux box and Postgres is running well now.
=======================
All 136 tests passed.
=======================
It's interesting that when I built Postgres on this same old Linux using
the native libc but it fails to run.
============== removing existing temp installation ==============
============== creating temporary installation ==============
============== initializing database system ==============
============== starting postmaster ==============
pg_regress: postmaster did not respond within 60 seconds
Building with musl on a modern Linux works on an old Linux. But building
Postgres on the old Linux with the native libc gives me a broken Postgres.
That's why I'm interested in musl libc.
On Sun, Apr 13, 2014 at 10:03 PM, John Mudd <johnbmudd@gmail.com> wrote:
> 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.
>
>
>
[-- Attachment #2: Type: text/html, Size: 1776 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2014-04-15 2:53 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-04-14 2:03 gettimeofday John Mudd
2014-04-14 10:16 ` gettimeofday Szabolcs Nagy
2014-04-15 2:53 ` gettimeofday John Mudd
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).