From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm1-x335.google.com (mail-wm1-x335.google.com [IPv6:2a00:1450:4864:20::335]) by sourceware.org (Postfix) with ESMTPS id D3C8D3858D38 for ; Thu, 22 Sep 2022 19:58:12 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org D3C8D3858D38 Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=googlemail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=googlemail.com Received: by mail-wm1-x335.google.com with SMTP id h130-20020a1c2188000000b003b4cadadce7so2013342wmh.3 for ; Thu, 22 Sep 2022 12:58:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20210112; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:from:to:cc:subject:date; bh=iw9Kg82KfamrBpVWvlrgvaAV51m7C6bvlSjOEZ4uVa8=; b=SYDedemUl4Bsl9JeqofQiQv+E/2VqZNzUBN9e9Nr2qheZMga+G5HcHQZgLyKh9peTO tf7H+J/RQ57l6zBASsKqakefllGyotL/9yHQvurpi2qDVacQsdZd0OOQBnjwo+D2E98e WpDNIi6EdYjH44lxLJZ4y1nKIND94Q2zGga17Bce7PIiIRc1zC8GMiXHwiHsiUu5BdUa CxHBKSoEzOQyaAJRej9ZPkfBMf9BufquEFQj9jIfCApuYABGWK6jaXSEZP1nS3JEe2dr 10R9eQjoP2orKYFbylWpbMCbxWprvQw2lYMXQyIZkF7ZDhoqSqn6FyvT4eVA8Zf4Ttgi 9spw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:x-gm-message-state:from:to:cc :subject:date; bh=iw9Kg82KfamrBpVWvlrgvaAV51m7C6bvlSjOEZ4uVa8=; b=6t2lu03bNd/jNIs/jAbgesQO74tbMkLnA/yxeeFAbAJYtH0s8HNr0cXiMbHpCZ9xwN Aax0Du1ZmshGBCeB/J8XL3Stp6R6a6/71G574IpKKQecShE1NJzDxiVu+jbQkGB26T+Z Knn94J0dxw7AAQeP/dotC1JGk/8Zp8dGwM4p4A9UidL0D2h7IFqtiVLhXYZkqeBqr+Hr 4067Zahwn3mvngvyRBVmmfe5tEuqBcogvne3cTfQ3PmYzc3L5SVp/mMiQuuax1cpJp/7 sFa5vwgoD9aUxfD7sVHxPjYtNN/T4FnT6PggeLRuAIr+nd+XUOY2fIzp/ZE2TI4kTcNJ /Tcg== X-Gm-Message-State: ACrzQf2rQmE4NfCYEJ9+23Hxe4Rpg5KMN/O3mGpiNMLK3NNuMmLOj10G FRci/vl+ot5n/HIk0l9cqwY= X-Google-Smtp-Source: AMsMyM7iOiY7H7X9tmbtqeZJYKoEtbC0xZvbvyl4ABhIkraanhSQndXNjd4hTzLnYHqMrJXZE6W5qw== X-Received: by 2002:a05:600c:42c9:b0:3b4:b0c0:d614 with SMTP id j9-20020a05600c42c900b003b4b0c0d614mr10542068wme.90.1663876691521; Thu, 22 Sep 2022 12:58:11 -0700 (PDT) Received: from [192.168.1.95] (host81-138-1-83.in-addr.btopenworld.com. [81.138.1.83]) by smtp.googlemail.com with ESMTPSA id f9-20020a05600c154900b003a3442f1229sm466976wmg.29.2022.09.22.12.58.10 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 22 Sep 2022 12:58:10 -0700 (PDT) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.120.23.2.7\)) Subject: Re: Use coroutines for avr-gcc From: Iain Sandoe In-Reply-To: Date: Thu, 22 Sep 2022 20:58:09 +0100 Cc: gcc-help@gcc.gnu.org Content-Transfer-Encoding: quoted-printable Message-Id: <206B6D0C-6972-442A-96E3-324050A78584@googlemail.com> References: To: Wilhelm Meier X-Mailer: Apple Mail (2.3608.120.23.2.7) X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,KAM_SHORT,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,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: > On 22 Sep 2022, at 13:34, Jonathan Wakely = wrote: >=20 > On Thu, 22 Sept 2022 at 13:29, Wilhelm Meier wrote: >>=20 >> According to the standard, an implementation can avoid the >> heap-allocation, if >> - the lifetime of the coroutine is strictly within the lifetime of = the >> caller >> - the size of coroutine state can be determined at compile time >>=20 >> Looks like this optimization is not yet available because = new/delete-ops >> are required. You can provide your own allocation and deallocation functions in the = promise class : see - https://eel.is/c++draft/dcl.fct.def.coroutine#9 (and #12). NOTE: this link is the current C++23 draft, the implementation in GCC = follows the C++20 version (but the basic provision is stil there) >>=20 >> Is there any work on this topic? >=20 > The so-called HALO optimizations are much more difficult than was > originally thought when the wording in the standard was written. >=20 > = https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2022/p2477r3.html#back= ground-and-motivation > describes some of the problems. Agreed, this topic needs more consideration (and it is not mandatory, so = should not be relied upon for the use-case described in any event). cheers Iain >=20 >=20 >> Thanks! >> Wilhelm >>=20 >> On 21.09.22 15:38, Wilhelm Meier wrote: >>> I tried to use coroutines with avr-gcc (13.0.0) for the AVR target. = I >>> managed to include the coroutine-header and to write a very simple >>> generator using the example from cppreference. >>>=20 >>> It compiles well, but then I get undefined symbols: >>>=20 >>> 1) new and delete operator-functions >>> 2) f(f()::f().Frame*) >>>=20 >>> Therefore two question arise here: >>>=20 >>> a) is it possible to use coroutines without head-allocation? E.g. = define >>> some global storage for the state of the coroutine? >>> b) if a) can be fullfilled, what is 2) supposed to do? >>>=20 >>> Thanks for any hints, >>> Wilhelm