From patchwork Mon Nov 11 16:34:54 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: 179096 Delivered-To: patch@linaro.org Received: by 2002:ac9:3c86:0:0:0:0:0 with SMTP id w6csp6574559ocf; Mon, 11 Nov 2019 08:35:13 -0800 (PST) X-Google-Smtp-Source: APXvYqw9sdTKf7a1MLtX0UGzTRgEjgUD80rbqK9Jc2C/wIMwprsE0wUNskGpbeB9VszBOGE+Jalj X-Received: by 2002:a17:906:411:: with SMTP id d17mr23373289eja.299.1573490113480; Mon, 11 Nov 2019 08:35:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573490113; cv=none; d=google.com; s=arc-20160816; b=C/Zae2Fr+0Y7ym1PdFXcemh793zk9hgu/Nt6rQRVhZ7B6aFCuLgaziMlGA08CoNj5j tpZiAuee0LUSlaeXEbSiujRsL8ZVxhHSyiJ17t3xCIXEB9fQZbMQ6+Dzj26YmrO/W1b1 sw9NWnFWXMoKej3oD+CAQW8+/HukP7GYk6u7DoR7otGmryXPfyNlKLv7BpyZQ8Jj0xNC 7lAng7S6xyiuNycd/0wUat6wwrosaKyPCoPMczVGVXvnFBo2c3PIRkpbG8CL0YCtdrPN 4mEiM753tXx+rMH1RKSUflhuICBnpOKlj1s7TRkn74g3sgIVJq4B9F9sp4dV9w8hdv43 HFIw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:date:subject: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=iTDwha9L8tMePsRHFypZQz/Kj2GcogjHbFhxY38pE74=; b=xQyxdiWPAHNYtU5eJyfPeviLqtXoDSBP4MnUdFHktFxkOB0ZgscJarauGu/binl6HK 4QkRw3BFtHKUtLdeZDxBvWksMfKS2NlMDWBFXMoxVjyiR7r9vsWo/zlvxQ1D+9tzyzf9 tVm5LezCtzx/fssMXW20UkZf2ZXPjzTCUVkneLoValzithYfCcUyOoUGiXQrb2jVLnlJ tGTddpHNf9IQGymLpMDV3m+v/dpJo8qL0cZ8HX9ixOCLHAWx12xsfZbRsgvwbH4MO0Ol oPgBcjKDxCi4erke4Sw6L2uPXpvIhI/M/BTBjv9nMt1bJEBZc8bNa6YK8H5DL1aUkPxY 1s0w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=DzDuFdBE; dkim=pass header.i=@linaro.org header.s=google header.b=VcLBfgQz; spf=pass (google.com: domain of libc-alpha-return-106893-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="libc-alpha-return-106893-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 ks2si9954153ejb.396.2019.11.11.08.35.12 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 11 Nov 2019 08:35:13 -0800 (PST) Received-SPF: pass (google.com: domain of libc-alpha-return-106893-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=DzDuFdBE; dkim=pass header.i=@linaro.org header.s=google header.b=VcLBfgQz; spf=pass (google.com: domain of libc-alpha-return-106893-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="libc-alpha-return-106893-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:subject:date:message-id; q=dns; s= default; b=KCFbjSnXSZOM8TBIyjxJF7ta+YYmEtab+ewCRIiehKPSpO55aHdyN ercJOhM7XJTmZtQSAb7OnRFnBUParbTBsgA5tznooemmGPPoqAh3ilsngnASk3+4 vrb6CqPITLGt27RmChQM8AcEQnk2dYJQYy9w9+TPSeMiScx+aS6J9Q= 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:subject:date:message-id; s=default; bh=/DxJFk6JQi1Ee7u9Y/VdOFaVDJw=; b=DzDuFdBEgFdiWezMCUu3RoksrXJJ kJOhiGgAXs3DOLI36toydJsPhbTflIFo+XsTm9OKK4M23qhLigntloV0SXMS5A6i JuUzmjcyNESomIRW9bOrl7wAY4zGQBosXEGsaAA9SF6JR3Kh9E+e7xKEAir2DV1o 9mt+es0occvWc3w= Received: (qmail 106247 invoked by alias); 11 Nov 2019 16:35:02 -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 106239 invoked by uid 89); 11 Nov 2019 16:35:02 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-21.6 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 autolearn=ham version=3.3.1 spammy= X-HELO: mail-qt1-f195.google.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id; bh=iTDwha9L8tMePsRHFypZQz/Kj2GcogjHbFhxY38pE74=; b=VcLBfgQzpeDe4syM2MVHrgHrwq6ycabm+cgCwTWBAh/bsGOk4gLY1D0BLArIRXWmEn JptEP0jl+k1v1XolV8V88SBOa2g/gYQ2HgDTzWDcRnbjseUHGsxqrAfxJAyhbAr2GCGn 9R1jHHzDT14WJK77X6SlBogVM0zaak9wP04226+2Po8GzRv/bqvATOn87WX/WaRtWN9H 2t32wznx2/iqCSOtKGB6rFARuTw+4+BSf+RNjQLqFapNbFWTF7bAdBtQRo+vxfT58bB4 SvcfjxJpoh2LrkREjWBjtaV+H15n1uT4vhCVaXlZQlj0mi9E4o6ErqNqsJrgvqwt1J+U OrSg== Return-Path: From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH] Fix clock_nanosleep when interrupted by a signal Date: Mon, 11 Nov 2019 13:34:54 -0300 Message-Id: <20191111163454.22535-1-adhemerval.zanella@linaro.org> This patch fixes the time64 support (added by 2e44b10b42d) where it misses the remaining argument updated if __NR_clock_nanosleep returns EINTR. Checked on i686-linux-gnu on 4.15 kernel (no time64 support) and on 5.3 kernel (with time64 support). Change-Id: Ie2d3ffdcf52a9a4f1e49466fd6abece31a7c7e69 --- sysdeps/unix/sysv/linux/clock_nanosleep.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) -- 2.17.1 diff --git a/sysdeps/unix/sysv/linux/clock_nanosleep.c b/sysdeps/unix/sysv/linux/clock_nanosleep.c index 60c61ee277..fc47c58ee7 100644 --- a/sysdeps/unix/sysv/linux/clock_nanosleep.c +++ b/sysdeps/unix/sysv/linux/clock_nanosleep.c @@ -52,13 +52,10 @@ __clock_nanosleep_time64 (clockid_t clock_id, int flags, const struct __timespec r = INTERNAL_SYSCALL_CANCEL (clock_nanosleep_time64, err, clock_id, flags, req, rem); - if (r == 0 || errno != ENOSYS) - { - return (INTERNAL_SYSCALL_ERROR_P (r, err) - ? INTERNAL_SYSCALL_ERRNO (r, err) : 0); - } + if (r != -ENOSYS) + return (INTERNAL_SYSCALL_ERROR_P (r, err) + ? INTERNAL_SYSCALL_ERRNO (r, err) : 0); # endif /* __NR_clock_nanosleep_time64 */ - struct timespec ts32, tr32; if (! in_time_t_range (req->tv_sec)) { @@ -66,11 +63,12 @@ __clock_nanosleep_time64 (clockid_t clock_id, int flags, const struct __timespec return -1; } - ts32 = valid_timespec64_to_timespec (*req); + struct timespec tr32; + struct timespec ts32 = valid_timespec64_to_timespec (*req); r = INTERNAL_SYSCALL_CANCEL (clock_nanosleep, err, clock_id, flags, &ts32, &tr32); - if (r == 0 && rem != NULL) + if (r == -EINTR && rem != NULL && (flags & TIMER_ABSTIME) == 0) *rem = valid_timespec_to_timespec64 (tr32); #endif /* __ASSUME_TIME64_SYSCALLS */ @@ -89,7 +87,7 @@ __clock_nanosleep (clockid_t clock_id, int flags, const struct timespec *req, treq64 = valid_timespec_to_timespec64 (*req); r = __clock_nanosleep_time64 (clock_id, flags, &treq64, &trem64); - if (r == 0 && rem != NULL) + if (r == EINTR && rem != NULL && (flags & TIMER_ABSTIME) == 0) *rem = valid_timespec64_to_timespec (trem64); return r;