From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 125169 invoked by alias); 26 Feb 2020 16:07:50 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 125141 invoked by uid 89); 26 Feb 2020 16:07:49 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-5.7 required=5.0 tests=AWL,BAYES_00,KAM_SHORT,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=unavailable version=3.3.1 spammy=UD:tv_nsec, H*MI:sk:1285559, timeval, UD:tv_sec X-HELO: us-smtp-1.mimecast.com Received: from us-smtp-delivery-1.mimecast.com (HELO us-smtp-1.mimecast.com) (207.211.31.120) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 26 Feb 2020 16:07:43 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1582733262; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=KCkmGjEVj9fk7iHVBOgt6lQjjreX9BzejhLM/4j6T2M=; b=TBnWvk8Kgxlg3CLzbZwBc2Gl5eGjaO0a1XrMfHEVEfaBYEGb2UMe+76i47MfOzu8RnFmvo voV/RXrnv5bVprq1beJ5ltF4BvluxpvfqUMj3/EJ9XldTgawqgvpKjIFEMVmTFb+Fc5TTb mF500+8nX71uKam/LZNKpQHi8xgNQj0= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-113-pnlB4jpDORuON8SPYEUobA-1; Wed, 26 Feb 2020 11:07:31 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B33A218B9FC8; Wed, 26 Feb 2020 16:07:30 +0000 (UTC) Received: from localhost (unknown [10.33.36.26]) by smtp.corp.redhat.com (Postfix) with ESMTP id 470125C545; Wed, 26 Feb 2020 16:07:30 +0000 (UTC) Date: Wed, 26 Feb 2020 16:07:00 -0000 From: Jonathan Wakely To: Thomas Rodgers Cc: gcc-patches@gcc.gnu.org, libstdc++@gcc.gnu.org Subject: Re: [PATCH] Add c++2a binary_semaphore Message-ID: <20200226160729.GU9441@redhat.com> References: <381004109.5930741.1582008200673.JavaMail.zimbra@redhat.com> <1291008602.5930779.1582008369882.JavaMail.zimbra@redhat.com> <20200218142541.GD9441@redhat.com> <901947645.6192437.1582168716749.JavaMail.zimbra@redhat.com> <1285559088.6683965.1582599187278.JavaMail.zimbra@redhat.com> MIME-Version: 1.0 In-Reply-To: <1285559088.6683965.1582599187278.JavaMail.zimbra@redhat.com> X-Clacks-Overhead: GNU Terry Pratchett X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: quoted-printable Content-Disposition: inline X-SW-Source: 2020-02/txt/msg01483.txt.bz2 On 24/02/20 21:53 -0500, Thomas Rodgers wrote: >+ bool >+ _S_futex_wait_until(int* __addr, int __val, >+ bool __has_timeout =3D false, >+ std::chrono::seconds __s =3D std::chrono::seconds::zero(), >+ std::chrono::nanoseconds __ns =3D std::chrono::nanoseconds::zero()) >+ { >+ if (!__has_timeout) >+ { >+ syscall (SYS_futex, __addr, 0, __val, nullptr); >+ // Can't do anything about an error here except abort, so ignore it. >+ } >+ else >+ { >+ struct timeval __tv; >+ gettimeofday(&__tv, NULL); >+ struct timespec __rt; >+ __rt.tv_sec =3D __s.count() - __tv.tv_sec; >+ __rt.tv_nsec =3D __ns.count() - __tv.tv_usec * 1000; >+ if (__rt.tv_nsec < 0) >+ { >+ __rt.tv_nsec +=3D 1000000000; >+ --__rt.tv_sec; >+ } >+ if (__rt.tv_sec < 0) >+ return false; >+ >+ if (syscall (SYS_futex, __addr, 0, __val, &__rt) =3D=3D -1) This syscall has the same problem as https://gcc.gnu.org/PR93421 so we should avoid introducing a new instance of the bug.