From patchwork Sun Oct 21 14:00:20 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sam Varshavchik X-Patchwork-Id: 192996 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id 443CD2C008D for ; Mon, 22 Oct 2012 01:00:31 +1100 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1351432832; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Message-ID:From:To:Subject:Date:Mime-Version:Content-Type: Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:Sender:Delivered-To; bh=lhVIAHVu3HGjo9FHYehu wsnYS8A=; b=BJUG1OEXdD3XPkMEtbdn73vlK9Tf8eppS7ZJBiSQW6R/soCllFh4 2Xj95h5ePA3S053zvqJM79rpp/BvHz74KkoBHlPfSpFpnbG5GM3FUGo1qg63/9Bb ZSsemgvGsKxLelvMhhlI/qs7AmbrOnFko8zbGEqW2zt4mQnw3nD1Umg= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:Received:Message-ID:From:To:Subject:Date:Mime-Version:Content-Type:X-IsSubscribed:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=KfSXX0P7zf5jqSB/u8xZIe1h7JOCLNl7gvOLxt9bmn+bQj95Up13KLf1Gj5/5v FCFMXVrw0MVQVRBgmZWr3Nwhvlqv9GbkQafQ07YXQCXL+xHty+fARcDfbR4uT4NJ emzY2+/jN38fG+Vwbq7V0O50IcvLOhZXVThJAn6Ik5e9I=; Received: (qmail 27861 invoked by alias); 21 Oct 2012 14:00:26 -0000 Received: (qmail 27853 invoked by uid 22791); 21 Oct 2012 14:00:25 -0000 X-SWARE-Spam-Status: No, hits=-5.0 required=5.0 tests=AWL, BAYES_00, KHOP_PGP_SIGNED, RP_MATCHES_RCVD, SARE_SUB_ENC_UTF8 X-Spam-Check-By: sourceware.org Received: from www.courier-mta.com (HELO www.courier-mta.com) (216.254.115.190) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sun, 21 Oct 2012 14:00:21 +0000 Received: from monster.email-scan.com (monster.email-scan.com [::ffff:192.168.0.2]) (TLS: TLSv1/SSLv3,256bits,AES256-SHA) by www.courier-mta.com with ESMTPS; Sun, 21 Oct 2012 10:00:20 -0400 id 000000000006008D.000000005083FFF4.00004608 Received: from monster.email-scan.com (localhost [127.0.0.1]) (IDENT: uid 1000) by monster.email-scan.com with ESMTP; Sun, 21 Oct 2012 10:00:20 -0400 id 000000000003E321.000000005083FFF4.000078BB Message-ID: From: Sam Varshavchik To: gcc-patches@gcc.gnu.org Subject: [PATCH] A steadier =?UTF-8?Q?steady=5Fclock?= Date: Sun, 21 Oct 2012 10:00:20 -0400 Mime-Version: 1.0 X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Based on a casual browsing of clock_gettime(3), CLOCK_MONOTONIC_RAW seems to be a better fit for std::chrono::steady_clock's requirements as given in 20.11.7.2, with recent Linux kernels, Something like this: Index: libstdc++-v3/src/c++11/chrono.cc =================================================================== --- libstdc++-v3/src/c++11/chrono.cc (revision 192652) +++ libstdc++-v3/src/c++11/chrono.cc (working copy) @@ -70,7 +70,11 @@ { timespec tp; // -EINVAL, -EFAULT +#ifdef CLOCK_MONOTONIC_RAW + clock_gettime(CLOCK_MONOTONIC_RAW, &tp); +#else clock_gettime(CLOCK_MONOTONIC, &tp); +#endif return time_point(duration(chrono::seconds(tp.tv_sec) + chrono::nanoseconds(tp.tv_nsec))); }