From patchwork Wed Mar 27 08:52:06 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lukasz Majewski X-Patchwork-Id: 1066742 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-100907-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="inf53guG"; dkim-atps=neutral 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 44ThcH05Pqz9sSh for ; Wed, 27 Mar 2019 19:53:34 +1100 (AEDT) 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:in-reply-to :references; q=dns; s=default; b=e7+4J63jkqrLFwddFjvDiSdWWAuSswN WXKLASJtnMBPBySEhILQHqLnVNZ+e5vNVHnvEk84dkQhGl7P+5x+r6YdM6xJUNrL 30VB2oYH7jbuTS5Q5LDqXf9MbeCsxgmrAH4HMpEjoNzIYBp5x6H/jBmdaELx0Tpw M0SG0oypT1BU= 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:in-reply-to :references; s=default; bh=lLsq+PSsCrHFDN3WU+u7WXmOoOg=; b=inf53 guGgghtbpVI9Msd9XMI481we8jSkjF2C+A3Ii4ElRT8UoKtPNt3JPJZWnv0/MmL0 ZNa4EzgFRzOkHIaxEmzyx7bbNKTNPQSZhrwLvssnrOLM+bI7bbIA7lyDryQB6oj+ 7EDGVf0afk8A1ktGaoYvdFo5gwFn0lbvpOBimM= Received: (qmail 16815 invoked by alias); 27 Mar 2019 08:52:41 -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 16708 invoked by uid 89); 27 Mar 2019 08:52:40 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-18.4 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.1 spammy=__set_errno, east X-HELO: mail-out.m-online.net From: Lukasz Majewski To: libc-alpha@sourceware.org, Joseph Myers Cc: Paul Eggert , Zack Weinberg , Lukasz Majewski Subject: [RFC 3/7] y2038: clock_settime: Provide __clock_settime64 implementation for linux Date: Wed, 27 Mar 2019 09:52:06 +0100 Message-Id: <20190327085210.22019-4-lukma@denx.de> In-Reply-To: <20190327085210.22019-1-lukma@denx.de> References: <20190327085210.22019-1-lukma@denx.de> * include/time.h: Remove __clock_settime typeof * include/time.h: Add __clock_settime64 definition according to __TIMESIZE * sysdeps/unix/sysv/linux/clock_settime.c: Remove clock_settime alias * sysdeps/unix/sysv/linux/clock_settime.c: Add clock_settime when __TIMESIZE != 64 Rewrite __clock_settime() to __clock_settime64 with explicit support for 64 bit time --- include/time.h | 9 +++++++- sysdeps/unix/sysv/linux/clock_settime.c | 40 +++++++++++++++++++++++---------- 2 files changed, 36 insertions(+), 13 deletions(-) diff --git a/include/time.h b/include/time.h index 09231073b5..c8c0a6936e 100644 --- a/include/time.h +++ b/include/time.h @@ -22,7 +22,6 @@ libc_hidden_proto (strptime) extern __typeof (clock_getres) __clock_getres; extern __typeof (clock_gettime) __clock_gettime; libc_hidden_proto (__clock_gettime) -extern __typeof (clock_settime) __clock_settime; extern __typeof (clock_nanosleep) __clock_nanosleep; extern __typeof (clock_getcpuclockid) __clock_getcpuclockid; @@ -103,6 +102,14 @@ extern __time64_t __timegm64 (struct tm *__tp) __THROW; libc_hidden_proto (__timegm64) #endif +#if __TIMESIZE == 64 +# define __clock_settime64 clock_settime +#else +extern int __clock_settime64 (clockid_t clock_id, + const struct __timespec64 *tp); +libc_hidden_proto (__clock_settime64) +#endif + /* Compute the `struct tm' representation of T, offset OFFSET seconds east of UTC, and store year, yday, mon, mday, wday, hour, min, sec into *TP. diff --git a/sysdeps/unix/sysv/linux/clock_settime.c b/sysdeps/unix/sysv/linux/clock_settime.c index d837e3019c..5b7ab7fcb3 100644 --- a/sysdeps/unix/sysv/linux/clock_settime.c +++ b/sysdeps/unix/sysv/linux/clock_settime.c @@ -19,19 +19,35 @@ #include #include -#include "kernel-posix-cpu-timers.h" +int +__clock_settime64 (clockid_t clock_id, const struct __timespec64 *tp) +{ + /* Make sure the time cvalue is OK. */ + if (tp->tv_nsec < 0 || tp->tv_nsec >= 1000000000) + { + __set_errno (EINVAL); + return -1; + } + + return INLINE_SYSCALL_CALL (clock_settime, clock_id, tp); +} -/* Set CLOCK to value TP. */ +#if __TIMESIZE != 64 int -__clock_settime (clockid_t clock_id, const struct timespec *tp) +clock_settime (clockid_t clock_id, const struct timespec *tp) { - /* Make sure the time cvalue is OK. */ - if (tp->tv_nsec < 0 || tp->tv_nsec >= 1000000000) - { - __set_errno (EINVAL); - return -1; - } - - return INLINE_SYSCALL_CALL (clock_settime, clock_id, tp); + struct __timespec64 ts64; + + if (! in_time_t_range (tp->tv_sec)) + { + __set_errno (EOVERFLOW); + return -1; + } + + valid_timespec_to_timespec64 (tp, &ts64); + return __clock_settime64 (clock_id, &ts64); } -weak_alias (__clock_settime, clock_settime) + +/* The clock_settime symbol needs to be public as librt is also + using it */ +#endif