From patchwork Fri Oct 25 12:08:22 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 177733 Delivered-To: patch@linaro.org Received: by 2002:a92:409a:0:0:0:0:0 with SMTP id d26csp3601774ill; Fri, 25 Oct 2019 05:09:18 -0700 (PDT) X-Google-Smtp-Source: APXvYqzvm0pD8t0PtYlBXkJH8QmnA5KnIezgOFPn0IRxOhmx0vfPQf5owr4eOwGAgdNExA6ixiZv X-Received: by 2002:a50:9fc1:: with SMTP id c59mr3551695edf.305.1572005358579; Fri, 25 Oct 2019 05:09:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572005358; cv=none; d=google.com; s=arc-20160816; b=xwXhuyXFQEzX7xyvBA+y3aSbBYFWvNzcK5ngowf1MHej5DfWVENuvYwQ1a4s/xcZoh BNTzMQRriYF3EWg0ghJv4UNbtA/l7E/pxjJYidq960jPhbPZT8re0ncEXV0Fot7Ec2/b XTsuOQwd7gbmHOO0Jmb2g6g3l2UyPt2deKG+iAnpwmzh/xyKBxKcYnlTs+i9o4ejXQmW 621/igB4vs2cVOV5soqCQPymY++QyD1cT8Zqfc8KclOoTnPItcJawHXaP8JmnJ/LdEVL yaObKG919zK+iaTzh6ZD4lwDlN54GiKd8ZUFxwr82d7D1/5wXq14neU6eAlgxOMdDaP+ xJYQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:delivered-to:sender:list-help:list-post:list-archive :list-subscribe:list-unsubscribe:list-id:precedence:mailing-list :dkim-signature:domainkey-signature; bh=XH8S8pd5Ix6M2iMMi0dcWAvwGeswgLqQfpyzn4Avce8=; b=OQ1Y2nLNUGGUOCtDT3z9RNBXYL7vHX4smbzKs+/wiB43SkjeuyuOGtQJqCxwMzEq8E nRyVRXWzINFc4HyFzlsJWa1rbAPUHD08gX65Vxbjr06GT+tAQ5agBL+cO86y8IYsvfI+ 3K8ig3SgEGTDa3Yf6x4T8d6QdhhSzassqH7pvZqOZAQ3QevY90nutGwF1H4v/DOKAQ35 eNrnF+jwB77zV/isTL9W0f2SZFijW8W315pyrL7Q9myMon8EsXzyqUnwK/L87L7wcNB/ 1toGvbzDMzD1hTwtVyv/LX3ufArwfN1Mqj/JY517KBeTOonbRPiK7RaXj6qO1HH3t9tD UAkw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=fz1neIoc; dkim=pass header.i=@linaro.org header.s=google header.b=TA7s1zBq; spf=pass (google.com: domain of libc-alpha-return-106283-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="libc-alpha-return-106283-patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id a11si1146209eju.31.2019.10.25.05.09.17 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 25 Oct 2019 05:09:18 -0700 (PDT) Received-SPF: pass (google.com: domain of libc-alpha-return-106283-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=fz1neIoc; dkim=pass header.i=@linaro.org header.s=google header.b=TA7s1zBq; spf=pass (google.com: domain of libc-alpha-return-106283-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="libc-alpha-return-106283-patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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=Yz0CPgOaCzkQjve99gaSTN7c392b3HT O3GcrPA5JlI2KsOniTFYzAIhJ7HMzJJSZ8vjRgw2W1quU+K4R76uk0R7adwCZh6a D/FpEHhl+AxwF/rOpVAYG/xGtiYWjHqO6xiJ2qahuIO2ODBYOINnIj1XMPnyJRVJ c6Hz+ja0Nea8= 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=pSyptNaZDVgUJKPihNGX1n85rH4=; b=fz1ne IocXHVMFBXbmFs5MYCjvCTk3O1aHDDlcjzDWiebrl9Wxs4s1ULyTrQ6gVuLjL9YL PHHyvx1reEm4KIs1JLTenGN/kkgBzu0FXjhe5a9oJ5XyQ5vP60uYxamdCxCty7V/ K9FDaG1x77K+qYenLBTwlGzpXB/ESyu8RRhrPY= Received: (qmail 77179 invoked by alias); 25 Oct 2019 12:08:53 -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 77059 invoked by uid 89); 25 Oct 2019 12:08:52 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-21.4 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy=resident, accomplish, pll, D*1 X-HELO: mail-qk1-f194.google.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=XH8S8pd5Ix6M2iMMi0dcWAvwGeswgLqQfpyzn4Avce8=; b=TA7s1zBqRIFdbkjep4trG3FmV6Nr9EB1Zv0agEFYfjU+re/v01l9BM/Xagk1+MjVhc zaCge9ejCNOSDOYsSrPuj/3He7McrGlunm2c+RrRz42aDka7cGFe+NNwMDHD+gUmkr4K 4GfGoF4Q0zmhqaJ7CAYD7SZ/t+KGMqJbZxHWIbWsOyh67Zin6iOiZZ0jCUzTKPieKvoN /dAIfoA+PWMoErkSaSEexGDiO6YiwwyIYh8cT/6le+PkzU/FRKj7pm25I9JSA878iIHI MF7Lig0o72fqrSdynTIB2rChvIOMgGjXHxaNL+9k6K9EFE4SWujHgIooToKgbVm1v/jz 68OA== Return-Path: From: Adhemerval Zanella To: libc-alpha@sourceware.org Cc: Lukasz Majewski , Zack Weinberg Subject: [PATCH v2 01/11] Linux/Alpha: don't use timeval32 system calls. Date: Fri, 25 Oct 2019 09:08:22 -0300 Message-Id: <20191025120832.27667-2-adhemerval.zanella@linaro.org> In-Reply-To: <20191025120832.27667-1-adhemerval.zanella@linaro.org> References: <20191025120832.27667-1-adhemerval.zanella@linaro.org> From: Zack Weinberg Changes from previous version: - Add check usage32 check on __wait4_tv32. - Change capitalized functions to lowercase. -- Linux/Alpha has two versions of several system call wrappers that take or return data of type "struct timeval" (possibly nested inside a larger structure). The GLIBC_2.0 version is a compat symbol that calls __NR_osf_foo or __NR_old_foo and uses a struct timeval with a 32-bit tv_sec field. The GLIBC_2.1 version is used for current code, calls __NR_foo, and uses a struct timeval with a 64-bit tv_sec field. This patch changes all of the compat symbols of this type to be wrappers around their GLIBC_2.1 counterparts; the compatibility system calls will no longer be used. It serves as a proposal for part of how we do the transition to 64-bit time_t on systems that currently use 32-bit time_t: * The patched glibc will NOT use system calls that involve 32-bit time_t to implement its compatibility symbols. This will make both our lives and the kernel maintainers' lives easier. The primary argument I've seen against it is that the kernel could warn about uses of the old system calls, helping people find old binaries that need to be recompiled. I think there are several other ways we could accomplish this, e.g. scripts to scan the filesystem for binaries with references to the old symbol versions, or issuing diagnostics ourselves. * The compat symbols do NOT report failure after the Y2038 deadline. An earlier revision of this patch had them return -1 and set errno to EOVERFLOW, but Adhemerval pointed out that many of them have already performed side effects at the point where we discover the overflow, so that would break more than it fixes. Also, we don't want people to be _checking_ for EOVERFLOW from these functions; we want them to recompile with 64-bit time_t. So it's not actually useful for them to report failure to the calling code. * What they do do, when they encounter overflow, is saturate the overflowed "struct timeval"(s): tv_sec is set to INT32_MAX and tv_nsec is set to 999999. That means time stops advancing for programs with 32-bit time_t when they reach the deadline. That's obviously going to break stuff, but I think wrapping around is probably going to break _more_ stuff. I'd be interested to hear arguments against, if anyone has one. The new header file tv32-compat.h is currently Alpha-specific but I mean for it to be reused to aid in writing wrappers for all affected architectures. I only put it in sysdeps/unix/sysv/linux/alpha for now because I haven't checked whether the various "foo32" structures it defines agree with the ABI for ports other than Linux/Alpha. Reviewed-by: Adhemerval Zanella --- sysdeps/unix/sysv/linux/Makefile | 2 +- sysdeps/unix/sysv/linux/adjtime.c | 40 ++--- sysdeps/unix/sysv/linux/adjtimex.c | 40 +++++ sysdeps/unix/sysv/linux/alpha/Makefile | 2 +- sysdeps/unix/sysv/linux/alpha/adjtime.c | 82 +--------- sysdeps/unix/sysv/linux/alpha/adjtimex.c | 22 +++ sysdeps/unix/sysv/linux/alpha/osf_adjtime.c | 130 ++++++++++++++++ sysdeps/unix/sysv/linux/alpha/osf_getitimer.c | 41 +++++ sysdeps/unix/sysv/linux/alpha/osf_getrusage.c | 39 +++++ .../unix/sysv/linux/alpha/osf_gettimeofday.c | 43 ++++++ sysdeps/unix/sysv/linux/alpha/osf_setitimer.c | 49 ++++++ .../unix/sysv/linux/alpha/osf_settimeofday.c | 41 +++++ sysdeps/unix/sysv/linux/alpha/osf_utimes.c | 37 +++++ sysdeps/unix/sysv/linux/alpha/osf_wait4.c | 41 +++++ sysdeps/unix/sysv/linux/alpha/syscalls.list | 27 ++-- sysdeps/unix/sysv/linux/alpha/tv32-compat.h | 146 ++++++++++++++++++ sysdeps/unix/sysv/linux/gettimeofday.c | 14 +- sysdeps/unix/sysv/linux/syscalls.list | 1 - 18 files changed, 666 insertions(+), 131 deletions(-) create mode 100644 sysdeps/unix/sysv/linux/adjtimex.c create mode 100644 sysdeps/unix/sysv/linux/alpha/adjtimex.c create mode 100644 sysdeps/unix/sysv/linux/alpha/osf_adjtime.c create mode 100644 sysdeps/unix/sysv/linux/alpha/osf_getitimer.c create mode 100644 sysdeps/unix/sysv/linux/alpha/osf_getrusage.c create mode 100644 sysdeps/unix/sysv/linux/alpha/osf_gettimeofday.c create mode 100644 sysdeps/unix/sysv/linux/alpha/osf_setitimer.c create mode 100644 sysdeps/unix/sysv/linux/alpha/osf_settimeofday.c create mode 100644 sysdeps/unix/sysv/linux/alpha/osf_utimes.c create mode 100644 sysdeps/unix/sysv/linux/alpha/osf_wait4.c create mode 100644 sysdeps/unix/sysv/linux/alpha/tv32-compat.h -- 2.17.1 diff --git a/sysdeps/unix/sysv/linux/Makefile b/sysdeps/unix/sysv/linux/Makefile index bbab8f8cc3..a7623fb390 100644 --- a/sysdeps/unix/sysv/linux/Makefile +++ b/sysdeps/unix/sysv/linux/Makefile @@ -14,7 +14,7 @@ endif ifeq ($(subdir),misc) include $(firstword $(wildcard $(sysdirs:=/sysctl.mk))) -sysdep_routines += clone umount umount2 readahead \ +sysdep_routines += adjtimex clone umount umount2 readahead \ setfsuid setfsgid epoll_pwait signalfd \ eventfd eventfd_read eventfd_write prlimit \ personality epoll_wait tee vmsplice splice \ diff --git a/sysdeps/unix/sysv/linux/adjtime.c b/sysdeps/unix/sysv/linux/adjtime.c index 6d1e129ccc..6b8021caa3 100644 --- a/sysdeps/unix/sysv/linux/adjtime.c +++ b/sysdeps/unix/sysv/linux/adjtime.c @@ -23,39 +23,14 @@ #define MAX_SEC (INT_MAX / 1000000L - 2) #define MIN_SEC (INT_MIN / 1000000L + 2) -#ifndef MOD_OFFSET -#define modes mode -#endif - -#ifndef TIMEVAL -#define TIMEVAL timeval -#endif - -#ifndef TIMEX -#define TIMEX timex -#endif - -#ifndef ADJTIME -#define ADJTIME __adjtime -#endif - -#ifndef ADJTIMEX -#define NO_LOCAL_ADJTIME -#define ADJTIMEX(x) __adjtimex (x) -#endif - -#ifndef LINKAGE -#define LINKAGE -#endif - -LINKAGE int -ADJTIME (const struct TIMEVAL *itv, struct TIMEVAL *otv) +int +__adjtime (const struct timeval *itv, struct timeval *otv) { - struct TIMEX tntx; + struct timex tntx; if (itv) { - struct TIMEVAL tmp; + struct timeval tmp; /* We will do some check here. */ tmp.tv_sec = itv->tv_sec + itv->tv_usec / 1000000L; @@ -68,7 +43,7 @@ ADJTIME (const struct TIMEVAL *itv, struct TIMEVAL *otv) else tntx.modes = ADJ_OFFSET_SS_READ; - if (__glibc_unlikely (ADJTIMEX (&tntx) < 0)) + if (__glibc_unlikely (__adjtimex (&tntx) < 0)) return -1; if (otv) @@ -87,6 +62,9 @@ ADJTIME (const struct TIMEVAL *itv, struct TIMEVAL *otv) return 0; } -#ifdef NO_LOCAL_ADJTIME +#ifdef VERSION_adjtime +weak_alias (__adjtime, __wadjtime); +default_symbol_version (__wadjtime, adjtime, VERSION_adjtime); +#else weak_alias (__adjtime, adjtime) #endif diff --git a/sysdeps/unix/sysv/linux/adjtimex.c b/sysdeps/unix/sysv/linux/adjtimex.c new file mode 100644 index 0000000000..6d62c72a17 --- /dev/null +++ b/sysdeps/unix/sysv/linux/adjtimex.c @@ -0,0 +1,40 @@ +/* Tune kernel clock. Linux specific syscall. + Copyright (C) 2019 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include +#include + +int +___adjtimex (struct timex *buf) +{ + return INLINE_SYSCALL_CALL (adjtimex, buf); +} + +#ifdef VERSION_adjtimex +weak_alias (___adjtimex, __wadjtimex); +weak_alias (___adjtimex, __wnadjtime); +default_symbol_version (___adjtimex, __adjtimex, VERSION_adjtimex); +default_symbol_version (__wadjtimex, adjtimex, VERSION_adjtimex); +default_symbol_version (__wnadjtime, ntp_adjtime, VERSION_adjtimex); +libc_hidden_ver (___adjtimex, __adjtimex); +#else +strong_alias (___adjtimex, __adjtimex) +weak_alias (___adjtimex, adjtimex) +weak_alias (___adjtimex, ntp_adjtime) +libc_hidden_def (__adjtimex) +#endif diff --git a/sysdeps/unix/sysv/linux/alpha/Makefile b/sysdeps/unix/sysv/linux/alpha/Makefile index fdd089af71..2e132e474b 100644 --- a/sysdeps/unix/sysv/linux/alpha/Makefile +++ b/sysdeps/unix/sysv/linux/alpha/Makefile @@ -9,7 +9,7 @@ sysdep_routines += ieee_get_fp_control ieee_set_fp_control \ ioperm # Support old timeval32 entry points -sysdep_routines += osf_gettimeofday osf_settimeofday \ +sysdep_routines += osf_adjtime osf_gettimeofday osf_settimeofday \ osf_getitimer osf_setitimer osf_utimes \ osf_getrusage osf_wait4 diff --git a/sysdeps/unix/sysv/linux/alpha/adjtime.c b/sysdeps/unix/sysv/linux/alpha/adjtime.c index 4aede1cc40..9cb058ee55 100644 --- a/sysdeps/unix/sysv/linux/alpha/adjtime.c +++ b/sysdeps/unix/sysv/linux/alpha/adjtime.c @@ -1,4 +1,5 @@ -/* Copyright (C) 1998-2019 Free Software Foundation, Inc. +/* adjtime -- Adjust the current time of day. Linux/Alpha/tv64 version. + Copyright (C) 2019 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -15,80 +16,7 @@ License along with the GNU C Library. If not, see . */ -#include -#include -#include - - -#if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_1) -struct timeval32 -{ - int tv_sec, tv_usec; -}; - -struct timex32 { - unsigned int modes; /* mode selector */ - long offset; /* time offset (usec) */ - long freq; /* frequency offset (scaled ppm) */ - long maxerror; /* maximum error (usec) */ - long esterror; /* estimated error (usec) */ - int status; /* clock command/status */ - long constant; /* pll time constant */ - long precision; /* clock precision (usec) (read only) */ - long tolerance; /* clock frequency tolerance (ppm) - * (read only) - */ - struct timeval32 time; /* (read only) */ - long tick; /* (modified) usecs between clock ticks */ - - long ppsfreq; /* pps frequency (scaled ppm) (ro) */ - long jitter; /* pps jitter (us) (ro) */ - int shift; /* interval duration (s) (shift) (ro) */ - long stabil; /* pps stability (scaled ppm) (ro) */ - long jitcnt; /* jitter limit exceeded (ro) */ - long calcnt; /* calibration intervals (ro) */ - long errcnt; /* calibration errors (ro) */ - long stbcnt; /* stability limit exceeded (ro) */ - - int :32; int :32; int :32; int :32; - int :32; int :32; int :32; int :32; - int :32; int :32; int :32; int :32; -}; - -#define TIMEVAL timeval32 -#define TIMEX timex32 -#define ADJTIME attribute_compat_text_section __adjtime_tv32 -#define ADJTIMEX(x) INLINE_SYSCALL (old_adjtimex, 1, x) -#define ADJTIMEX32(x) INLINE_SYSCALL (old_adjtimex, 1, x) - +/* We can use the generic Linux implementation, but we have to override its + default symbol version. */ +#define VERSION_adjtime GLIBC_2.1 #include - -int attribute_compat_text_section -__adjtimex_tv32 (struct timex32 *tx) { return ADJTIMEX (tx); } - -strong_alias (__adjtimex_tv32, __adjtimex_tv32_1); -strong_alias (__adjtimex_tv32, __adjtimex_tv32_2); -compat_symbol (libc, __adjtimex_tv32_1, __adjtimex, GLIBC_2_0); -compat_symbol (libc, __adjtimex_tv32_2, adjtimex, GLIBC_2_0); -compat_symbol (libc, __adjtime_tv32, adjtime, GLIBC_2_0); -#endif /* SHLIB_COMPAT */ - -#undef TIMEVAL -#undef TIMEX -#undef ADJTIME -#undef ADJTIMEX -#define TIMEVAL timeval -#define TIMEX timex -#define ADJTIMEX(x) INLINE_SYSCALL (adjtimex, 1, x) - -#include - -int -__adjtimex_tv64 (struct timex *tx) { return ADJTIMEX (tx); } - -libc_hidden_ver (__adjtimex_tv64, __adjtimex) -strong_alias (__adjtimex_tv64, __adjtimex_tv64p); -weak_alias (__adjtimex_tv64, ntp_adjtime); -versioned_symbol (libc, __adjtimex_tv64, __adjtimex, GLIBC_2_1); -versioned_symbol (libc, __adjtimex_tv64p, adjtimex, GLIBC_2_1); -versioned_symbol (libc, __adjtime, adjtime, GLIBC_2_1); diff --git a/sysdeps/unix/sysv/linux/alpha/adjtimex.c b/sysdeps/unix/sysv/linux/alpha/adjtimex.c new file mode 100644 index 0000000000..1a8e0a9529 --- /dev/null +++ b/sysdeps/unix/sysv/linux/alpha/adjtimex.c @@ -0,0 +1,22 @@ +/* adjtimex -- Adjust the current time of day. Linux/Alpha/tv64 version. + Copyright (C) 2019 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +/* We can use the generic Linux implementation, but we have to override its + default symbol version. */ +#define VERSION_adjtimex GLIBC_2.1 +#include diff --git a/sysdeps/unix/sysv/linux/alpha/osf_adjtime.c b/sysdeps/unix/sysv/linux/alpha/osf_adjtime.c new file mode 100644 index 0000000000..c948ac2dda --- /dev/null +++ b/sysdeps/unix/sysv/linux/alpha/osf_adjtime.c @@ -0,0 +1,130 @@ +/* adjtime -- adjust the system clock. Linux/Alpha/tv32 version. + Copyright (C) 2019 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include + +#if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_1) + +#include +#include +#include + +struct timex32 { + unsigned int modes; /* mode selector */ + long offset; /* time offset (usec) */ + long freq; /* frequency offset (scaled ppm) */ + long maxerror; /* maximum error (usec) */ + long esterror; /* estimated error (usec) */ + int status; /* clock command/status */ + long constant; /* pll time constant */ + long precision; /* clock precision (usec) (read only) */ + long tolerance; /* clock frequency tolerance (ppm) + * (read only) + */ + struct timeval32 time; /* (read only) */ + long tick; /* (modified) usecs between clock ticks */ + + long ppsfreq; /* pps frequency (scaled ppm) (ro) */ + long jitter; /* pps jitter (us) (ro) */ + int shift; /* interval duration (s) (shift) (ro) */ + long stabil; /* pps stability (scaled ppm) (ro) */ + long jitcnt; /* jitter limit exceeded (ro) */ + long calcnt; /* calibration intervals (ro) */ + long errcnt; /* calibration errors (ro) */ + long stbcnt; /* stability limit exceeded (ro) */ + + int :32; int :32; int :32; int :32; + int :32; int :32; int :32; int :32; + int :32; int :32; int :32; int :32; +}; + +int +attribute_compat_text_section +__adjtime_tv32 (const struct timeval32 *itv, struct timeval32 *otv) +{ + struct timeval itv64, otv64; + tv32_to_tv64 (&itv64, itv); + + if (__adjtime (&itv64, &otv64) == -1) + return -1; + + tv64_to_tv32 (otv, &itv64); + return 0; +} + +int +attribute_compat_text_section +__adjtimex_tv32 (struct timex32 *tx) +{ + struct timex tx64; + memset (&tx64, 0, sizeof tx64); + tx64.modes = tx->modes; + tx64.offset = tx->offset; + tx64.freq = tx->freq; + tx64.maxerror = tx->maxerror; + tx64.esterror = tx->esterror; + tx64.status = tx->status; + tx64.constant = tx->constant; + tx64.precision = tx->precision; + tx64.tolerance = tx->tolerance; + tx64.tick = tx->tick; + tx64.ppsfreq = tx->ppsfreq; + tx64.jitter = tx->jitter; + tx64.shift = tx->shift; + tx64.stabil = tx->stabil; + tx64.jitcnt = tx->jitcnt; + tx64.calcnt = tx->calcnt; + tx64.errcnt = tx->errcnt; + tx64.stbcnt = tx->stbcnt; + tv32_to_tv64 (&tx64.time, &tx->time); + + int status = __adjtimex (&tx64); + if (status < 0) + return status; + + memset (tx, 0, sizeof *tx); + tx->modes = tx64.modes; + tx->offset = tx64.offset; + tx->freq = tx64.freq; + tx->maxerror = tx64.maxerror; + tx->esterror = tx64.esterror; + tx->status = tx64.status; + tx->constant = tx64.constant; + tx->precision = tx64.precision; + tx->tolerance = tx64.tolerance; + tx->tick = tx64.tick; + tx->ppsfreq = tx64.ppsfreq; + tx->jitter = tx64.jitter; + tx->shift = tx64.shift; + tx->stabil = tx64.stabil; + tx->jitcnt = tx64.jitcnt; + tx->calcnt = tx64.calcnt; + tx->errcnt = tx64.errcnt; + tx->stbcnt = tx64.stbcnt; + tv64_to_tv32 (&tx->time, &tx64.time); + + return status; +} + +strong_alias (__adjtimex_tv32, __adjtimex_tv32_1); +strong_alias (__adjtimex_tv32, __adjtimex_tv32_2); +compat_symbol (libc, __adjtimex_tv32_1, __adjtimex, GLIBC_2_0); +compat_symbol (libc, __adjtimex_tv32_2, adjtimex, GLIBC_2_0); +compat_symbol (libc, __adjtime_tv32, adjtime, GLIBC_2_0); + +#endif /* SHLIB_COMPAT */ diff --git a/sysdeps/unix/sysv/linux/alpha/osf_getitimer.c b/sysdeps/unix/sysv/linux/alpha/osf_getitimer.c new file mode 100644 index 0000000000..f290954783 --- /dev/null +++ b/sysdeps/unix/sysv/linux/alpha/osf_getitimer.c @@ -0,0 +1,41 @@ +/* getitimer -- Get the state of an interval timer. Linux/Alpha/tv32 version. + Copyright (C) 2019 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include + +#if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_1) + +#include +#include + +int +attribute_compat_text_section +__getitimer_tv32 (int which, struct itimerval32 *curr_value) +{ + struct itimerval curr_value_64; + if (__getitimer (which, &curr_value_64) == -1) + return -1; + + /* Write all fields of 'curr_value' regardless of overflow. */ + tv64_to_tv32 (&curr_value->it_interval, &curr_value_64.it_interval); + tv64_to_tv32 (&curr_value->it_value, &curr_value_64.it_value); + return 0; +} + +compat_symbol (libc, __getitimer_tv32, getitimer, GLIBC_2_0); +#endif diff --git a/sysdeps/unix/sysv/linux/alpha/osf_getrusage.c b/sysdeps/unix/sysv/linux/alpha/osf_getrusage.c new file mode 100644 index 0000000000..918e8445d4 --- /dev/null +++ b/sysdeps/unix/sysv/linux/alpha/osf_getrusage.c @@ -0,0 +1,39 @@ +/* utimes -- change file timestamps. Linux/Alpha/tv32 version. + Copyright (C) 2019 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include + +#if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_1) + +#include +#include +#include + +int +__getrusage_tv32 (int who, struct rusage32 *usage32) +{ + struct rusage usage64; + if (__getrusage (who, &usage64) == -1) + return -1; + + rusage64_to_rusage32 (usage32, &usage64); + return 0; +} + +compat_symbol (libc, __getrusage_tv32, getrusage, GLIBC_2_0); +#endif diff --git a/sysdeps/unix/sysv/linux/alpha/osf_gettimeofday.c b/sysdeps/unix/sysv/linux/alpha/osf_gettimeofday.c new file mode 100644 index 0000000000..e6cc522dd1 --- /dev/null +++ b/sysdeps/unix/sysv/linux/alpha/osf_gettimeofday.c @@ -0,0 +1,43 @@ +/* gettimeofday -- Get the current time of day. Linux/Alpha/tv32 version. + Copyright (C) 2019 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include + +#if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_1) + +#include +#include + +/* Get the current time of day and timezone information putting it + into *TV and *TZ. */ + +int +attribute_compat_text_section +__gettimeofday_tv32 (struct timeval32 *restrict tv32, void *restrict tz) +{ + struct timeval tv; + __gettimeofday (&tv, tz); + + tv64_to_tv32 (tv32, &tv); + return 0; +} + +compat_symbol (libc, __gettimeofday_tv32, __gettimeofday, GLIBC_2_0); +strong_alias (__gettimeofday_tv32, __gettimeofday_tv32_1); +compat_symbol (libc, __gettimeofday_tv32_1, gettimeofday, GLIBC_2_0); +#endif diff --git a/sysdeps/unix/sysv/linux/alpha/osf_setitimer.c b/sysdeps/unix/sysv/linux/alpha/osf_setitimer.c new file mode 100644 index 0000000000..d6bbcee60a --- /dev/null +++ b/sysdeps/unix/sysv/linux/alpha/osf_setitimer.c @@ -0,0 +1,49 @@ +/* getitimer -- Get the state of an interval timer. Linux/Alpha/tv32 version. + Copyright (C) 2019 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include + +#if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_1) + +#include +#include + +int +attribute_compat_text_section +__setitimer_tv32 (int which, const struct itimerval32 *restrict new_value, + struct itimerval32 *restrict old_value) +{ + struct itimerval new_value_64; + tv32_to_tv64 (&new_value_64.it_interval, &new_value->it_interval); + tv32_to_tv64 (&new_value_64.it_value, &new_value->it_value); + + if (old_value == NULL) + return __setitimer (which, &new_value_64, NULL); + + struct itimerval old_value_64; + if (__setitimer (which, &new_value_64, &old_value_64) == -1) + return -1; + + /* Write all fields of 'old_value' regardless of overflow. */ + tv64_to_tv32 (&old_value->it_interval, &old_value_64.it_interval); + tv64_to_tv32 (&old_value->it_value, &old_value_64.it_value); + return 0; +} + +compat_symbol (libc, __setitimer_tv32, setitimer, GLIBC_2_0); +#endif diff --git a/sysdeps/unix/sysv/linux/alpha/osf_settimeofday.c b/sysdeps/unix/sysv/linux/alpha/osf_settimeofday.c new file mode 100644 index 0000000000..fb2a36df19 --- /dev/null +++ b/sysdeps/unix/sysv/linux/alpha/osf_settimeofday.c @@ -0,0 +1,41 @@ +/* settimeofday -- Set the current time of day. Linux/Alpha/tv32 version. + Copyright (C) 2019 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include + +#if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_1) + +#include +#include +#include +#include + +/* Set the current time of day and timezone information. + This call is restricted to the super-user. */ +int +attribute_compat_text_section +__settimeofday_tv32 (const struct timeval32 *tv32, + const struct timezone *tz) +{ + struct timeval tv; + tv32_to_tv64 (&tv, tv32); + return __settimeofday (&tv, tz); +} + +compat_symbol (libc, __settimeofday_tv32, settimeofday, GLIBC_2_0); +#endif diff --git a/sysdeps/unix/sysv/linux/alpha/osf_utimes.c b/sysdeps/unix/sysv/linux/alpha/osf_utimes.c new file mode 100644 index 0000000000..788fb7cd44 --- /dev/null +++ b/sysdeps/unix/sysv/linux/alpha/osf_utimes.c @@ -0,0 +1,37 @@ +/* utimes -- change file timestamps. Linux/Alpha/tv32 version. + Copyright (C) 2019 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include + +#if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_1) + +#include +#include + +int +attribute_compat_text_section +__utimes_tv32 (const char *filename, const struct timeval32 times32[2]) +{ + struct timeval times[2]; + tv32_to_tv64 (×[0], ×32[0]); + tv32_to_tv64 (×[1], ×32[1]); + return __utimes (filename, times); +} + +compat_symbol (libc, __utimes_tv32, utimes, GLIBC_2_0); +#endif diff --git a/sysdeps/unix/sysv/linux/alpha/osf_wait4.c b/sysdeps/unix/sysv/linux/alpha/osf_wait4.c new file mode 100644 index 0000000000..e8db554660 --- /dev/null +++ b/sysdeps/unix/sysv/linux/alpha/osf_wait4.c @@ -0,0 +1,41 @@ +/* wait4 -- wait for process to change state. Linux/Alpha/tv32 version. + Copyright (C) 2019 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include + +#if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_1) + +#include +#include +#include +#include + +pid_t +attribute_compat_text_section +__wait4_tv32 (pid_t pid, int *status, int options, struct rusage32 *usage32) +{ + struct rusage usage64; + pid_t child = __wait4 (pid, status, options, &usage64); + + if (child >= 0 && usage32 != NULL) + rusage64_to_rusage32 (usage32, &usage64); + return child; +} + +compat_symbol (libc, __wait4_tv32, wait4, GLIBC_2_0); +#endif diff --git a/sysdeps/unix/sysv/linux/alpha/syscalls.list b/sysdeps/unix/sysv/linux/alpha/syscalls.list index 12cd021b60..c786aa751e 100644 --- a/sysdeps/unix/sysv/linux/alpha/syscalls.list +++ b/sysdeps/unix/sysv/linux/alpha/syscalls.list @@ -1,4 +1,4 @@ -# File name Caller Syscall name # args Strong name Weak names +# File name Caller Syscall name Args Strong name Weak names sigstack - sigstack 2 sigstack @@ -22,23 +22,14 @@ pciconfig_read EXTRA pciconfig_read 5 pciconfig_read pciconfig_write EXTRA pciconfig_write 5 pciconfig_write pciconfig_iobase EXTRA pciconfig_iobase 3 __pciconfig_iobase pciconfig_iobase -# support old timeval32 entry points -osf_gettimeofday - osf_gettimeofday 2 __gettimeofday_tv32 __gettimeofday@GLIBC_2.0 gettimeofday@GLIBC_2.0 -osf_settimeofday - osf_settimeofday 2 __settimeofday_tv32 settimeofday@GLIBC_2.0 -osf_getitimer - osf_getitimer 2 __getitimer_tv32 getitimer@GLIBC_2.0 -osf_setitimer - osf_setitimer 3 __setitimer_tv32 setitimer@GLIBC_2.0 -osf_utimes - osf_utimes 2 __utimes_tv32 utimes@GLIBC_2.0 -osf_getrusage - osf_getrusage 2 __getrusage_tv32 getrusage@GLIBC_2.0 -osf_wait4 - osf_wait4 4 __wait4_tv32 wait4@GLIBC_2.0 - -# support new timeval64 entry points -gettimeofday - gettimeofday 2 __GI___gettimeofday gettimeofday@@GLIBC_2.1 __gettimeofday@@GLIBC_2.1 -settimeofday - settimeofday 2 __settimeofday settimeofday@@GLIBC_2.1 -getitimer - getitimer 2 __getitimer getitimer@@GLIBC_2.1 -setitimer - setitimer 3 __setitimer setitimer@@GLIBC_2.1 -utimes - utimes 2 __utimes utimes@@GLIBC_2.1 -getrusage - getrusage 2 __getrusage getrusage@@GLIBC_2.1 -wait4 - wait4 4 __wait4 wait4@@GLIBC_2.1 +# timeval64 entry points (see osf_*.c for GLIBC_2.0 timeval32 equivalents) +gettimeofday - gettimeofday i:pP __GI___gettimeofday gettimeofday@@GLIBC_2.1 __gettimeofday@@GLIBC_2.1 +settimeofday - settimeofday i:PP __settimeofday settimeofday@@GLIBC_2.1 +getitimer - getitimer i:ip __getitimer getitimer@@GLIBC_2.1 +setitimer - setitimer i:ipP __setitimer setitimer@@GLIBC_2.1 +utimes - utimes i:sp __utimes utimes@@GLIBC_2.1 +getrusage - getrusage i:ip __getrusage getrusage@@GLIBC_2.1 +wait4 - wait4 i:iWiP __wait4 wait4@@GLIBC_2.1 # avoid 64-bit aliases on 32-bit statfs syscalls fstatfs - fstatfs i:ip __fstatfs fstatfs diff --git a/sysdeps/unix/sysv/linux/alpha/tv32-compat.h b/sysdeps/unix/sysv/linux/alpha/tv32-compat.h new file mode 100644 index 0000000000..e1edb7453a --- /dev/null +++ b/sysdeps/unix/sysv/linux/alpha/tv32-compat.h @@ -0,0 +1,146 @@ +/* Compatibility definitions for `struct timeval' with 32-bit time_t. + Copyright (C) 2019 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#ifndef _TV32_COMPAT_H +#define _TV32_COMPAT_H 1 + +#include + +#include +#include +#include +#include +#include + +#include // for INT32_MAX +#include // for memset + +#define TV_USEC_MAX 999999 // 10**6 - 1 + +/* A version of 'struct timeval' with 32-bit time_t. */ +struct timeval32 +{ + int32_t tv_sec; + int32_t tv_usec; +}; + +/* Structures containing 'struct timeval' with 32-bit time_t. */ +struct itimerval32 +{ + struct timeval32 it_interval; + struct timeval32 it_value; +}; + +struct rusage32 +{ + struct timeval32 ru_utime; /* user time used */ + struct timeval32 ru_stime; /* system time used */ + long ru_maxrss; /* maximum resident set size */ + long ru_ixrss; /* integral shared memory size */ + long ru_idrss; /* integral unshared data size */ + long ru_isrss; /* integral unshared stack size */ + long ru_minflt; /* page reclaims */ + long ru_majflt; /* page faults */ + long ru_nswap; /* swaps */ + long ru_inblock; /* block input operations */ + long ru_oublock; /* block output operations */ + long ru_msgsnd; /* messages sent */ + long ru_msgrcv; /* messages received */ + long ru_nsignals; /* signals received */ + long ru_nvcsw; /* voluntary context switches */ + long ru_nivcsw; /* involuntary " */ +}; + +/* Conversion functions. If the seconds field of a timeval32 would + overflow, they write { INT32_MAX, TV_USEC_MAX } to the output. */ + +static inline void +tv32_to_tv64 (struct timeval *restrict tv64, + const struct timeval32 *restrict tv32) +{ + tv64->tv_sec = tv32->tv_sec; + tv64->tv_usec = tv32->tv_usec; +} + +static inline void +tv32_to_ts64 (struct timespec *restrict ts64, + const struct timeval32 *restrict tv32) +{ + ts64->tv_sec = tv32->tv_sec; + ts64->tv_nsec = tv32->tv_usec * 1000; +} + +static inline void +tv64_to_tv32 (struct timeval32 *restrict tv32, + const struct timeval *restrict tv64) +{ + if (__glibc_unlikely (tv64->tv_sec > (time_t) INT32_MAX)) + { + tv32->tv_sec = INT32_MAX; + tv32->tv_usec = TV_USEC_MAX; + } + else + { + tv32->tv_sec = tv64->tv_sec; + tv32->tv_usec = tv64->tv_usec; + } +} + +static inline void +ts64_to_tv32 (struct timeval32 *restrict tv32, + const struct timespec *restrict ts64) +{ + if (__glibc_unlikely (ts64->tv_sec > (time_t) INT32_MAX)) + { + tv32->tv_sec = INT32_MAX; + tv32->tv_usec = TV_USEC_MAX; + } + else + { + tv32->tv_sec = ts64->tv_sec; + tv32->tv_usec = ts64->tv_nsec / 1000; + } +} + +static inline void +rusage64_to_rusage32 (struct rusage32 *restrict r32, + const struct rusage *restrict r64) +{ + /* Make sure the entire output structure is cleared, including + padding and reserved fields. */ + memset (r32, 0, sizeof *r32); + + tv64_to_tv32 (&r32->ru_utime, &r64->ru_utime); + tv64_to_tv32 (&r32->ru_stime, &r64->ru_stime); + r32->ru_maxrss = r64->ru_maxrss; + r32->ru_ixrss = r64->ru_ixrss; + r32->ru_idrss = r64->ru_idrss; + r32->ru_isrss = r64->ru_isrss; + r32->ru_minflt = r64->ru_minflt; + r32->ru_majflt = r64->ru_majflt; + r32->ru_nswap = r64->ru_nswap; + r32->ru_inblock = r64->ru_inblock; + r32->ru_oublock = r64->ru_oublock; + r32->ru_msgsnd = r64->ru_msgsnd; + r32->ru_msgrcv = r64->ru_msgrcv; + r32->ru_nsignals = r64->ru_nsignals; + r32->ru_nvcsw = r64->ru_nvcsw; + r32->ru_nivcsw = r64->ru_nivcsw; +} + +#endif /* tv32-compat.h */ diff --git a/sysdeps/unix/sysv/linux/gettimeofday.c b/sysdeps/unix/sysv/linux/gettimeofday.c index d69d4eaa96..c9597d6405 100644 --- a/sysdeps/unix/sysv/linux/gettimeofday.c +++ b/sysdeps/unix/sysv/linux/gettimeofday.c @@ -30,10 +30,20 @@ putting it into *tv and *tz. If tz is null, *tz is not filled. Returns 0 on success, -1 on errors. */ int -__gettimeofday (struct timeval *tv, struct timezone *tz) +___gettimeofday (struct timeval *tv, struct timezone *tz) { return INLINE_VSYSCALL (gettimeofday, 2, tv, tz); } + +#ifdef VERSION_gettimeofday +weak_alias (___gettimeofday, __wgettimeofday); +default_symbol_version (___gettimeofday, __gettimeofday, VERSION_gettimeofday); +default_symbol_version (__wgettimeofday, gettimeofday, VERSION_gettimeofday); +libc_hidden_ver (___gettimeofday, __gettimeofday); +libc_hidden_ver (___gettimeofday, gettimeofday); +#else +strong_alias (___gettimeofday, __gettimeofday) +weak_alias (___gettimeofday, gettimeofday) libc_hidden_def (__gettimeofday) -weak_alias (__gettimeofday, gettimeofday) libc_hidden_weak (gettimeofday) +#endif diff --git a/sysdeps/unix/sysv/linux/syscalls.list b/sysdeps/unix/sysv/linux/syscalls.list index e374f97b5f..cdcf6c127b 100644 --- a/sysdeps/unix/sysv/linux/syscalls.list +++ b/sysdeps/unix/sysv/linux/syscalls.list @@ -1,6 +1,5 @@ # File name Caller Syscall name Args Strong name Weak names -adjtimex adjtime adjtimex i:p __adjtimex adjtimex ntp_adjtime alarm - alarm i:i alarm bdflush EXTRA bdflush i:ii __compat_bdflush bdflush@GLIBC_2.0:GLIBC_2.23 capget EXTRA capget i:pp capget From patchwork Fri Oct 25 12:08:23 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 177734 Delivered-To: patch@linaro.org Received: by 2002:a92:409a:0:0:0:0:0 with SMTP id d26csp3602072ill; Fri, 25 Oct 2019 05:09:29 -0700 (PDT) X-Google-Smtp-Source: APXvYqwbl4qFBfCjOjknsyrAJfmnsZ4ONVv3W8HqnGsiHls2/U7jq6F5wEhc1YcGb9yfk6dGm1Wu X-Received: by 2002:a50:984b:: with SMTP id h11mr3565570edb.248.1572005369558; Fri, 25 Oct 2019 05:09:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572005369; cv=none; d=google.com; s=arc-20160816; b=Y41lrgCLBrXXTi7vb24YLHHW+EdXnrRbjoJ6ywMrtnwo3aCqpPAnXgyn5hpJm9Ypgw FEi8exwh0F14jnnU5B++3R97VJRdKoUBpjq/V49OlZV36RDaVN9oSwCxt1ufqePVQRdQ wj5nW+0imcKBxHOvjpnZATm6fTcc32Rz3giXO2hYv9Ff6DVx58qPvOQT1X6bJhyFlv8k 1JqQUzC6dUNH7SUgZ6LNsFPWV29K5mkJA5DJjjW4iSokK1Ok+m5gGwaySKIC3aE8+Wzk sAcC391Ap/URvU7/7d1nfAos9Qqj1RuowFeFPtQgyhatbs3IUHp5mU5TBLT2dI7EbGzI lTog== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:delivered-to:sender:list-help:list-post:list-archive :list-subscribe:list-unsubscribe:list-id:precedence:mailing-list :dkim-signature:domainkey-signature; bh=6Ybuv7SmPXc4Z83sfGH0i13c3jC4/Dv/+afbFilWrk4=; b=xxHl8NVF1ZrHGIsN3h0XfhWv4abmPIsYL0BDp0bp4nOwrnDTk5mWDwDrmzbmwJNXhN xUHiIkG141WrpsunQM8qaVafPaFc3w5gIgj3i/MAVDBAkQAsUCsldSd9g+JP4Ht7c0Qd BUh+pTwhHRAD3I1p2X5otgjXT0qcjeHmgh2RB9SrB5g84dqZtBxa33z78NLXAG2kB3lB tm//syCMF6zOhyZ8uVfbzmFsqxQ0tu01AGiwCU7ON8CpGfnkva0j86k5LbOooQaRt59r sggYMuyhf+kBwWTRgSF86qjXz8X9ZhOKCUdGaELWEDZw7974knVF+rzLPk0yBvRckj5b 3MuA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=xt0VGiNc; dkim=pass header.i=@linaro.org header.s=google header.b=qgvYVWHe; spf=pass (google.com: domain of libc-alpha-return-106284-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="libc-alpha-return-106284-patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id y41si1081145edb.69.2019.10.25.05.09.28 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 25 Oct 2019 05:09:29 -0700 (PDT) Received-SPF: pass (google.com: domain of libc-alpha-return-106284-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=xt0VGiNc; dkim=pass header.i=@linaro.org header.s=google header.b=qgvYVWHe; spf=pass (google.com: domain of libc-alpha-return-106284-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="libc-alpha-return-106284-patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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=yW0VoyDPQbmroqds30S++sOa8GvM1kx YYaaChwkXqZpCFnj2keABeFqq6O3osdAFncmOh+7m1q2J3N/w7i6V+ZYYh3V6qc5 y4AOlwasfqoQ03W1ey7qQcnztwOrBPvNHLn/KCt9d0jO23Ifiyrx/ErjnNjKDWXq 5tJufmEuvgPE= 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=6KpmY7/XCIT2RrN6Zg03NOZS/Ws=; b=xt0VG iNc/hIzThkj/4H3DS3cZL0M25oWhP0OcT0f8kgH94J3efaXrV/KmZJm3owbguQRA udQZNRSlkUckoVbQoLV47KhOC652omgHhjCxH9a8VvSulZHd/swY0qtINql/rxPB eUKjbGucm1e/bynDjfl+MA7bhaAJHDzjJm8yrI= Received: (qmail 77272 invoked by alias); 25 Oct 2019 12:08:53 -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 77143 invoked by uid 89); 25 Oct 2019 12:08:53 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-20.4 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS, UNSUBSCRIBE_BODY autolearn=ham version=3.3.1 spammy=6th, 500000, 1000000, BEFORE X-HELO: mail-qk1-f195.google.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=6Ybuv7SmPXc4Z83sfGH0i13c3jC4/Dv/+afbFilWrk4=; b=qgvYVWHejdhq1KcapVBH+6QsAWCz8SfyJvg8NJTfvHwIny4iPZR8tz/6ynQ7re3JzF fqTGU2eUiVnfCv5flbFq/C48bxJXAkujGxwCpYdFhNAYXuUH894rMwp9sodyMo9DfnSy KyNJB2PW62BE+GF2VFR/c2TQoZTuoxWVBIu4vebX+YQYkeT5o7l1qVZ2Of6aSmb+/JLu RFP8slXbrnlbK/JoxZOXsDNjes14fbZK8CHwHh9KX28bY0FmpjNRKZHk6n9umTTGYM9m AqKC4rBMWkarBolO123wRgb6ij9j9hi4Giy7lEvxuA09d9fqSA4LQwhXx8IEXbh/XGKh wj9A== Return-Path: From: Adhemerval Zanella To: libc-alpha@sourceware.org Cc: Lukasz Majewski , Zack Weinberg Subject: [PATCH v2 02/11] Change most internal uses of __gettimeofday to __clock_gettime. Date: Fri, 25 Oct 2019 09:08:23 -0300 Message-Id: <20191025120832.27667-3-adhemerval.zanella@linaro.org> In-Reply-To: <20191025120832.27667-1-adhemerval.zanella@linaro.org> References: <20191025120832.27667-1-adhemerval.zanella@linaro.org> From: Zack Weinberg Changes from previous version: - Fixed some indentation and style issues. - Use external clock_gettime on memusage.h. - Fixed some conformant issues on Hurd. -- Since gettimeofday will shortly be implemented in terms of clock_gettime on all platforms, internal code should use clock_gettime directly; in addition to removing a layer of indirection, this will allow us to remove the PLT-bypass gunk for gettimeofday. (We can't quite do that yet, but it'll be coming later in this patch series.) In many cases, the changed code does fewer conversions. The changed code always assumes __clock_gettime (CLOCK_REALTIME) cannot fail. Most of the call sites were assuming gettimeofday could not fail, but a few places were checking for errors. POSIX says clock_gettime can only fail if the clock constant is invalid or unsupported, and CLOCK_REALTIME is the one and only clock constant that's required to be supported. For consistency I grepped the entire source tree for any other places that checked for errors from __clock_gettime (CLOCK_REALTIME), found one, and changed it too. (For the record, POSIX also says gettimeofday can never fail.) (It would be nice if we could declare that GNU systems will always support CLOCK_MONOTONIC as well as CLOCK_REALTIME; there are several places where we are using CLOCK_REALTIME where _MONOTONIC would be more appropriate, and/or trying to use _MONOTONIC and then falling back to _REALTIME. But the Hurd doesn't support CLOCK_MONOTONIC yet, and it looks like adding it would involve substantial changes to gnumach's internals and API. Oh well.) A few Hurd-specific files were changed to use __host_get_time instead of __clock_gettime, as this seemed tidier. We also assume this cannot fail. Skimming the code in gnumach leads me to believe the only way it could fail is if __mach_host_self also failed, and our Hurd-specific code consistently assumes that can't happen, so I'm going with that. With the exception of support/support_test_main.c, test cases are not modified, mainly because I didn't want to have to figure out which test cases were testing gettimeofday specifically. The definition of GETTIME in sysdeps/generic/memusage.h had a typo and was not reading tv_sec at all. I fixed this. It appears nobody has been generating malloc traces on a machine that doesn't have a superseding definition. There are a whole bunch of places where the code could be simplified by factoring out timespec subtraction and/or comparison logic, but I want to keep this patch as mechanical as possible. Checked on x86_64-linux-gnu, i686-linux-gnu, powerpc64le-linux-gnu, powerpc64-linux-gnu, powerpc-linux-gnu, and aarch64-linux-gnu. Reviewed-by: Adhemerval Zanella --- inet/deadline.c | 8 +------- login/logout.c | 9 +++++---- login/logwtmp.c | 7 +++---- nis/nis_call.c | 4 +++- nptl/pthread_join_common.c | 7 +++---- nptl/pthread_mutex_timedlock.c | 7 +++---- nscd/nscd_helper.c | 24 +++++++++++------------ resolv/gai_misc.c | 6 +++--- resolv/gai_suspend.c | 6 +++--- resolv/res_send.c | 7 +------ sunrpc/auth_des.c | 19 ++++++++++-------- sunrpc/auth_unix.c | 9 +++++---- sunrpc/create_xid.c | 6 +++--- sunrpc/svcauth_des.c | 7 ++++++- support/support_test_main.c | 23 +++++++++++----------- sysdeps/generic/memusage.h | 16 +++++++-------- sysdeps/mach/hurd/getitimer.c | 11 ++++++++--- sysdeps/mach/hurd/setitimer.c | 13 ++++++------ sysdeps/mach/hurd/times.c | 7 +++---- sysdeps/mach/nanosleep.c | 36 ++++++++++++++++++++++------------ sysdeps/mach/usleep.c | 5 ----- sysdeps/posix/tempname.c | 9 ++++----- sysdeps/posix/timespec_get.c | 14 ++++--------- sysdeps/pthread/aio_misc.c | 6 +++--- sysdeps/pthread/aio_suspend.c | 6 +++--- sysdeps/unix/make-syscalls.sh | 2 +- 26 files changed, 137 insertions(+), 137 deletions(-) -- 2.17.1 Reviewed-by: Lukasz Majewski diff --git a/inet/deadline.c b/inet/deadline.c index 6051f1fe0c..541c16bd9a 100644 --- a/inet/deadline.c +++ b/inet/deadline.c @@ -29,13 +29,7 @@ __deadline_current_time (void) { struct deadline_current_time result; if (__clock_gettime (CLOCK_MONOTONIC, &result.current) != 0) - { - struct timeval current_tv; - if (__gettimeofday (¤t_tv, NULL) == 0) - __libc_fatal ("Fatal error: gettimeofday system call failed\n"); - result.current.tv_sec = current_tv.tv_sec; - result.current.tv_nsec = current_tv.tv_usec * 1000; - } + __clock_gettime (CLOCK_REALTIME, &result.current); assert (result.current.tv_sec >= 0); return result; } diff --git a/login/logout.c b/login/logout.c index d0d421cbf7..b8b38df19d 100644 --- a/login/logout.c +++ b/login/logout.c @@ -19,6 +19,7 @@ #include #include #include +#include #include int @@ -45,10 +46,10 @@ logout (const char *line) /* Clear information about who & from where. */ memset (ut->ut_name, '\0', sizeof ut->ut_name); memset (ut->ut_host, '\0', sizeof ut->ut_host); - struct timeval tv; - __gettimeofday (&tv, NULL); - ut->ut_tv.tv_sec = tv.tv_sec; - ut->ut_tv.tv_usec = tv.tv_usec; + + struct timespec ts; + __clock_gettime (CLOCK_REALTIME, &ts); + TIMESPEC_TO_TIMEVAL (&ut->ut_tv, &ts); ut->ut_type = DEAD_PROCESS; if (pututline (ut) != NULL) diff --git a/login/logwtmp.c b/login/logwtmp.c index 654f412ecb..eddba96f35 100644 --- a/login/logwtmp.c +++ b/login/logwtmp.c @@ -36,10 +36,9 @@ logwtmp (const char *line, const char *name, const char *host) strncpy (ut.ut_name, name, sizeof ut.ut_name); strncpy (ut.ut_host, host, sizeof ut.ut_host); - struct timeval tv; - __gettimeofday (&tv, NULL); - ut.ut_tv.tv_sec = tv.tv_sec; - ut.ut_tv.tv_usec = tv.tv_usec; + struct timespec ts; + __clock_gettime (CLOCK_REALTIME, &ts); + TIMESPEC_TO_TIMEVAL (&ut.ut_tv, &ts); updwtmp (_PATH_WTMP, &ut); } diff --git a/nis/nis_call.c b/nis/nis_call.c index 1684de1c6d..5097e614ea 100644 --- a/nis/nis_call.c +++ b/nis/nis_call.c @@ -709,6 +709,7 @@ __nisfind_server (const_nis_name name, int search_parent, nis_error status; directory_obj *obj; struct timeval now; + struct timespec ts; unsigned int server_used = ~0; unsigned int current_ep = ~0; @@ -718,7 +719,8 @@ __nisfind_server (const_nis_name name, int search_parent, if (*dir != NULL) return NIS_SUCCESS; - (void) gettimeofday (&now, NULL); + __clock_gettime (CLOCK_REALTIME, &ts); + TIMESPEC_TO_TIMEVAL (&now, &ts); if ((flags & NO_CACHE) == 0) *dir = nis_server_cache_search (name, search_parent, &server_used, diff --git a/nptl/pthread_join_common.c b/nptl/pthread_join_common.c index 9545ae4bd3..ad3073e32d 100644 --- a/nptl/pthread_join_common.c +++ b/nptl/pthread_join_common.c @@ -46,15 +46,14 @@ timedwait_tid (pid_t *tidp, const struct timespec *abstime) /* Repeat until thread terminated. */ while ((tid = *tidp) != 0) { - struct timeval tv; struct timespec rt; /* Get the current time. */ - __gettimeofday (&tv, NULL); + __clock_gettime (CLOCK_REALTIME, &rt); /* Compute relative timeout. */ - rt.tv_sec = abstime->tv_sec - tv.tv_sec; - rt.tv_nsec = abstime->tv_nsec - tv.tv_usec * 1000; + rt.tv_sec = abstime->tv_sec - rt.tv_sec; + rt.tv_nsec = abstime->tv_nsec - rt.tv_nsec; if (rt.tv_nsec < 0) { rt.tv_nsec += 1000000000; diff --git a/nptl/pthread_mutex_timedlock.c b/nptl/pthread_mutex_timedlock.c index a0ce044dd4..7a5be6b997 100644 --- a/nptl/pthread_mutex_timedlock.c +++ b/nptl/pthread_mutex_timedlock.c @@ -567,15 +567,14 @@ __pthread_mutex_clocklock_common (pthread_mutex_t *mutex, goto failpp; } - struct timeval tv; struct timespec rt; /* Get the current time. */ - (void) __gettimeofday (&tv, NULL); + __clock_gettime (CLOCK_REALTIME, &rt); /* Compute relative timeout. */ - rt.tv_sec = abstime->tv_sec - tv.tv_sec; - rt.tv_nsec = abstime->tv_nsec - tv.tv_usec * 1000; + rt.tv_sec = abstime->tv_sec - rt.tv_sec; + rt.tv_nsec = abstime->tv_nsec - rt.tv_nsec; if (rt.tv_nsec < 0) { rt.tv_nsec += 1000000000; diff --git a/nscd/nscd_helper.c b/nscd/nscd_helper.c index d326a380ee..7361fe2e0a 100644 --- a/nscd/nscd_helper.c +++ b/nscd/nscd_helper.c @@ -59,9 +59,10 @@ wait_on_socket (int sock, long int usectmo) /* Handle the case where the poll() call is interrupted by a signal. We cannot just use TEMP_FAILURE_RETRY since it might lead to infinite loops. */ - struct timeval now; - (void) __gettimeofday (&now, NULL); - long int end = now.tv_sec * 1000 + usectmo + (now.tv_usec + 500) / 1000; + struct timespec now; + __clock_gettime (CLOCK_REALTIME, &now); + long int end = (now.tv_sec * 1000 + usectmo + + (now.tv_nsec + 500000) / 1000000); long int timeout = usectmo; while (1) { @@ -70,8 +71,9 @@ wait_on_socket (int sock, long int usectmo) break; /* Recompute the timeout time. */ - (void) __gettimeofday (&now, NULL); - timeout = end - (now.tv_sec * 1000 + (now.tv_usec + 500) / 1000); + __clock_gettime (CLOCK_REALTIME, &now); + timeout = end - ((now.tv_sec * 1000 + + (now.tv_nsec + 500000) / 1000000)); } } @@ -191,9 +193,7 @@ open_socket (request_type type, const char *key, size_t keylen) memcpy (reqdata->key, key, keylen); bool first_try = true; - struct timeval tvend; - /* Fake initializing tvend. */ - asm ("" : "=m" (tvend)); + struct timespec tvend = { 0, 0 }; while (1) { #ifndef MSG_NOSIGNAL @@ -212,18 +212,18 @@ open_socket (request_type type, const char *key, size_t keylen) /* The daemon is busy wait for it. */ int to; - struct timeval now; - (void) __gettimeofday (&now, NULL); + struct timespec now; + __clock_gettime (CLOCK_REALTIME, &now); if (first_try) { - tvend.tv_usec = now.tv_usec; + tvend.tv_nsec = now.tv_nsec; tvend.tv_sec = now.tv_sec + 5; to = 5 * 1000; first_try = false; } else to = ((tvend.tv_sec - now.tv_sec) * 1000 - + (tvend.tv_usec - now.tv_usec) / 1000); + + (tvend.tv_nsec - now.tv_nsec) / 1000000); struct pollfd fds[1]; fds[0].fd = sock; diff --git a/resolv/gai_misc.c b/resolv/gai_misc.c index 8738359d81..760c33ac29 100644 --- a/resolv/gai_misc.c +++ b/resolv/gai_misc.c @@ -357,13 +357,13 @@ handle_requests (void *arg) something to arrive in it. */ if (runp == NULL && optim.gai_idle_time >= 0) { - struct timeval now; + struct timespec now; struct timespec wakeup_time; ++idle_thread_count; - gettimeofday (&now, NULL); + __clock_gettime (CLOCK_REALTIME, &now); wakeup_time.tv_sec = now.tv_sec + optim.gai_idle_time; - wakeup_time.tv_nsec = now.tv_usec * 1000; + wakeup_time.tv_nsec = now.tv_nsec; if (wakeup_time.tv_nsec >= 1000000000) { wakeup_time.tv_nsec -= 1000000000; diff --git a/resolv/gai_suspend.c b/resolv/gai_suspend.c index 16d6998980..b8c642bddc 100644 --- a/resolv/gai_suspend.c +++ b/resolv/gai_suspend.c @@ -91,11 +91,11 @@ gai_suspend (const struct gaicb *const list[], int ent, { /* We have to convert the relative timeout value into an absolute time value with pthread_cond_timedwait expects. */ - struct timeval now; + struct timespec now; struct timespec abstime; - __gettimeofday (&now, NULL); - abstime.tv_nsec = timeout->tv_nsec + now.tv_usec * 1000; + __clock_gettime (CLOCK_REALTIME, &now); + abstime.tv_nsec = timeout->tv_nsec + now.tv_nsec; abstime.tv_sec = timeout->tv_sec + now.tv_sec; if (abstime.tv_nsec >= 1000000000) { diff --git a/resolv/res_send.c b/resolv/res_send.c index 6b9c73f820..47bfba6747 100644 --- a/resolv/res_send.c +++ b/resolv/res_send.c @@ -172,12 +172,7 @@ evCmpTime(struct timespec a, struct timespec b) { static void evNowTime(struct timespec *res) { - struct timeval now; - - if (gettimeofday(&now, NULL) < 0) - evConsTime(res, 0, 0); - else - TIMEVAL_TO_TIMESPEC (&now, res); + __clock_gettime(CLOCK_REALTIME, res); } diff --git a/sunrpc/auth_des.c b/sunrpc/auth_des.c index 5b6f985bc2..d26820a701 100644 --- a/sunrpc/auth_des.c +++ b/sunrpc/auth_des.c @@ -41,6 +41,7 @@ #include #include /* XXX: just to get htonl() and ntohl() */ #include +#include #include #define MILLION 1000000L @@ -246,15 +247,15 @@ authdes_marshal (AUTH *auth, XDR *xdrs) int status; int len; register int32_t *ixdr; - struct timeval tval; + struct timespec now; /* * Figure out the "time", accounting for any time difference * with the server if necessary. */ - __gettimeofday (&tval, (struct timezone *) NULL); - ad->ad_timestamp.tv_sec = tval.tv_sec + ad->ad_timediff.tv_sec; - ad->ad_timestamp.tv_usec = tval.tv_usec + ad->ad_timediff.tv_usec; + __clock_gettime (CLOCK_REALTIME, &now); + ad->ad_timestamp.tv_sec = now.tv_sec + ad->ad_timediff.tv_sec; + ad->ad_timestamp.tv_usec = (now.tv_nsec / 1000) + ad->ad_timediff.tv_usec; if (ad->ad_timestamp.tv_usec >= MILLION) { ad->ad_timestamp.tv_usec -= MILLION; @@ -445,21 +446,23 @@ authdes_destroy (AUTH *auth) static bool_t synchronize (struct sockaddr *syncaddr, struct rpc_timeval *timep) { - struct timeval mytime; + struct timespec mytime; struct rpc_timeval timeout; + long int myusec; timeout.tv_sec = RTIME_TIMEOUT; timeout.tv_usec = 0; if (rtime ((struct sockaddr_in *) syncaddr, timep, &timeout) < 0) return FALSE; - __gettimeofday (&mytime, (struct timezone *) NULL); + __clock_gettime (CLOCK_REALTIME, &mytime); timep->tv_sec -= mytime.tv_sec; - if (mytime.tv_usec > timep->tv_usec) + myusec = mytime.tv_nsec / 1000; + if (myusec > timep->tv_usec) { timep->tv_sec -= 1; timep->tv_usec += MILLION; } - timep->tv_usec -= mytime.tv_usec; + timep->tv_usec -= myusec; return TRUE; } diff --git a/sunrpc/auth_unix.c b/sunrpc/auth_unix.c index b035fdd870..ff0d2eb933 100644 --- a/sunrpc/auth_unix.c +++ b/sunrpc/auth_unix.c @@ -43,6 +43,7 @@ #include #include #include +#include #include #include #include @@ -96,7 +97,7 @@ authunix_create (char *machname, uid_t uid, gid_t gid, int len, { struct authunix_parms aup; char mymem[MAX_AUTH_BYTES]; - struct timeval now; + struct timespec now; XDR xdrs; AUTH *auth; struct audata *au; @@ -122,7 +123,7 @@ no_memory: /* * fill in param struct from the given params */ - (void) __gettimeofday (&now, (struct timezone *) 0); + __clock_gettime (CLOCK_REALTIME, &now); aup.aup_time = now.tv_sec; aup.aup_machname = machname; aup.aup_uid = uid; @@ -276,7 +277,7 @@ authunix_refresh (AUTH *auth) { struct audata *au = AUTH_PRIVATE (auth); struct authunix_parms aup; - struct timeval now; + struct timespec now; XDR xdrs; int stat; @@ -297,7 +298,7 @@ authunix_refresh (AUTH *auth) goto done; /* update the time and serialize in place */ - (void) __gettimeofday (&now, (struct timezone *) 0); + __clock_gettime (CLOCK_REALTIME, &now); aup.aup_time = now.tv_sec; xdrs.x_op = XDR_ENCODE; XDR_SETPOS (&xdrs, 0); diff --git a/sunrpc/create_xid.c b/sunrpc/create_xid.c index 1339615a1b..c692c1eb92 100644 --- a/sunrpc/create_xid.c +++ b/sunrpc/create_xid.c @@ -39,10 +39,10 @@ _create_xid (void) pid_t pid = getpid (); if (is_initialized != pid) { - struct timeval now; + struct timespec now; - __gettimeofday (&now, (struct timezone *) 0); - __srand48_r (now.tv_sec ^ now.tv_usec ^ pid, + __clock_gettime (CLOCK_REALTIME, &now); + __srand48_r (now.tv_sec ^ now.tv_nsec ^ pid, &__rpc_lrand48_data); is_initialized = pid; } diff --git a/sunrpc/svcauth_des.c b/sunrpc/svcauth_des.c index c5a512d6f8..7607abc818 100644 --- a/sunrpc/svcauth_des.c +++ b/sunrpc/svcauth_des.c @@ -44,6 +44,7 @@ #include #include #include +#include #include #include #include @@ -295,7 +296,11 @@ _svcauth_des (register struct svc_req *rqst, register struct rpc_msg *msg) debug ("timestamp before last seen"); return AUTH_REJECTEDVERF; /* replay */ } - __gettimeofday (¤t, (struct timezone *) NULL); + { + struct timespec now; + __clock_gettime (CLOCK_REALTIME, &now); + TIMESPEC_TO_TIMEVAL (¤t, &now); + } current.tv_sec -= window; /* allow for expiration */ if (!BEFORE (¤t, ×tamp)) { diff --git a/support/support_test_main.c b/support/support_test_main.c index 05ad92e688..d6b3a8d45f 100644 --- a/support/support_test_main.c +++ b/support/support_test_main.c @@ -88,16 +88,18 @@ static pid_t test_pid; static void (*cleanup_function) (void); static void -print_timestamp (const char *what, struct timeval tv) +print_timestamp (const char *what, struct timespec tv) { struct tm tm; + /* Casts of tv.tv_nsec below are necessary because the type of + tv_nsec is not literally long int on all supported platforms. */ if (gmtime_r (&tv.tv_sec, &tm) == NULL) - printf ("%s: %lld.%06d\n", - what, (long long int) tv.tv_sec, (int) tv.tv_usec); + printf ("%s: %lld.%09ld\n", + what, (long long int) tv.tv_sec, (long int) tv.tv_nsec); else - printf ("%s: %04d-%02d-%02dT%02d:%02d:%02d.%06d\n", + printf ("%s: %04d-%02d-%02dT%02d:%02d:%02d.%09ld\n", what, 1900 + tm.tm_year, tm.tm_mon + 1, tm.tm_mday, - tm.tm_hour, tm.tm_min, tm.tm_sec, (int) tv.tv_usec); + tm.tm_hour, tm.tm_min, tm.tm_sec, (long int) tv.tv_nsec); } /* Timeout handler. We kill the child and exit with an error. */ @@ -110,8 +112,8 @@ signal_handler (int sig) /* Do this first to avoid further interference from the subprocess. */ - struct timeval now; - bool now_available = gettimeofday (&now, NULL) == 0; + struct timespec now; + clock_gettime (CLOCK_REALTIME, &now); struct stat64 st; bool st_available = fstat64 (STDOUT_FILENO, &st) == 0 && st.st_mtime != 0; @@ -165,12 +167,9 @@ signal_handler (int sig) printf ("Timed out: killed the child process but it exited %d\n", WEXITSTATUS (status)); - if (now_available) - print_timestamp ("Termination time", now); + print_timestamp ("Termination time", now); if (st_available) - print_timestamp ("Last write to standard output", - (struct timeval) { st.st_mtim.tv_sec, - st.st_mtim.tv_nsec / 1000 }); + print_timestamp ("Last write to standard output", st.st_mtim); /* Exit with an error. */ exit (1); diff --git a/sysdeps/generic/memusage.h b/sysdeps/generic/memusage.h index 400fe23f29..88b291e3fa 100644 --- a/sysdeps/generic/memusage.h +++ b/sysdeps/generic/memusage.h @@ -26,14 +26,14 @@ #endif #ifndef GETTIME -# define GETTIME(low,high) \ - { \ - struct timeval tval; \ - uint64_t usecs; \ - gettimeofday (&tval, NULL); \ - usecs = (uint64_t) tval.tv_usec + (uint64_t) tval.tv_usec * 1000000; \ - low = usecs & 0xffffffff; \ - high = usecs >> 32; \ +# define GETTIME(low,high) \ + { \ + struct timespec now; \ + uint64_t usecs; \ + clock_gettime (CLOCK_REALTIME, &now); \ + usecs = (uint64_t)now.tv_nsec / 1000 + (uint64_t)now.tv_sec * 1000000; \ + low = usecs & 0xffffffff; \ + high = usecs >> 32; \ } #endif diff --git a/sysdeps/mach/hurd/getitimer.c b/sysdeps/mach/hurd/getitimer.c index f332f0e681..0982357815 100644 --- a/sysdeps/mach/hurd/getitimer.c +++ b/sysdeps/mach/hurd/getitimer.c @@ -19,8 +19,9 @@ #include #include #include +#include -/* XXX Temporary cheezoid implementation; see __setitmr.c. */ +/* XXX Temporary cheezoid implementation; see setitimer.c. */ /* These are defined in __setitmr.c. */ extern spin_lock_t _hurd_itimer_lock; @@ -61,8 +62,12 @@ __getitimer (enum __itimer_which which, struct itimerval *value) } /* Get the time now. */ - if (__gettimeofday (&elapsed, NULL) < 0) - return -1; + { + time_value_t tv; + __host_get_time (__mach_host_self (), &tv); + elapsed.tv_sec = tv.seconds; + elapsed.tv_usec = tv.microseconds; + } /* Extract the current timer setting; and the time it was set, so we can calculate the time elapsed so far. */ diff --git a/sysdeps/mach/hurd/setitimer.c b/sysdeps/mach/hurd/setitimer.c index 34b433914c..2aab365c31 100644 --- a/sysdeps/mach/hurd/setitimer.c +++ b/sysdeps/mach/hurd/setitimer.c @@ -23,6 +23,7 @@ #include #include #include +#include #include /* XXX Temporary cheezoid implementation of ITIMER_REAL/SIGALRM. */ @@ -243,12 +244,12 @@ setitimer_locked (const struct itimerval *new, struct itimerval *old, if ((newval.it_value.tv_sec | newval.it_value.tv_usec) != 0 || old != NULL) { /* Calculate how much time is remaining for the pending alarm. */ - if (__gettimeofday (&now, NULL) < 0) - { - __spin_unlock (&_hurd_itimer_lock); - _hurd_critical_section_unlock (crit); - return -1; - } + { + time_value_t tv; + __host_get_time (__mach_host_self (), &tv); + now.tv_sec = tv.seconds; + now.tv_usec = tv.microseconds; + } elapsed = now; subtract_timeval (&elapsed, &_hurd_itimer_started); remaining = _hurd_itimerval.it_value; diff --git a/sysdeps/mach/hurd/times.c b/sysdeps/mach/hurd/times.c index 3aac803c51..56a0062cd5 100644 --- a/sysdeps/mach/hurd/times.c +++ b/sysdeps/mach/hurd/times.c @@ -42,7 +42,7 @@ __times (struct tms *tms) struct task_basic_info bi; struct task_thread_times_info tti; mach_msg_type_number_t count; - union { time_value_t tvt; struct timeval tv; } now; + time_value_t now; error_t err; count = TASK_BASIC_INFO_COUNT; @@ -65,10 +65,9 @@ __times (struct tms *tms) /* XXX This can't be implemented until getrusage(RUSAGE_CHILDREN) can be. */ tms->tms_cutime = tms->tms_cstime = 0; - if (__gettimeofday (&now.tv, NULL) < 0) - return -1; + __host_get_time (__mach_host_self (), &now); - return (clock_from_time_value (&now.tvt) + return (clock_from_time_value (&now) - clock_from_time_value (&bi.creation_time)); } weak_alias (__times, times) diff --git a/sysdeps/mach/nanosleep.c b/sysdeps/mach/nanosleep.c index 67caa3ea8a..36fb14598e 100644 --- a/sysdeps/mach/nanosleep.c +++ b/sysdeps/mach/nanosleep.c @@ -18,16 +18,26 @@ #include #include -#include #include #include +# define timespec_sub(a, b, result) \ + do { \ + (result)->tv_sec = (a)->tv_sec - (b)->tv_sec; \ + (result)->tv_nsec = (a)->tv_nsec - (b)->tv_nsec; \ + if ((result)->tv_nsec < 0) { \ + --(result)->tv_sec; \ + (result)->tv_nsec += 1000000000; \ + } \ + } while (0) + int __libc_nanosleep (const struct timespec *requested_time, - struct timespec *remaining) + struct timespec *remaining) { mach_port_t recv; - struct timeval before, after; + struct timespec before; + error_t err; if (requested_time->tv_sec < 0 || requested_time->tv_nsec < 0 @@ -43,20 +53,20 @@ __libc_nanosleep (const struct timespec *requested_time, recv = __mach_reply_port (); - if (remaining && __gettimeofday (&before, NULL) < 0) - return -1; - error_t err = __mach_msg (NULL, MACH_RCV_MSG|MACH_RCV_TIMEOUT|MACH_RCV_INTERRUPT, - 0, 0, recv, ms, MACH_PORT_NULL); + if (remaining != 0) + __clock_gettime (CLOCK_REALTIME, &before); + + err = __mach_msg (NULL, MACH_RCV_MSG|MACH_RCV_TIMEOUT|MACH_RCV_INTERRUPT, + 0, 0, recv, ms, MACH_PORT_NULL); __mach_port_destroy (mach_task_self (), recv); if (err == EMACH_RCV_INTERRUPTED) { - if (remaining && __gettimeofday (&after, NULL) >= 0) + if (remaining != 0) { - struct timeval req_time, elapsed, rem; - TIMESPEC_TO_TIMEVAL (&req_time, requested_time); - timersub (&after, &before, &elapsed); - timersub (&req_time, &elapsed, &rem); - TIMEVAL_TO_TIMESPEC (&rem, remaining); + struct timespec after, elapsed; + __clock_gettime (CLOCK_REALTIME, &after); + timespec_sub (&after, &before, &elapsed); + timespec_sub (requested_time, &elapsed, remaining); } errno = EINTR; diff --git a/sysdeps/mach/usleep.c b/sysdeps/mach/usleep.c index 3b79857c5d..578540d065 100644 --- a/sysdeps/mach/usleep.c +++ b/sysdeps/mach/usleep.c @@ -25,17 +25,12 @@ int usleep (useconds_t useconds) { mach_port_t recv; - struct timeval before, after; recv = __mach_reply_port (); - if (__gettimeofday (&before, NULL) < 0) - return -1; (void) __mach_msg (NULL, MACH_RCV_MSG|MACH_RCV_TIMEOUT|MACH_RCV_INTERRUPT, 0, 0, recv, (useconds + 999) / 1000, MACH_PORT_NULL); __mach_port_destroy (mach_task_self (), recv); - if (__gettimeofday (&after, NULL) < 0) - return -1; return 0; } diff --git a/sysdeps/posix/tempname.c b/sysdeps/posix/tempname.c index a248472540..692c336452 100644 --- a/sysdeps/posix/tempname.c +++ b/sysdeps/posix/tempname.c @@ -50,7 +50,7 @@ #include #include -#include +#include #include #include @@ -63,7 +63,6 @@ # define struct_stat64 struct stat # define __gen_tempname gen_tempname # define __getpid getpid -# define __gettimeofday gettimeofday # define __mkdir mkdir # define __open open # define __lxstat64(version, file, buf) lstat (file, buf) @@ -76,9 +75,9 @@ # else # define RANDOM_BITS(Var) \ { \ - struct timeval tv; \ - __gettimeofday (&tv, NULL); \ - (Var) = ((uint64_t) tv.tv_usec << 16) ^ tv.tv_sec; \ + struct timespec ts; \ + clock_gettime (CLOCK_REALTIME, &ts); \ + (Var) = ((uint64_t) tv.tv_nsec << 16) ^ tv.tv_sec; \ } #endif diff --git a/sysdeps/posix/timespec_get.c b/sysdeps/posix/timespec_get.c index 1fc18ac648..e3146da2d3 100644 --- a/sysdeps/posix/timespec_get.c +++ b/sysdeps/posix/timespec_get.c @@ -23,16 +23,10 @@ int timespec_get (struct timespec *ts, int base) { - switch (base) + if (base == TIME_UTC) { - case TIME_UTC: - if (__clock_gettime (CLOCK_REALTIME, ts) < 0) - return 0; - break; - - default: - return 0; + __clock_gettime (CLOCK_REALTIME, ts); + return base; } - - return base; + return 0; } diff --git a/sysdeps/pthread/aio_misc.c b/sysdeps/pthread/aio_misc.c index 6ff0132ecb..65b4b1ade8 100644 --- a/sysdeps/pthread/aio_misc.c +++ b/sysdeps/pthread/aio_misc.c @@ -614,13 +614,13 @@ handle_fildes_io (void *arg) something to arrive in it. */ if (runp == NULL && optim.aio_idle_time >= 0) { - struct timeval now; + struct timespec now; struct timespec wakeup_time; ++idle_thread_count; - __gettimeofday (&now, NULL); + __clock_gettime (CLOCK_REALTIME, &now); wakeup_time.tv_sec = now.tv_sec + optim.aio_idle_time; - wakeup_time.tv_nsec = now.tv_usec * 1000; + wakeup_time.tv_nsec = now.tv_nsec; if (wakeup_time.tv_nsec >= 1000000000) { wakeup_time.tv_nsec -= 1000000000; diff --git a/sysdeps/pthread/aio_suspend.c b/sysdeps/pthread/aio_suspend.c index ad654e1d08..bb324a5fe6 100644 --- a/sysdeps/pthread/aio_suspend.c +++ b/sysdeps/pthread/aio_suspend.c @@ -183,11 +183,11 @@ aio_suspend (const struct aiocb *const list[], int nent, { /* We have to convert the relative timeout value into an absolute time value with pthread_cond_timedwait expects. */ - struct timeval now; + struct timespec now; struct timespec abstime; - __gettimeofday (&now, NULL); - abstime.tv_nsec = timeout->tv_nsec + now.tv_usec * 1000; + __clock_gettime (CLOCK_REALTIME, &now); + abstime.tv_nsec = timeout->tv_nsec + now.tv_nsec; abstime.tv_sec = timeout->tv_sec + now.tv_sec; if (abstime.tv_nsec >= 1000000000) { diff --git a/sysdeps/unix/make-syscalls.sh b/sysdeps/unix/make-syscalls.sh index b49e6b6305..fe24bbc78f 100644 --- a/sysdeps/unix/make-syscalls.sh +++ b/sysdeps/unix/make-syscalls.sh @@ -27,7 +27,7 @@ # n: scalar buffer length (e.g., 3rd arg to read) # N: pointer to value/return scalar buffer length (e.g., 6th arg to recvfrom) # p: non-NULL pointer to typed object (e.g., any non-void* arg) -# P: optionally-NULL pointer to typed object (e.g., 2nd argument to gettimeofday) +# P: optionally-NULL pointer to typed object (e.g., 3rd argument to sigaction) # s: non-NULL string (e.g., 1st arg to open) # S: optionally-NULL string (e.g., 1st arg to acct) # v: vararg scalar (e.g., optional 3rd arg to open) From patchwork Fri Oct 25 12:08:24 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 177732 Delivered-To: patch@linaro.org Received: by 2002:a92:409a:0:0:0:0:0 with SMTP id d26csp3601493ill; Fri, 25 Oct 2019 05:09:06 -0700 (PDT) X-Google-Smtp-Source: APXvYqxsJVDTUZSR8aMeDCSouOFX9C7GD097kCX0w7kRPsPwvyVvrwGSv4xXqIpCTgNX566Gbkdy X-Received: by 2002:a17:906:3746:: with SMTP id e6mr3034137ejc.170.1572005346058; Fri, 25 Oct 2019 05:09:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572005346; cv=none; d=google.com; s=arc-20160816; b=vHNyZYTtqooGlqI0Q1Uch3pEFYe+KrD2lOdqkJ1GdQNjB4fi2GzJjuW5cqZgaxEt1g lMKGkH06DNMFgUJ8WKMcS4wAlO/+JIkUDgmHOumGEZmotvo+iw3qia0+QuuzOotfNcgG vd6lWjYdrin9/VqZmkDm8nhGMvGU6KFfObcS2fCI45gsrb3eSbTQxIlXdFLuA6OEIZIM hNGYaxQWMqn+GaIFagCPHrz/anjSpUwzhH0ZESAfCdmm39cAw4vzKg2QWwwy5eXrKDb9 Nww+IHA09nslEnUhN+jn4nc7q/Zf/8RiVhFDaJeGG9kG+zICuU/raQCcmnHSSYw6/XlN iYbQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:delivered-to:sender:list-help:list-post:list-archive :list-subscribe:list-unsubscribe:list-id:precedence:mailing-list :dkim-signature:domainkey-signature; bh=APXkdpaTZNm9nD89B8jZ5tBCK/W+zlQ/9JEkC0sr+qY=; b=QQ6htV8vj8IenvS5eQ0lsAT09o9tOlpvY7zccAr7s3N339392Q4JpmD437fwyOg/e4 v1fvtc/arGyTfZFUwWIALrmzNMx8QCUcs+atxbv+w3W3h7PS/Jj50zf8xJdMXw/2FJT2 vbc7najguqTMVI0mFm8+B9BGATctSzv6WheVCU+o9pbdD5T8+Q4l03MJPNJw6oShIN11 zbShz9xD+slouKZOxHmxSl9/bPj++UGM7MeuqnjNNdT950aHHqXai89cVapkRHQlqoKP mztjLLx0L81MYT+1vl/qdFyS8aE3+pluxFcQ1MH9q1vxjAAWAPF5YnoDgOg2Cr8QFL0W rfcQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=mCJW2gof; dkim=pass header.i=@linaro.org header.s=google header.b=jlnyXYnb; spf=pass (google.com: domain of libc-alpha-return-106282-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="libc-alpha-return-106282-patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id y42si1104751edd.191.2019.10.25.05.09.05 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 25 Oct 2019 05:09:06 -0700 (PDT) Received-SPF: pass (google.com: domain of libc-alpha-return-106282-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=mCJW2gof; dkim=pass header.i=@linaro.org header.s=google header.b=jlnyXYnb; spf=pass (google.com: domain of libc-alpha-return-106282-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="libc-alpha-return-106282-patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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=g14JUsYQdHm57IQnXk4faZOq0MDHboy X+DApW5WOj0zqrvB9HwPzULkJKzJO4GUk02lGUIw/ucfy5qJ1SIpGOyjYFsRYWhn Nx6qBMMTDYfHe6+YRxmh/oEk454Q+vJypbKpl6RbfbzS8sk3xXZBkC0uLU4qFio+ CgYLBysllrcE= 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=69ibD8x3LLDh5wUBXL1uYqlb/Es=; b=mCJW2 gofp3b+DcyPjDQSB4N72LXZYziW05tPmsk0IndsxY8f5NNsS+BJ+FKo5NAiGOaS0 8IiuirBgmMyWE5hUYlBXhVCo8rf82AoUm/QdsNvnyYKnxZNPyv01EPol6ng1xd+E xaEBNNcIB8jIbvlRg0ojGvQD12Cb6ILhPLzRsA= Received: (qmail 77139 invoked by alias); 25 Oct 2019 12:08:53 -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 77045 invoked by uid 89); 25 Oct 2019 12:08:52 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-21.4 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy=ports X-HELO: mail-qk1-f196.google.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=APXkdpaTZNm9nD89B8jZ5tBCK/W+zlQ/9JEkC0sr+qY=; b=jlnyXYnbWq95pYlYl2KNfTUDMoea2Rn+NgD4aUv6qWML4TGPraBPR6GC0gTc9S3Pon HurXjZkNM3gsyLN1iT29rrDu8RR+Ur577OnxquQdQ8En7sOSS5nHVi5f9lyfWWHtBPl5 OzxJN5Pz5sa+NF6fUDQkaSQ8xxLiWguLFobnLn5soOLiSO8l6b7s7tYKoU/T3LbDE3eg QEx2pK5wQbKSXvh/m2FDXx/53R1+GMIO/ZTOojeVbaDBF6gTRZ8+cZfHjHaJntWsjkKM 5QCyUEsT1MP+s7D3sSjxhJM8G+4ZVmz4rJgVuDANgBsst65p0YlLtC3MHgHdcCqbFjUl Bmyg== Return-Path: From: Adhemerval Zanella To: libc-alpha@sourceware.org Cc: Lukasz Majewski , Zack Weinberg Subject: [PATCH v2 03/11] Use clock_settime to implement stime; withdraw stime. Date: Fri, 25 Oct 2019 09:08:24 -0300 Message-Id: <20191025120832.27667-4-adhemerval.zanella@linaro.org> In-Reply-To: <20191025120832.27667-1-adhemerval.zanella@linaro.org> References: <20191025120832.27667-1-adhemerval.zanella@linaro.org> From: Zack Weinberg Use clock_settime to implement stime; withdraw stime. Changes from previous version: - Added a NEWS entry. -- Unconditionally, on all ports, use clock_settime to implement stime, not settimeofday or a direct syscall. Then convert stime into a compatibility symbol and remove its prototype from time.h. Checked on x86_64-linux-gnu, i686-linux-gnu, powerpc64le-linux-gnu, powerpc64-linux-gnu, powerpc-linux-gnu, and aarch64-linux-gnu. Reviewed-by: Adhemerval Zanella --- NEWS | 4 +++ sysdeps/unix/stime.c | 39 --------------------------- sysdeps/unix/sysv/linux/syscalls.list | 1 - time/stime.c | 25 ++++++++--------- time/time.h | 6 ----- 5 files changed, 17 insertions(+), 58 deletions(-) delete mode 100644 sysdeps/unix/stime.c -- 2.17.1 Reviewed-by: Lukasz Majewski diff --git a/NEWS b/NEWS index d7286841c9..8727b5e7f0 100644 --- a/NEWS +++ b/NEWS @@ -30,6 +30,10 @@ Deprecated and removed features, and other changes affecting compatibility: Request 25 to TS 18661-1, as applied for C2X. Existing binaries that pass floating-point arguments directly will continue to work. +* The obsolete function stime is no longer available to newly linked + binaries and it has been removed from header. This function + has been deprecated in favor of clock_settime. + Changes to build and runtime requirements: [Add changes to build and runtime requirements here] diff --git a/sysdeps/unix/stime.c b/sysdeps/unix/stime.c deleted file mode 100644 index b40c33454a..0000000000 --- a/sysdeps/unix/stime.c +++ /dev/null @@ -1,39 +0,0 @@ -/* Copyright (C) 1992-2019 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - . */ - -#include -#include /* For NULL. */ -#include -#include - -/* Set the system clock to *WHEN. */ - -int -stime (const time_t *when) -{ - struct timeval tv; - - if (when == NULL) - { - __set_errno (EINVAL); - return -1; - } - - tv.tv_sec = *when; - tv.tv_usec = 0; - return __settimeofday (&tv, (struct timezone *) 0); -} diff --git a/sysdeps/unix/sysv/linux/syscalls.list b/sysdeps/unix/sysv/linux/syscalls.list index cdcf6c127b..70b110979b 100644 --- a/sysdeps/unix/sysv/linux/syscalls.list +++ b/sysdeps/unix/sysv/linux/syscalls.list @@ -61,7 +61,6 @@ setfsgid EXTRA setfsgid i:i setfsgid setfsuid EXTRA setfsuid i:i setfsuid setpgid - setpgid i:ii __setpgid setpgid sigaltstack - sigaltstack i:PP __sigaltstack sigaltstack -stime - stime i:p stime sysinfo EXTRA sysinfo i:p __sysinfo sysinfo swapon - swapon i:si __swapon swapon swapoff - swapoff i:s __swapoff swapoff diff --git a/time/stime.c b/time/stime.c index a53c0e86ae..6ea3b6dcc1 100644 --- a/time/stime.c +++ b/time/stime.c @@ -15,23 +15,24 @@ License along with the GNU C Library; if not, see . */ -#include +#include + +#if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_31) + #include -#include /* Set the system clock to *WHEN. */ int -stime (const time_t *when) +attribute_compat_text_section +__stime (const time_t *when) { - if (when == NULL) - { - __set_errno (EINVAL); - return -1; - } - - __set_errno (ENOSYS); - return -1; + struct timespec ts; + ts.tv_sec = *when; + ts.tv_nsec = 0; + + return __clock_settime (CLOCK_REALTIME, &ts); } -stub_warning (stime) +compat_symbol (libc, __stime, stime, GLIBC_2_0); +#endif diff --git a/time/time.h b/time/time.h index 72a1078d2c..7daaacce16 100644 --- a/time/time.h +++ b/time/time.h @@ -175,12 +175,6 @@ extern int daylight; extern long int timezone; #endif -#ifdef __USE_MISC -/* Set the system time to *WHEN. - This call is restricted to the superuser. */ -extern int stime (const time_t *__when) __THROW; -#endif - /* Nonzero if YEAR is a leap year (every 4 years, except every 100th isn't, and every 400th is). */ From patchwork Fri Oct 25 12:08:25 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 177736 Delivered-To: patch@linaro.org Received: by 2002:a92:409a:0:0:0:0:0 with SMTP id d26csp3602583ill; Fri, 25 Oct 2019 05:09:52 -0700 (PDT) X-Google-Smtp-Source: APXvYqy7GUB6QEtsP0RTG/aihFoa/hLFDzL4Truidlb9TdYtnoR/mVm0Cn+rRMSOgJPvDM2NEzIy X-Received: by 2002:a05:6402:21d6:: with SMTP id bi22mr3493244edb.19.1572005392197; Fri, 25 Oct 2019 05:09:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572005392; cv=none; d=google.com; s=arc-20160816; b=GhL6kX09k3knmrNPMuv/Y7LD301D4uJa/dUtNYw/4Vz6yK5YtC9zg/58TUor1OsGvi AKWT/oc8gHI3n6YGH/ADgDoay6I1d8fVAtwaY8kfnf6ephmKCYEUVWqKix4NkR4QACTM ZGDNlk8j5p1I1gBdH3ccdyzkU+UcXWr69sNMHNNxP4z9W9UYKinWwdAXWYGjnZrd73hl A9fPZhEXWBpJdd06O2Sq2MCUrnXp/vo8m8ZAN8RTwZV7z7Ju7g7mbhJISP24gsIe513o EU3HCeO7VE7KLK1PY3JDyQQ9b+JzOaQtB/Hdifw+6QtRiivw3FZfSOS4GS4zRvRQRFS6 hqwA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature:delivered-to :sender:list-help:list-post:list-archive:list-subscribe :list-unsubscribe:list-id:precedence:mailing-list:dkim-signature :domainkey-signature; bh=27hDrog4+twgSWKgM/faGX3uQpqarOtDmQrLHSbvgK0=; b=0JDze6t8VjS5pv0MbfI1dQ2e9m5wPfempDI0Zeo7D56G4fBTUlgTfNXPfVxpKEqxq9 D+zILeUzdAZ38DSZxLpZn9dHClzsz1SKxmLplWWGiLSPkOz/8u4ejepgEKaRHx0SscWW 7qJIiTezqAFzIp2jiRiNoWyfN0iwSlL6iEI49uwfx70DlmL0SCNGnumAr5tlMLdlnDt/ WLU5jgzWKEGCTfNcxU7bP765uvbI4llHpwIwo6dsjIjvCgFQ3Lf2Mwy08z4A1Av7Lb1S 8c7eeW0VM6/Ql+0RsqQMMyhhpJjPdoVEo0oXYh7FWpwvkx6JZKqx8BAmivH9NSaD0bo0 j0CA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=H1bQC+jR; dkim=pass header.i=@linaro.org header.s=google header.b=VfxFL58S; spf=pass (google.com: domain of libc-alpha-return-106286-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="libc-alpha-return-106286-patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id j24si1028615edt.259.2019.10.25.05.09.51 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 25 Oct 2019 05:09:52 -0700 (PDT) Received-SPF: pass (google.com: domain of libc-alpha-return-106286-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=H1bQC+jR; dkim=pass header.i=@linaro.org header.s=google header.b=VfxFL58S; spf=pass (google.com: domain of libc-alpha-return-106286-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="libc-alpha-return-106286-patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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:mime-version:content-type:content-transfer-encoding; q=dns; s=default; b=UdbJF5hQ5ca4fNbCHRohy0+99E7a4nCwg53RJfWUdyx KtZpJnU/JEgVxcgEVJJ5K2PmMZWAQo1AvPVDMyP1Trl0dtbvvPcRwL3Qgrh9Bv3k KGFkFTduSczEzwA8WrxxpZZ65EztHEFFOtwhDwRUxMpIeqasKZoxWn9LayQz8g/U = 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:mime-version:content-type:content-transfer-encoding; s=default; bh=lL2VbeFn5PflmjnsOg5528z/i7A=; b=H1bQC+jRV+JBh+uck fmyFBuHCxHNB1hwrL9OQei7rqH18W4IN553IyJMFkuxmh+Ba99n1yS2HQZ5/4/co d3qznpoHx5GsWmJaeAY5ygaLh370LAxDxLc5rVkkmFMw5gMtqJKPLhNXAJi0eRjH WXKDz2//WHE4nNzrRAtUz+b5oc= Received: (qmail 77739 invoked by alias); 25 Oct 2019 12:08:56 -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 77647 invoked by uid 89); 25 Oct 2019 12:08:56 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-21.5 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy=shutdown, prepared, accident X-HELO: mail-qk1-f195.google.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=27hDrog4+twgSWKgM/faGX3uQpqarOtDmQrLHSbvgK0=; b=VfxFL58Szq9lJe15+g5NpKJo/FKghyroNmvI+lr+cP87iIBkDxX7sWI5o0mlT7ptjJ yqnowDpKY8498nfJUQWfy5D/OxhhGRoWPLWNtzFIYq0mmEsDMhGd8G1Q/I3gdldBwG/H Q87fETWjZyGns8ZckdM/2GvbwfA22nfdCiPX9K4Sowx7Z2wD81K90Bq+7pht9VhJpcw7 VDp6a5njT8gmYGsHeV0bOnIEOcHHd+4MNsZYh+pvJLZquaWh0c/5KqBjq62KeU4HNwlz RKHMlUil1RhxTQnpfIkPEleoIskI72L6kxJq9LwPEe7lH5rZ1iIm+pG1ILLBShl0nhTw E8HA== Return-Path: From: Adhemerval Zanella To: libc-alpha@sourceware.org Cc: Lukasz Majewski , Zack Weinberg Subject: [PATCH v2 04/11] Use clock_settime to implement settimeofday. Date: Fri, 25 Oct 2019 09:08:25 -0300 Message-Id: <20191025120832.27667-5-adhemerval.zanella@linaro.org> In-Reply-To: <20191025120832.27667-1-adhemerval.zanella@linaro.org> References: <20191025120832.27667-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 From: Zack Weinberg Use clock_settime to implement settimeofday. Changes from previous version: - Added a NEWS entry. -- Unconditionally, on all ports, use clock_settime to implement settimeofday. Remove sysdeps/unix/clock_settime.c, which implemented clock_settime by calling settimeofday; new OS ports must henceforth provide a real implementation of clock_settime. Hurd had a real implementation of settimeofday but not of clock_settime; this patch converts it into an implementation of clock_settime. It only supports CLOCK_REALTIME and microsecond resolution; Hurd/Mach does not appear to have any support for finer-resolution clocks. The vestigial "set time zone" feature of settimeofday complicates the generic settimeofday implementation a little. The only remaining uses of this feature that aren't just bugs, are using it to inform the Linux kernel of the offset between the hardware clock and UTC, on systems where the hardware clock doesn't run in UTC (usually because of dual-booting with Windows). There currently isn't any other way to do this. However, the callers that do this call settimeofday with _only_ the timezone argument non-NULL. Therefore, glibc's new behavior is: callers of settimeofday must supply one and only one of the two arguments. If both arguments are non-NULL, or both arguments are NULL, the call fails and sets errno to EINVAL. When only the timeval argument is supplied, settimeofday calls __clock_settime(CLOCK_REALTIME), same as stime. When only the timezone argument is supplied, settimeofday calls a new internal function called __settimezone. On Linux, only, this function will pass the timezone structure to the settimeofday system call. On all other operating systems, and on Linux architectures that don't define __NR_settimeofday, __settimezone is a stub that always sets errno to ENOSYS and returns -1. The settimeoday syscall is enabled on Linux by the flag COMPAT_32BIT_TIME, which is an option to either 32-bits ABIs or COMPAT builds (defined usually by 64-bit kernels that want to support 32-bit ABIs, such as x86). The idea to future 64-bit time_t only ABIs is to not provide settimeofday syscall. The same semantics are implemented for Linux/Alpha's GLIBC_2.0 compat symbol for settimeofday. There are no longer any internal callers of __settimeofday, so the internal prototype is removed. Checked on x86_64-linux-gnu, i686-linux-gnu, powerpc64le-linux-gnu, powerpc64-linux-gnu, powerpc-linux-gnu, and aarch64-linux-gnu. Reviewed-by: Adhemerval Zanella --- NEWS | 24 +++++++++ include/sys/time.h | 3 +- sysdeps/{unix => mach/hurd}/clock_settime.c | 51 ++++++++----------- sysdeps/unix/syscalls.list | 1 - .../unix/sysv/linux/alpha/osf_settimeofday.c | 16 ++++-- sysdeps/unix/sysv/linux/alpha/settimeofday.c | 22 ++++++++ sysdeps/unix/sysv/linux/alpha/syscalls.list | 1 - sysdeps/unix/sysv/linux/settimezone.c | 36 +++++++++++++ time/Makefile | 8 +-- time/settimeofday.c | 24 +++++++-- .../hurd/settimeofday.c => time/settimezone.c | 34 ++----------- 11 files changed, 147 insertions(+), 73 deletions(-) rename sysdeps/{unix => mach/hurd}/clock_settime.c (65%) create mode 100644 sysdeps/unix/sysv/linux/alpha/settimeofday.c create mode 100644 sysdeps/unix/sysv/linux/settimezone.c rename sysdeps/mach/hurd/settimeofday.c => time/settimezone.c (52%) -- 2.17.1 Reviewed-by: Lukasz Majewski diff --git a/NEWS b/NEWS index 8727b5e7f0..0b1476e745 100644 --- a/NEWS +++ b/NEWS @@ -34,6 +34,30 @@ Deprecated and removed features, and other changes affecting compatibility: binaries and it has been removed from header. This function has been deprecated in favor of clock_settime. +* The settimeofday function can still be used to set a system-wide time + zone when the operating system supports it. This is because the Linux + kernel reused the API, on some architectures, to describe a system-wide + time-zone-like offset between the software clock maintained by the kernel, + and the “RTC” clock that keeps time when the system is shut down. + + However, to reduce the odds of this offset being set by accident, + settimeofday can no longer be used to set the time and the offset + simultaneously. If both of its two arguments are non-null, the call + will fail (setting errno to EINVAL). + + Callers attempting to set this offset should also be prepared for the call + to fail and set errno to ENOSYS; this already happens on the Hurd and on + some Linux architectures. The Linux kernel maintainers are discussing a + more principled replacement for the reused API. After a replacement + becomes available, we will change settimeofday to fail with ENOSYS on all + platforms when its ‘tzp’ argument is not a null pointer. + + Note that settimeofday itself is obsolescent according to POSIX. + Programs that set the system time should use clock_settime and/or + the adjtime family of functions instead. We may also cease to make + settimeofday available to newly linked binaries after there is a + replacement for Linux’s time-zone-like offset API. + Changes to build and runtime requirements: [Add changes to build and runtime requirements here] diff --git a/include/sys/time.h b/include/sys/time.h index 57208afa82..c0e30e70fb 100644 --- a/include/sys/time.h +++ b/include/sys/time.h @@ -24,8 +24,7 @@ extern int __gettimeofday (struct timeval *__tv, struct timezone *__tz); libc_hidden_proto (__gettimeofday) libc_hidden_proto (gettimeofday) -extern int __settimeofday (const struct timeval *__tv, - const struct timezone *__tz) +extern int __settimezone (const struct timezone *__tz) attribute_hidden; extern int __adjtime (const struct timeval *__delta, struct timeval *__olddelta); diff --git a/sysdeps/unix/clock_settime.c b/sysdeps/mach/hurd/clock_settime.c similarity index 65% rename from sysdeps/unix/clock_settime.c rename to sysdeps/mach/hurd/clock_settime.c index 18d7c99864..02239c097a 100644 --- a/sysdeps/unix/clock_settime.c +++ b/sysdeps/mach/hurd/clock_settime.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1999-2019 Free Software Foundation, Inc. +/* Copyright (C) 1991-2019 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -17,38 +17,31 @@ #include #include -#include +#include +#include #include -/* Set CLOCK to value TP. */ +/* Set the current time of day. + This call is restricted to the super-user. */ int -__clock_settime (clockid_t clock_id, const struct timespec *tp) +__clock_settime (clockid_t clock_id, const struct timespec *ts) { - int retval = -1; - - /* Make sure the time cvalue is OK. */ - if (tp->tv_nsec < 0 || tp->tv_nsec >= 1000000000) - { - __set_errno (EINVAL); - return -1; - } - - switch (clock_id) - { - case CLOCK_REALTIME: - { - struct timeval tv; - TIMESPEC_TO_TIMEVAL (&tv, tp); - retval = __settimeofday (&tv, NULL); - } - break; - - default: - __set_errno (EINVAL); - break; - } - - return retval; + error_t err; + mach_port_t hostpriv; + time_value_t tv; + + if (clock_id != CLOCK_REALTIME) + return __hurd_fail (EINVAL); + + err = __get_privileged_ports (&hostpriv, NULL); + if (err) + return __hurd_fail (EPERM); + + TIMESPEC_TO_TIME_VALUE (&tv, ts); + err = __host_set_time (hostpriv, tv); + __mach_port_deallocate (__mach_task_self (), hostpriv); + + return __hurd_fail (err); } libc_hidden_def (__clock_settime) diff --git a/sysdeps/unix/syscalls.list b/sysdeps/unix/syscalls.list index 61e5360b4d..5fedd5733d 100644 --- a/sysdeps/unix/syscalls.list +++ b/sysdeps/unix/syscalls.list @@ -76,7 +76,6 @@ setreuid - setreuid i:ii __setreuid setreuid setrlimit - setrlimit i:ip __setrlimit setrlimit setsid - setsid i: __setsid setsid setsockopt - setsockopt i:iiibn setsockopt __setsockopt -settimeofday - settimeofday i:PP __settimeofday settimeofday setuid - setuid i:i __setuid setuid shutdown - shutdown i:ii shutdown sigaction - sigaction i:ipp __sigaction sigaction diff --git a/sysdeps/unix/sysv/linux/alpha/osf_settimeofday.c b/sysdeps/unix/sysv/linux/alpha/osf_settimeofday.c index fb2a36df19..914f5ac57b 100644 --- a/sysdeps/unix/sysv/linux/alpha/osf_settimeofday.c +++ b/sysdeps/unix/sysv/linux/alpha/osf_settimeofday.c @@ -32,9 +32,19 @@ attribute_compat_text_section __settimeofday_tv32 (const struct timeval32 *tv32, const struct timezone *tz) { - struct timeval tv; - tv32_to_tv64 (&tv, tv32); - return __settimeofday (&tv, tz); + if (__glibc_unlikely (tz != 0)) + { + if (tv32 != 0) + { + __set_errno (EINVAL); + return -1; + } + return __settimezone (tz); + } + + struct timespec ts; + tv32_to_ts64 (&ts, tv32); + return __clock_settime (CLOCK_REALTIME, &ts); } compat_symbol (libc, __settimeofday_tv32, settimeofday, GLIBC_2_0); diff --git a/sysdeps/unix/sysv/linux/alpha/settimeofday.c b/sysdeps/unix/sysv/linux/alpha/settimeofday.c new file mode 100644 index 0000000000..36a6901e4e --- /dev/null +++ b/sysdeps/unix/sysv/linux/alpha/settimeofday.c @@ -0,0 +1,22 @@ +/* settimeofday -- Set the current time of day. Linux/Alpha/tv64 version. + Copyright (C) 2019 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +/* We can use the generic implementation, but we have to override its + default symbol version. */ +#define VERSION_settimeofday GLIBC_2.1 +#include