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:message-id:date:from:mime-version:to:subject :references:in-reply-to:content-type:content-transfer-encoding; q=dns; s=default; b=taR6n97BsU44lGa0zG7tTaapF/KTSslzBLCLiTpXQ+C U7Gz9wvA6byHPUSmt+dxHTIT/5G4HIqCcR5J1Lc0Y5GIb1dKDcUaQN3TzIjVGm0Z uUzRgCG9ig2cShzbTCSvbx+bJVyKg3yT7kZX9bwcplnW4QkwKSixk8QPIqGDCVE0 = 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:message-id:date:from:mime-version:to:subject :references:in-reply-to:content-type:content-transfer-encoding; s=default; bh=+6H/2Nm8Jt3/lUrhJUMqOLJDEcw=; b=JfCFsc+DyTlN5Z+R3 tzowTAMSRkD+P9annwa+ncuKs828j28YReMlCmaK5hU4iac/Gmb78d6ZoQhnt3Cz rEBicPebD0fzJDSmN3LME5nOmZYYKXo0OnGqDjDAhulRua1o3scncFRMvHjwFvNL hkP7p0rZI0x/eSKVhJW9Oq4q/4= Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , 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=-3.0 required=5.0 tests=AWL,BAYES_00,KHOP_THREADED,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Message-ID: <516725CC.9070808@net-b.de> Date: Thu, 11 Apr 2013 23:06:20 +0200 From: Tobias Burnus User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130329 Thunderbird/17.0.5 MIME-Version: 1.0 To: cygwin AT cygwin DOT com, fortran AT gcc DOT gnu DOT org Subject: Re: Cygwin with clock_gettime and CLOCK_MONOTONIC - gives always 0 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> In-Reply-To: <51671EAA.8030901@net-b.de> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Tobias Burnus: > 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. However, POSIX states: "If the > Monotonic Clock option is supported, all implementations shall support > a clock_id of CLOCK_MONOTONIC defined in ." Sorry, I read this backward. CLOCK_MONOTONIC has to be in time.h according to POSIX [1]. However, whether the monotonic-clock option is supported, is given by _POSIX_MONOTONIC_CLOCK of unistd.h. POSIX states [2]: - "If a symbolic constant is defined with the value -1, the option is not supported." - "If a symbolic constant is defined with the value zero, all headers, data types, and functions shall be present. The application can check at runtime to see whether the option is supported." - "If a symbolic constant is defined with a value greater than zero, the option shall always be supported when the application is executed." Just looking at newlib, the value should be "-1"; but a value of "0" is probably fine as well. For Cygwin it could also be > 0. ... As Corinna has written as follow up, the latter is actually the case: Only RTEMS and Cygwin define it (with value > 0). Regarding the zero value, the patch she mentions is: "times.cc (hires_ns::nsecs): Take bool parameter. If set to true, don't use prime value (== return system wide absolute value).", http://cygwin.com/cgi-bin/cvsweb.cgi/src/winsup/cygwin/times.cc.diff?r1=1.117&r2=1.118&cvsroot=src&f=h Thanks for the patch! For libgfortran, as action item one should at least check whether _POSIX_MONOTONIC_CLOCK is defined as >= 0 before assuming that monotonic clocks work. (With 0 (as with glibc/Linux) or with when not defined, it might be still available but according to POSIX that's only checkable via |sysconf(_SC_MONOTONIC_CLOCK|) at runtime.) Tobias [1] http://pubs.opengroup.org/onlinepubs/009695399/basedefs/time.h.html [2] http://pubs.opengroup.org/onlinepubs/009695399/basedefs/unistd.h.html -- 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