From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/4879 Path: news.gmane.org!not-for-mail From: Szabolcs Nagy Newsgroups: gmane.linux.lib.musl.general Subject: Re: gettimeofday Date: Mon, 14 Apr 2014 12:16:15 +0200 Message-ID: <20140414101615.GY3034@port70.net> References: Reply-To: musl@lists.openwall.com NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1397470597 24183 80.91.229.3 (14 Apr 2014 10:16:37 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 14 Apr 2014 10:16:37 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-4883-gllmg-musl=m.gmane.org@lists.openwall.com Mon Apr 14 12:16:30 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 1WZdwD-0007Ll-Ls for gllmg-musl@plane.gmane.org; Mon, 14 Apr 2014 12:16:29 +0200 Original-Received: (qmail 19829 invoked by uid 550); 14 Apr 2014 10:16:27 -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 19821 invoked from network); 14 Apr 2014 10:16:27 -0000 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) Xref: news.gmane.org gmane.linux.lib.musl.general:4879 Archived-At: * John Mudd [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; }