From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/10491 Path: news.gmane.org!.POSTED!not-for-mail From: Daniel Sabogal Newsgroups: gmane.linux.lib.musl.general Subject: [PATCH v2] fix clock_nanosleep error case Date: Sat, 17 Sep 2016 12:05:45 -0400 Message-ID: <20160917160545.4348-1-dsabogalcc@gmail.com> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: blaine.gmane.org X-Trace: blaine.gmane.org 1474128407 4028 195.159.176.226 (17 Sep 2016 16:06:47 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sat, 17 Sep 2016 16:06:47 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-10504-gllmg-musl=m.gmane.org@lists.openwall.com Sat Sep 17 18:06:44 2016 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by blaine.gmane.org with smtp (Exim 4.84_2) (envelope-from ) id 1blI8Z-0000ah-O6 for gllmg-musl@m.gmane.org; Sat, 17 Sep 2016 18:06:43 +0200 Original-Received: (qmail 30326 invoked by uid 550); 17 Sep 2016 16:06:43 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Original-Received: (qmail 30294 invoked from network); 17 Sep 2016 16:06:42 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:subject:date:message-id; bh=y04++A9ng6y8txovouQrXSLpYbZ8rL81LlStpxKRCWM=; b=IiIl5tphME4aS3q/xEzwQ8oDf6kh2hcOc9co+V/NN+OjnCuTucaXpiKayGOf2ni40x kD0gy5DL4pAIpZIuIZyXNYN+Kx/uKl1PyT7iEIik9cEQ48LzTK6w7yrQq78MpXjY6UXV Sy5lr6eEAN7A6Z1V7hDxkBeEMoGD02rh5TDqcLNlZEuoTl4F/b+mCs24xnjFFfSiMlAL IOY6ja/aSLHVpbzrjEcNnKWZIO4wc4veXR7C+ER1ruNd39hCNnhG9ae+iOJ7NrR6XM+C Y+wDxEd47/CbWOlSFZ5lkcSuN4VQ9L7GlsS6bHriv8YG6dvCOmc23dFaFCFcLmlCuQfi tZrQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:subject:date:message-id; bh=y04++A9ng6y8txovouQrXSLpYbZ8rL81LlStpxKRCWM=; b=YEYAikE7l9xqvKpYXmKu7qQFPanQOlRjrY9h+zaIM+HWVoLXhg96QLF7E6EKCw4cJU XucatrdAeJGNGUDq5gnBQ8omJ7wV01d853VDobsSpO483Ur30t15S08xmNf5knyyL7AT GntwSq/zl1o3Dd6e7lHde4c/cFLlDr4jAu4TZujJ8XKQiU510jS/aYK3C5Y6fTSB0kCM 8cBq8wnauwELX1G5XWzPVAhuIjnGxlGl4dvcIrxCX/6D/+J7ZyfDwIehskILL4FvzemA 12uLjhf15u7lh0ppY/YsM1RPqnmgamPGEXBSCyk1L5f6e1hiS6NpM3UaB4pIGInwrbGT hjRQ== X-Gm-Message-State: AE9vXwOIuSWJ0eCPYLSIc58qV61Cmf95BvSUVGJ9QtbS/B2Ou/BUBNjgVmDd3xFGYJhwzw== X-Received: by 10.202.48.22 with SMTP id w22mr20063096oiw.59.1474128390462; Sat, 17 Sep 2016 09:06:30 -0700 (PDT) X-Mailer: git-send-email 2.10.0 Xref: news.gmane.org gmane.linux.lib.musl.general:10491 Archived-At: posix requires that EINVAL be returned if the first parameter specifies the cpu-time clock of the calling thread (CLOCK_THREAD_CPUTIME_ID). linux returns ENOTSUP instead so we handle this. --- Applied Szabolcs' suggestion for remapping the return value. clock_nanosleep is required to be a cancellation point. --- src/time/clock_nanosleep.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/time/clock_nanosleep.c b/src/time/clock_nanosleep.c index ec87b9e..9e4d9f1 100644 --- a/src/time/clock_nanosleep.c +++ b/src/time/clock_nanosleep.c @@ -1,8 +1,10 @@ #include +#include #include "syscall.h" #include "libc.h" int clock_nanosleep(clockid_t clk, int flags, const struct timespec *req, struct timespec *rem) { - return -__syscall_cp(SYS_clock_nanosleep, clk, flags, req, rem); + int r = -__syscall_cp(SYS_clock_nanosleep, clk, flags, req, rem); + return clk == CLOCK_THREAD_CPUTIME_ID ? EINVAL : r; } -- 2.10.0