From patchwork Thu Jul 2 04:07:46 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shawn Landden X-Patchwork-Id: 490415 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]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 8177D14076E for ; Thu, 2 Jul 2015 14:08:10 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=sourceware.org header.i=@sourceware.org header.b=x3FRXmJo; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id; q=dns; s= default; b=vD9dLOc0GQAtuwEQOJt8lcQ5Ahtj+1cHhOVodA7Lp0ZTSHZMsNeFD 6x6+X3t79w61jZMC6rfjedqjtn7PNh2Q34gx/9qsD3R2mibSNt5Oe9zbF2/7GFcj q+L0lLfuEsfF3Msuft/PxtcnrOjGDu+mNS5TgrTHqC1xO8emUcipV0= 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:from:to:cc:subject:date:message-id; s=default; bh=Ba14DEohwW/qdy6gcpME2bRJNPY=; b=x3FRXmJo2rqiEUC5v+mpB/hKsOdx wTaVXFTPF4n8QyOBNq+YX+nmmUrUe+NtTauzWU0LFwVbxJzu6TBXUUj1LWtIjzFn zjM6k9STTRbJQX9TKENFjNG+F5CbQgqZwsJ/j9UgD32FymjckpzXTDgqSyzXxoJ3 B3uriOAV3WeDP6E= Received: (qmail 82776 invoked by alias); 2 Jul 2015 04:08:05 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 82767 invoked by uid 89); 2 Jul 2015 04:08:04 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=2.0 required=5.0 tests=AWL, BAYES_50, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-pa0-f52.google.com X-Received: by 10.66.66.202 with SMTP id h10mr61509216pat.145.1435810081986; Wed, 01 Jul 2015 21:08:01 -0700 (PDT) From: Shawn Landden To: libc-alpha@sourceware.org Cc: Shawn Landden Subject: [PATCH] time/time.h: CLOCK_EARTH Date: Wed, 1 Jul 2015 21:07:46 -0700 Message-Id: <1435810066-106004-1-git-send-email-shawn@churchofgit.com> If leap seconds are abolished for leap hours, as has been repeately proposed, and clocks remain in UTC, then the fact that the day is slightly shorter than 86400 seconds will slowly accumulate. Over time this will make UTC undesirable for astronomical applications, such as sun-rise, sun-set, and solar noon. Introduce CLOCK_EARTH, that for now is CLOCK_REALTIME, but may in the future become UT1 (mean solar time at zero degrees longitute), so that these applications can mark their need for an astronomical time, rather than "wall time". This will allow these applications to supported in a forward-compatible manner, regardless of changes in the definition of time. If leap seconds are abolished a correct implementation of CLOCK_TAI could also be provided, and perhaps a CLOCK_LORANC and CLOCK_GPS. * timezone/leapseconds: Update history. * sysdeps/unix/sysv/linux/bits/time.h: add CLOCK_EARTH. * sysdeps/unix/clock_gettime.c: make CLOCK_EARTH identical to CLOCK_REALTIME. --- sysdeps/unix/clock_gettime.c | 6 ++++++ sysdeps/unix/sysv/linux/bits/time.h | 8 ++++++-- timezone/leapseconds | 2 ++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/sysdeps/unix/clock_gettime.c b/sysdeps/unix/clock_gettime.c index 2975368..ddc4058 100644 --- a/sysdeps/unix/clock_gettime.c +++ b/sysdeps/unix/clock_gettime.c @@ -93,6 +93,12 @@ __clock_gettime (clockid_t clock_id, struct timespec *tp) { int retval = -1; + /* UTC is currently tied to Earth time through use of leap seconds. If this + changes in the future we can provide an implementation of UT1 in a forward + compatible way. */ + if (clock_id == CLOCK_EARTH) + clock_id = CLOCK_REALTIME; + switch (clock_id) { #ifdef SYSDEP_GETTIME diff --git a/sysdeps/unix/sysv/linux/bits/time.h b/sysdeps/unix/sysv/linux/bits/time.h index 706946c..4b1094d 100644 --- a/sysdeps/unix/sysv/linux/bits/time.h +++ b/sysdeps/unix/sysv/linux/bits/time.h @@ -77,9 +77,13 @@ extern long int __sysconf (int); # define CLOCK_REALTIME_ALARM 8 /* Like CLOCK_BOOTTIME but also wakes suspended system. */ # define CLOCK_BOOTTIME_ALARM 9 -/* Like CLOCK_REALTIME but in International Atomic Time. */ +/* Like CLOCK_REALTIME but in International Atomic Time. + * GPS + 19 = TAI + * Loran-C + 28 = TAI + */ # define CLOCK_TAI 11 - +/* Like CLOCK_REALTIME but always mean solar time of zero degrees long (maybe UT1). */ +# define CLOCK_EARTH 12 /* Flag to indicate time is absolute. */ # define TIMER_ABSTIME 1 # endif diff --git a/timezone/leapseconds b/timezone/leapseconds index d6343c0..717a792 100644 --- a/timezone/leapseconds +++ b/timezone/leapseconds @@ -48,6 +48,8 @@ Leap 1997 Jun 30 23:59:60 + S Leap 1998 Dec 31 23:59:60 + S Leap 2005 Dec 31 23:59:60 + S Leap 2008 Dec 31 23:59:60 + S +Leap 2012 Jun 30 23:59:60 + S +Leap 2015 Jun 30 23:59:60 + S # INTERNATIONAL EARTH ROTATION AND REFERENCE SYSTEMS SERVICE (IERS) #