mailing list of musl libc
 help / color / mirror / code / Atom feed
From: John Mudd <johnbmudd@gmail.com>
To: musl <musl@lists.openwall.com>
Subject: gettimeofday
Date: Sun, 13 Apr 2014 22:03:10 -0400	[thread overview]
Message-ID: <CAGDMk9GmZBgQZtxhG4OSqH3gzMt=pjRVnbmXTSdHRFMnfvXo=A@mail.gmail.com> (raw)

[-- 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 --]

             reply	other threads:[~2014-04-14  2:03 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-04-14  2:03 John Mudd [this message]
2014-04-14 10:16 ` gettimeofday Szabolcs Nagy
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='CAGDMk9GmZBgQZtxhG4OSqH3gzMt=pjRVnbmXTSdHRFMnfvXo=A@mail.gmail.com' \
    --to=johnbmudd@gmail.com \
    --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).