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 7C4E23853827 for ; Fri, 21 Oct 2022 09:58:49 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 7C4E23853827 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=1666346329; 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=IDprbQJMy4IozW/1xpv9Di964YxIp06BmWZOZL7Dm+T4yhpobFhCHflrQmzhNK+12QnZbz 8OlLYUP6UhOzbLHjzZlE7DSauxBDrxmJP8pS3keYOnYMhTtqlKdt7Co2WQyd3GBlgeZpOf wTv5iHBi6XlFd9/8Ypej1oom9uCeB8I= Received: from mail-qk1-f199.google.com (mail-qk1-f199.google.com [209.85.222.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-515-H2INg7iYNSWHbvJ_edPmlQ-1; Fri, 21 Oct 2022 05:58:45 -0400 X-MC-Unique: H2INg7iYNSWHbvJ_edPmlQ-1 Received: by mail-qk1-f199.google.com with SMTP id x16-20020a05620a449000b006eecf2d621eso3003880qkp.16 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=22Zcsg570rVwb7ufrlZYy1H/Nt33YSbkZaf/N3J2rLQF3Ef+TQHtjWoXZmFw6Qv2/T y2dvQEsBCZgylfNLHCfP2XHu3zkWQsOSRezUF7Z7AYfJiLgpTlxPh1ULEwu+Vy++G9w0 yfJ0sh/lbwldUYlVJfSCLAtI6qWuOUb8EkltE6HeCc5TxYgdcepRJ1u473H2fzqkudND x3PJ6A/VotCinm6au74fVdmELPGASQ5yBbsueaJG3lSu83VbW0EPRCJ5anADfYWTmz7U /q/DuRtIngPOUzeINQ+G4hgdn58nsCx4LLBasbqJO7qKrNbq7vzgEhOPALA9M9VbJwUX zSUg== X-Gm-Message-State: ACrzQf08PY2fOk3U51svqTe27EUZgXBF3wrbxRpiPaE0Vud6BpaojJZr eCvzaJB+Of2XdxngqLQsIPGuifZZS5S0c4jeGDuryTjPVyksFwrTqoFpyECdbDbpS2+VT53J0UD mKkjX1FNF0fmgrU0aS3wZQ7i5kMPSZ2IysA== X-Received: by 2002:a05:622a:15cf:b0:39c:4c04:107d with SMTP id d15-20020a05622a15cf00b0039c4c04107dmr14982078qty.122.1666346325346; 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=unavailable 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