Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date: Sun, 13 Apr 2014 22:03:10 -0400
From: John Mudd <johnbmudd@...il.com>
To: musl <musl@...ts.openwall.com>
Subject: gettimeofday

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

Content of type "text/html" skipped

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.