From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-Status: No, score=-4.1 required=3.0 tests=AWL,BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_PASS,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id 75E0A1F66E for ; Sat, 15 Aug 2020 18:12:10 +0000 (UTC) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 2C9F23857C61; Sat, 15 Aug 2020 18:12:09 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2C9F23857C61 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1597515129; bh=kND0xmDjNEnd7/jnpuXeMM8OpdaKT5c6xjrt3hzOIq8=; h=References:In-Reply-To:Date:Subject:To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=fSY+hZxXid2lWiTE0lIOv4+bcZRYs2Bh3RAZcbFZZUkYsXVIdC+RKCWd7MEWQsmcv oCYAWgwtE1enVwfLj5YLxMcIjalD/y/WkxBrdb9r48ywUyaOhY1a/bCRbyXiPjkrZ1 8Er9H2ryKr9f6oibz7a2RYD0RaMUqcx0g4KFqLno= Received: from mail-il1-x142.google.com (mail-il1-x142.google.com [IPv6:2607:f8b0:4864:20::142]) by sourceware.org (Postfix) with ESMTPS id F40F93857C4A for ; Sat, 15 Aug 2020 18:12:05 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org F40F93857C4A Received: by mail-il1-x142.google.com with SMTP id c6so11109102ilo.13 for ; Sat, 15 Aug 2020 11:12:05 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=kND0xmDjNEnd7/jnpuXeMM8OpdaKT5c6xjrt3hzOIq8=; b=S7N9v3loG9vzqzPuUy535oL4ZLJB0PcQL8VOzWoaIor8n6fCaqBfZzvrzHPSHDlqW1 XY6jbOi9w2cNudj/KVI+4HJheo3e8W++fdkgNadwqiDBanaH8NuqNmz1RZRC5/XXjEUV UDmC4RUCUuLsss8Zutdxxy+en1fn9Unwkgr+ATb0rIFFTH/ug6ToUv5jmz9MzNjJ6AdA bjYBhtb8YG7hA/tsnJ7Y740cgYq9L7yjdo8H75/v4kfxQJ5/sDxhRxj7Ry2Y2YyXugug 8fWGjUtFeimXr8mHP7fZuYuhcmWB2Q/aH5JTK7geUsH8usmSOauoazKHhRhtXOZ7awVL PqfA== X-Gm-Message-State: AOAM532fL0GNLSHRO5ahNPPJUdPw9yGhF3qmUkkuh8eAJQPrlb26O9l7 UQsGUPzXlSV4Xx/O1HjdBm09xuaQLRTbO6ZhVOc= X-Google-Smtp-Source: ABdhPJyqsKYksb0pqmnTFN8cNeSRJG3pjTe2VPt9AYBHSxgP/h0z32ebWtb34mk3DgCV3wK1q+/Q4/UbUUKCf3pOPQo= X-Received: by 2002:a92:bf0c:: with SMTP id z12mr7155800ilh.151.1597515125312; Sat, 15 Aug 2020 11:12:05 -0700 (PDT) MIME-Version: 1.0 References: <20200812102205.14816-1-lukma@denx.de> In-Reply-To: <20200812102205.14816-1-lukma@denx.de> Date: Sat, 15 Aug 2020 11:11:29 -0700 Message-ID: Subject: [PATCH] nptl: Handle NULL abstime [BZ #26394] To: Lukasz Majewski Content-Type: multipart/mixed; boundary="00000000000091d9cd05acee79c3" X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: "H.J. Lu via Libc-alpha" Reply-To: "H.J. Lu" Cc: Florian Weimer , GNU C Library , Andreas Schwab , Stepan Golosunov , Alistair Francis , Joseph Myers Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" --00000000000091d9cd05acee79c3 Content-Type: text/plain; charset="UTF-8" On Wed, Aug 12, 2020 at 3:22 AM Lukasz Majewski wrote: > > The pthread_clockjoin_np and pthread_timedjoin_np have been converted to > support 64 bit time. > > This change introduces new futex_timed_wait_cancel64 function in > ./sysdeps/nptl/futex-internal.h, which uses futex_time64 where possible > and tries to replace low-level preprocessor macros from > lowlevellock-futex.h > The pthread_{timed|clock}join_np only accept absolute time. Moreover, > there is no need to check for NULL passed as *abstime pointer as > clockwait_tid() always passes struct __timespec64. > > For systems with __TIMESIZE != 64 && __WORDSIZE == 32: > - Conversions between 64 bit time to 32 bit are necessary > - Redirection to __pthread_{clock|timed}join_np64 will provide support > for 64 bit time > > Build tests: > ./src/scripts/build-many-glibcs.py glibcs > > Run-time tests: > - Run specific tests on ARM/x86 32bit systems (qemu): > https://github.com/lmajewski/meta-y2038 and run tests: > https://github.com/lmajewski/y2038-tests/commits/master > > Above tests were performed with Y2038 redirection applied as well as without > to test the proper usage of both __pthread_{timed|clock}join_np64 and > __pthread_{timed|clock}join_np. > > --- > Changes for v2: > - Update the commit message > > Changes for v3: > - Use const qualifier for futex_timed_wait_cancel64() timeout parameter > - Use INTERNAL_SYSCALL_CALL macro instead of INTERNAL_SYSCALL > - Use LIBC_CANCEL_{RESET|ASYNC} macro instead of CANCEL_{RESET|ASYNC} > - Add switch clause with listing possible error values returned by > futex{_time64} syscall > > Changes for v4: > > - Update comment when -EOVERFLOW is returned from futex syscall > - Use INTERNAL_SYSCALL_CANCELL instead of INTERNAL_SYSCALL_CALL > (with or without LIBC_CANCEL_ASYNC/LIBC_CANCEL_RESET) to make > the code smaller as it hides cancellation points handling. > > Changes for v5: > > - Refactor the code to avoid using goto > diff --git a/nptl/pthread_clockjoin.c b/nptl/pthread_clockjoin.c > index a3e7f37e3b..3cd780f688 100644 > --- a/nptl/pthread_clockjoin.c > +++ b/nptl/pthread_clockjoin.c > @@ -16,14 +16,27 @@ > License along with the GNU C Library; if not, see > . */ > > +#include > #include "pthreadP.h" > > int > -__pthread_clockjoin_np (pthread_t threadid, void **thread_return, > - clockid_t clockid, > - const struct timespec *abstime) > +__pthread_clockjoin_np64 (pthread_t threadid, void **thread_return, > + clockid_t clockid, const struct __timespec64 *abstime) > { > return __pthread_clockjoin_ex (threadid, thread_return, > clockid, abstime, true); > } > + > +#if __TIMESIZE != 64 > +libc_hidden_def (__pthread_clockjoin_np64) > + > +int > +__pthread_clockjoin_np (pthread_t threadid, void **thread_return, > + clockid_t clockid, const struct timespec *abstime) > +{ > + struct __timespec64 ts64 = valid_timespec_to_timespec64 (*abstime); > + > + return __pthread_clockjoin_np64 (threadid, thread_return, clockid, &ts64); > +} > +#endif > weak_alias (__pthread_clockjoin_np, pthread_clockjoin_np) > +#if __TIMESIZE != 64 > +libc_hidden_def (__pthread_timedjoin_np64) > + > +int > +__pthread_timedjoin_np (pthread_t threadid, void **thread_return, > + const struct timespec *abstime) > +{ > + struct __timespec64 ts64 = valid_timespec_to_timespec64 (*abstime); > + > + return __pthread_timedjoin_np64 (threadid, thread_return, &ts64); > +} > +#endif > weak_alias (__pthread_timedjoin_np, pthread_timedjoin_np) This caused: https://sourceware.org/bugzilla/show_bug.cgi?id=26394 I am testing this. -- H.J. --00000000000091d9cd05acee79c3 Content-Type: application/x-patch; name="0001-nptl-Handle-NULL-abstime-BZ-26394.patch" Content-Disposition: attachment; filename="0001-nptl-Handle-NULL-abstime-BZ-26394.patch" Content-Transfer-Encoding: base64 Content-ID: X-Attachment-Id: f_kdvz6wo00 RnJvbSBmYTFmOTc2ODBmY2EyOTBhMzc4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