mailing list of musl libc
 help / color / mirror / code / Atom feed
* 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

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).