X-Recipient: archive-cygwin AT delorie DOT com DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:date:from:to:cc:subject:message-id:reply-to :references:mime-version:content-type:in-reply-to; q=dns; s= default; b=LqQLg5Pvir+sdhBdLptPtIi9lFLJCuQbn41nf7XZj3VT0Jk3rYWaG Ru27Wb4gKNAT558WTRWES3lHVwN/Wq03GWKj9g9q83MyP10OdLWoDRDUx2+Bdyjs IuQaDMP/DwtSnIn/pIsPJpsJGVcx/Co58bXlyHayISUlpqhJS6YzU4= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:date:from:to:cc:subject:message-id:reply-to :references:mime-version:content-type:in-reply-to; s=default; bh=LPTVvRT3pMOp+OkwOLNSgFMHm5M=; b=Vnbnd/Oh1qZwSly3lObQ46IRzR2V NTSYFqXPKKZj4Oty44HxIb1LZcg01LmZ2lRfAZKP7gtnb7CbiyeU/KjU6cH3DRTA INUKuGD42FGWCz0ZULfULQ5oDxexSDYsV4ClzI4IYB8VVZQceWCPRRngSG5NsLPF MNHOq/9CutH4zXE= Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Id: <cygwin.cygwin.com> List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com> List-Archive: <http://sourceware.org/ml/cygwin/> List-Post: <mailto:cygwin AT cygwin DOT com> List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs> Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=3.3.1 Date: Thu, 11 Apr 2013 22:46:05 +0200 From: Corinna Vinschen <corinna-cygwin AT cygwin DOT com> To: cygwin AT cygwin DOT com Cc: fortran AT gcc DOT gnu DOT org Subject: Re: Cygwin with clock_gettime and CLOCK_MONOTONIC - gives always 0 Message-ID: <20130411204605.GA11358@calimero.vinschen.de> Reply-To: cygwin AT cygwin DOT com, fortran AT gcc DOT gnu DOT org Mail-Followup-To: cygwin AT cygwin DOT com, fortran AT gcc DOT gnu DOT org References: <5166A0B3 DOT 70801 AT net-b DOT de> <5166BCA1 DOT 5040204 AT net-b DOT de> <20130411134835 DOT GD18333 AT calimero DOT vinschen DOT de> <51670B6B DOT 3000503 AT net-b DOT de> <20130411195200 DOT GJ18333 AT calimero DOT vinschen DOT de> <51671EAA DOT 8030901 AT net-b DOT de> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <51671EAA.8030901@net-b.de> User-Agent: Mutt/1.5.21 (2010-09-15) On Apr 11 22:35, Tobias Burnus wrote: > Corinna Vinschen wrote: > >On Apr 11 21:13, Tobias Burnus wrote: > >>Where is actually the source code of the clock_gettime, which Cygwin > >>uses? I thought that it was newlib. But looking at > >>http://sourceware.org/cgi-bin/cvsweb.cgi/src/newlib/libc/sys/linux/clock_gettime.c?cvsroot=src > >>the code should return -1 for "clock_gettime (CLOCK_MONOTONIC" as > >>CLOCK_MONOTONIC (= 4) is not handled, only CLOCK_REALTIME (= 1, > >>according to src/newlib/libc/include/time.h). > >> > >>However, as both you and Angelo get a zero return value, I must look > >>at the wrong file. > >Yes, for Cygwin it's > >http://cygwin.com/cgi-bin/cvsweb.cgi/src/winsup/cygwin/timer.cc?cvsroot=src > > Well, it's "times.cc" not "timer.cc". I think the problem with > Cygwin was a red herring. But there are a bunch of problems: > > > a) Angelo's code to initialize the random seed assumes that > Fortran's "system_clock" and the "clock_gettime(CLOCK_MONOTONIC" it > calls give a result where 0 is the beginning of the epoch (like on > Linux/glibc) or the system start up (as Windows' > GetTickCount/GetTickCount64). However, QueryPerformanceCounter > (probably intrinsically, but at least as used by Cygwin) returns > some time based on the startup time http://cygwin.com/ml/cygwin/2013-04/msg00191.html > - and as the frequency seems to > be slow such that the result is 0 or (nearly) the same number for > the startup. Thus, the random_seed initialization doesn't work as > expected on Cygwin/Windows. > > b) Newlib is broken. For clock_gettime, CLOCK_MONOTONIC is not > implemented. But both CLOCK_MONOTONIC and even > _POSIX_MONOTONIC_CLOCK (with value 200112L) are defined. No, newlib is right. Look again. In libc/include/time.h CLOCK_MONOTONIC is only defined if _POSIX_MONOTONIC_CLOCK is defined. In libc/include/sys/features.h, _POSIX_MONOTONIC_CLOCK is only defined for RTEMS and Cygwin. Corinna -- Corinna Vinschen Please, send mails regarding Cygwin to Cygwin Maintainer cygwin AT cygwin DOT com Red Hat -- Problem reports: http://cygwin.com/problems.html FAQ: http://cygwin.com/faq/ Documentation: http://cygwin.com/docs.html Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple