From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/4878 Path: news.gmane.org!not-for-mail From: John Mudd Newsgroups: gmane.linux.lib.musl.general Subject: gettimeofday Date: Sun, 13 Apr 2014 22:03:10 -0400 Message-ID: Reply-To: musl@lists.openwall.com NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=001a11c3474c037a8c04f6f71729 X-Trace: ger.gmane.org 1397441054 16553 80.91.229.3 (14 Apr 2014 02:04:14 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 14 Apr 2014 02:04:14 +0000 (UTC) To: musl Original-X-From: musl-return-4882-gllmg-musl=m.gmane.org@lists.openwall.com Mon Apr 14 04:04:07 2014 Return-path: Envelope-to: gllmg-musl@plane.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by plane.gmane.org with smtp (Exim 4.69) (envelope-from ) id 1WZWFj-0000Ue-7N for gllmg-musl@plane.gmane.org; Mon, 14 Apr 2014 04:04:07 +0200 Original-Received: (qmail 5172 invoked by uid 550); 14 Apr 2014 02:04:03 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Original-Received: (qmail 4032 invoked from network); 14 Apr 2014 02:03:41 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:from:date:message-id:subject:to:content-type; bh=NrRJi5tufiHOZmaDSZ7WACHsALg8hyBhiCiatoWb4a4=; b=btNQmGLYYgFZVWbcHxFgk/Lgt8XqXLoExyndSkGaBWmRusm7gRcCQZcKxVam5aMVGE z62UrC84A48o2BCIuSdupdOjmuUzI5hh6pcT6Ljl1r8N9W8ymJs/LY96T8OBP1LsXmF6 NrkhtjuIqTenel6f/lqIZJlg8TdBEylEyLyLra2nq9e4dK8bZCHjQZKc54XqoQ15zpfk gHoJc1V2YCmgVsTpZa50/CQMxVPpI9KAX96enUZ/Ub0yDysDERIj2aPICBEa7LtzilUY ergjndsDQBQ4t9dr1hSbRwZb2tzDnrAEPBHt4MivSV0SsEAq5ohcnYZaSmmXO0GwFWTt XM2g== X-Received: by 10.152.115.178 with SMTP id jp18mr27275951lab.23.1397441010300; Sun, 13 Apr 2014 19:03:30 -0700 (PDT) Xref: news.gmane.org gmane.linux.lib.musl.general:4878 Archived-At: --001a11c3474c037a8c04f6f71729 Content-Type: text/plain; charset=ISO-8859-1 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 #include #include 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 --001a11c3474c037a8c04f6f71729 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
I ran into trouble when I built Postgres using musl o= n a modern Linux and tried to run it on an old Linux. The problem seemed to= involve=A0gettimeofday() 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[])
{
=A0 =A0 s= truct timeval now;
=A0 =A0 int rc;

=A0 =A0 rc=3Dgettimeofday(&am= p;now, NULL);
=A0 =A0 if(rc=3D=3D0) {
=A0 =A0 =A0 =A0 p= rintf("gettimeofday() successful.\n");
=A0 =A0 =A0 =A0 = printf("time =3D %u.%06u\n",
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 now.tv_sec, now.tv_usec);
= =A0 =A0 }
=A0 =A0 else {
=A0 =A0 =A0 =A0 printf("g= ettimeofday() failed, errno =3D %d\n",
=A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0 errno);
=A0 =A0 =A0 =A0 return -1;
=A0 =A0 }

=A0 =A0 return 0;
}
=
$=A0

I compiled the following and ran it on U= buntu 13.10. Looks good.

$ test_time
gettimeofday() successful.
time =3D 1397440671.749296
$ strace test_time
exec= ve("/home/mudd/musl/test_time", ["test_time"], [/* 32 v= ars */]) =3D 0
clock_gettime(CLOCK_REALTIME, {1397440676, 6601116= 83}) =3D 0
ioctl(1, SNDCTL_TMR_TIMEBASE or TCGETS, {B38400 opost isig icanon echo= ...}) =3D 0
writev(1, [{"gettimeofday() successful.", = 26}, {"\n", 1}], 2gettimeofday() successful.
) =3D 27
writev(1, [{"time =3D 1397440676.660111", 24}, {"\n&quo= t;, 1}], 2time =3D 1397440676.660111
) =3D 25
exit_grou= p(0) =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =3D ?
$= =A0


Then I moved the executable to my old Linux and got this. Si= milar to what happened with Postgres.=A0

$ te= st_time
gettimeofday() successful.
time =3D 300.000000<= /div>
$ strace test_time
execve("/home/jmudd/musl/test_time&q= uot;, ["test_time"], [/* 27 vars */]) =3D 0
clock_getti= me(0, 0xbfffae48) =A0 =A0 =A0 =A0 =A0 =A0=3D -1 ENOSYS (Function not implem= ented)
gettimeofday(NULL, {300, 0}) =A0 =A0 =A0 =A0 =A0 =A0=3D 0
io= ctl(1, TCGETS, {B38400 opost isig icanon echo ...}) =3D 0
writev(= 1, [{"gettimeofday() successful.", 26}, {"\n", 1}], 2ge= ttimeofday() successful.
) =3D 27
writev(1, [{"time =3D 300.000000", 17}, {= "\n", 1}], 2time =3D 300.000000
) =3D 18
exit= _group(0) =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =3D ?
$=A0

John
--001a11c3474c037a8c04f6f71729--