From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 658DF385416C for ; Fri, 21 Oct 2022 09:58:47 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 658DF385416C Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1666346326; 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: in-reply-to:in-reply-to:references:references; bh=5fDSLGI/Y38z+cIw0juaJYeF3r9JfZWMl6hdWT1uHt0=; b=GQA53YtODWZi4YrmlnBkPd+pmDStbYmTIVdlH779DZ036AA5dC7n3LvLdwtPLRSM/cnKMo SBtxDU1eTGctoj3ZcKTCUta/3inRD3P2Q6yCdvMpBG5lAVuF4nhWdWQah8nVVYtYx/5CGW BkVahd6m/b/Zi57KkHRm5S04wC9oKDE= Received: from mail-qv1-f70.google.com (mail-qv1-f70.google.com [209.85.219.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-515-X2WNjvIPMIazyN1TYhYgaQ-1; Fri, 21 Oct 2022 05:58:45 -0400 X-MC-Unique: X2WNjvIPMIazyN1TYhYgaQ-1 Received: by mail-qv1-f70.google.com with SMTP id ny15-20020a056214398f00b004b9152f4b53so1926014qvb.17 for ; Fri, 21 Oct 2022 02:58:45 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=5fDSLGI/Y38z+cIw0juaJYeF3r9JfZWMl6hdWT1uHt0=; b=fz2edjk2auJS/y6HfP03JnIaf8hlv2jIDQDoXeFW7Bj2mqHO4jccLcHPbH20pVRx/h +v36JT+LAN+8d0/XpycYFoXw+Vy+TiQOxXcct91AaDxx2fC8Se2yFGGasx0pgKdbR9LW sT0EDj9g161PnPWzs3Yss6aNcFeCMxc6otgdK3dIfzfPUVTwqQI+Hu961qCx7SiyCAwI c9H/a03pvAAKLd3nmaonU2BdcjZTdNWVFzDL6/TwniKWnwHdv6lAqhT3Cx3zNFhQvCEr RpkQkIsuV8MT3fNwKCjPCtT6+sqcaihP0yAtrSiTEUNtbJl1krdgUeZnifzYyGxZQdyT Jhag== X-Gm-Message-State: ACrzQf3QsGsD0OFICoW4N27rIWSkv2SBAFsjakq+8lymLvwVQRJFWe6x v0VWva4od6fGAN9OCmLUIIxB1BoNIvAH80usoOO9g1kaWH47MLHE6rqZVQxCv4uM7BsGq3ZF/To 0kisaWP7MMp6Ckt7BqZj0VMtp9akUIaw= X-Received: by 2002:a05:622a:15cf:b0:39c:4c04:107d with SMTP id d15-20020a05622a15cf00b0039c4c04107dmr14982075qty.122.1666346325340; Fri, 21 Oct 2022 02:58:45 -0700 (PDT) X-Google-Smtp-Source: AMsMyM729jxzo5pzS5ClA9SKxBG1jzMat8JYGil5VCz23k6cWOCMrVl7YbInxntZpgTcvtGqYvwU/PBplq37igikqAc= X-Received: by 2002:a05:622a:15cf:b0:39c:4c04:107d with SMTP id d15-20020a05622a15cf00b0039c4c04107dmr14982068qty.122.1666346325156; Fri, 21 Oct 2022 02:58:45 -0700 (PDT) MIME-Version: 1.0 References: <0f1f223a-3756-1da3-bd1d-b87edd34e1f9@126.com> In-Reply-To: <0f1f223a-3756-1da3-bd1d-b87edd34e1f9@126.com> From: Jonathan Wakely Date: Fri, 21 Oct 2022 10:58:34 +0100 Message-ID: Subject: Re: Adding a new thread model to GCC To: LIU Hao Cc: gcc-patches@gcc.gnu.org, libstdc++@gcc.gnu.org, Eric Botcazou X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-6.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,KAM_SHORT,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: How does this compare with Eric B's proposal at https://gcc.gnu.org/legacy-ml/gcc-patches/2019-06/msg01840.html ? It would be good if we can accept one of them for GCC 13, but I don't know Windows well enough to determine which is better. On Sat, 1 Oct 2022 at 19:35, LIU Hao via Libstdc++ wrote: > > Greetings. > > After some years I think it's time to put on this topic again. > > This patch series is an attempt to add a new thread model basing on the mcfgthread library > (https://github.com/lhmouse/mcfgthread), which provides efficient implementations of mutexes, > condition variables, once flags, etc. for native Windows. > > > The first patch is necessary because somewhere in libgfortran, `pthread_t` is referenced. If the > thread model is not `posix`, it fails to compile. > > The second patch implements `std::thread::hardware_concurrency()` for non-posix thread models. This > would also work for the win32 thread model if `std::thread` would be supported in the future. > > The third patch adds the `mcf` thread model for GCC and its libraries. A new builtin macro > `__USING_MCFGTHREAD__` is added to indicate whether this new thread model is in effect. This grants > `std::mutex` and `std::once_flag` trivial destructors; `std::condition_variable` is a bit > unfortunate because its destructor is non-trivial, but in reality no cleanup is performed. > > > I have been bootstrapping GCC with the MCF thread model for more than five years. At the moment, C, > C++ and Fortran are supported. Ada is untested because I don't know how to bootstrap it. Objective-C > is not supported, because threading APIs for libobjc have not been implemented. > > Please review. If there are any changes that I have to make, let me know. > > > -- > Best regards, > LIU Hao