From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from sm.strop.com.pl (sm.strop.com.pl [83.17.179.219]) by sourceware.org (Postfix) with ESMTPS id 593B73858C2D for ; Wed, 28 Jun 2023 08:39:34 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 593B73858C2D Authentication-Results: sourceware.org; dmarc=pass (p=reject dis=none) header.from=ztk-rp.eu Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=ztk-rp.eu Received: from zorro.ztk-rp.eu ([::ffff:10.208.4.171]) (TLS: TLS1.2,256bits,ECDHE_RSA_AES_256_GCM_SHA384) by sm.strop.com.pl with ESMTPS; Wed, 28 Jun 2023 10:35:37 +0200 id 0000000003CACA25.00000000649BF0D9.00005030 Received: from public-gprs403814.centertel.pl ([37.47.208.167]:8991 helo=[192.168.43.32]) by zorro.ztk-rp.eu with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1qEQeG-00CYPL-0b; Wed, 28 Jun 2023 10:35:37 +0200 Message-ID: <21650b1b-1d2e-7929-3105-b8aaca629272@ztk-rp.eu> Date: Wed, 28 Jun 2023 10:35:32 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.11.0 Content-Language: en-US To: Jonathan Wakely Cc: waffl3x , "gcc@gcc.gnu.org" References: <439affd4-11fe-de80-94c8-6fc64cbf76ec@ztk-rp.eu> From: =?UTF-8?Q?Rafa=c5=82_Pietrak?= In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-SA-Exim-Connect-IP: 37.47.208.167 X-SA-Exim-Mail-From: embedded@ztk-rp.eu X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-Spam-Level: X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,KAM_DMARC_STATUS,NICE_REPLY_A,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE,T_SPF_HELO_PERMERROR autolearn=ham autolearn_force=no version=3.4.6 Subject: Re: wishlist: support for shorter pointers X-SA-Exim-Version: 4.2.1 (built Sat, 13 Feb 2021 17:57:42 +0000) X-SA-Exim-Scanned: Yes (on zorro.ztk-rp.eu) Received-SPF: unknown (IP address lookup failed.) SPF=FROM; sender=embedded@ztk-rp.eu; remoteip=::ffff:10.208.4.171; remotehost=; helo=zorro.ztk-rp.eu; receiver=sm.strop.com.pl; List-Id: Hi Jonathan, W dniu 28.06.2023 o 09:31, Jonathan Wakely pisze: > > > On Wed, 28 Jun 2023, 08:14 Rafał Pietrak via Gcc, how it looks like. I have a lot of code like this scattered around: > ------------------- >                                 y->next = NULL; >                 if (our) { out->next = a; >                 for (y = t->HD; y && y->next; y = y->next) >                 if (y)  y->next = a; >                         fit->HD = a->next; >                 fit->win = a->next; >                         b = a->next; > -------------------- > This is from just one source file, which otherwise is "plain C". If I > was to put it into a library that use "asm tweaked fancy pointers", a > portable fragment of code becomes "target dedicated" - this is > undesired. > > > If you use a C++ library type for your pointers the syntax above doesn't > need to change, and the fancy pointer type can be implemented portable, > with customisation for targets where you could use 16 bits for the pointers. As you can expect from the problem I've stated - I don't know C++, so I'll need some more advice there. But, before I dive into learning C++ (forgive the naive question).... isn't it so, that C++ comes with a heavy runtime? One that will bloat my tiny project? Or the bloat comes only when one uses particular elaborated class/inheritance scenarios, and this particular case ( for (...; ...; x = x->next) {} ) will not draw any of that into this project? Not knowing C++ and wanting to check your suggestion (before I start putting time into learning it), can you pls provide me a sample of code, that would replace the following: ---------------- struct test_s { struct test_s *next; char buff[1]; }; int test_funct(struct test_s *head, char *opt) { struct test_s *x = head; for (; x; x = x->next) { if (!*x->buff) { *x->buff = *opt; break; } } return x; } ----------------- .... and help me compile it into a variant with "normal/natural to architecture" pointers, and a variant with "fancy 16-bit" pointers? Thenx in advance, -R PS: as before - I don't get mails from the list, pls CC responses to me.