From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NOR01-OL1-obe.outbound.protection.outlook.com (mail-ol1nor01on2044.outbound.protection.outlook.com [40.107.224.44]) by sourceware.org (Postfix) with ESMTPS id 90EEE3858408 for ; Wed, 5 Jul 2023 11:55:26 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 90EEE3858408 Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=westcontrol.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=westcontrol.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ReB7LbuVp/BiRtXUDbx7+SRb3d23gwNDpXzKhVh1cceW0gfHa8OV6IO8p4MoiPXm/lJZOiWFafnYR4DNcv+EryQigB8Wu4YyNNuqsbdYWlarcA8wG9oLP6nIZFWYbTleZXZq5cY8ZfnKkRP4XnkIxa5DP74l1h+e0oq+e+n4+YdkxNipYw/Ns9hO5OV8NdRig36cdeBFijMF6ytYpCSxaBQZQ1t0O2XQBlcCBgqvSzFoO9LWK1s3EFOdhsNDe+LXAq0QXjFBTzD6bA9nR9eiFcyGw+62oqQ8TmVDzoxGucvhi0qrdRJeAckfkIS/FksEgo+xiXoz+qLT1sxvrObn1w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=1b5HaGyNWfz++VsofbpFXRJ8zRII5gTc70J2USxdbPo=; b=lBjSUd0wHVJS/WSsXd03xOGKalcO3+RShtxIBlI0J5tQnLgLS61gLkc3/e01IcnUZkhgC8mj4CU71+TioGPp3IOuiq+QuYzK2JcWilrOPNOUv2wjDLVlopEgxG4w0PwM58AN+XxRAQr20fZ4/sXB9fMRN0SAHpOCXO+Gb8aUeuG/qcruzmleUTsycHr/SZ6OUmlWMQD8qf98qvLgqzb0E7e5sBN37uud4Njaszb/r7RF6wsg0B4/mpLCV00yiUmP1qFYWhEmW25y/WcpKyi1M1gKGYuJG/0xnJKK2MHez+m3DdSyu3XuPYcjzc38Cc4e+3CiodzTa8dbLZsg3G+tYA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=westcontrol.com; dmarc=pass action=none header.from=westcontrol.com; dkim=pass header.d=westcontrol.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=westcontrol.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=1b5HaGyNWfz++VsofbpFXRJ8zRII5gTc70J2USxdbPo=; b=IFymgcdnS9rty23Kz4gFJERmTqhlEGA3WmMkFE36PbVa8ecN52S56otlr/EHMgbJNOckF1iyGL/nMTY9AbIgOIdO5AhrVuTflDTvwQaKcT68PmxNVUCpH/STy6KbldjVjwn7ttuWAdBmGt9j6Uv0zq8NcqSG+/aIkszINqEai4Ua0Jcdxpgi8xE0/aeidfmRXIlV+LTBB6TvR2yx0kc6zL7YJ+zhOy84WHIvg3VIx44+opACLyhosx8DCsAHQJyvgHbyuZb+Nd9ekYrHp5GDQ3muYaFzUt+24XjjgQI2XiPGxoOJQWJjDjyaiHTpZxS01hz5e8h67W5Zz12YE4DXvg== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=westcontrol.com; Received: from SV0P279MB0233.NORP279.PROD.OUTLOOK.COM (2603:10a6:f10:b::13) by OS5P279MB0869.NORP279.PROD.OUTLOOK.COM (2603:10a6:e10:37::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6565.17; Wed, 5 Jul 2023 11:55:24 +0000 Received: from SV0P279MB0233.NORP279.PROD.OUTLOOK.COM ([fe80::b999:1d1d:3eb1:b8f1]) by SV0P279MB0233.NORP279.PROD.OUTLOOK.COM ([fe80::b999:1d1d:3eb1:b8f1%7]) with mapi id 15.20.6565.016; Wed, 5 Jul 2023 11:55:24 +0000 Message-ID: <25afc1cb-3a62-135d-3206-2d9eb6216944@westcontrol.com> Date: Wed, 5 Jul 2023 13:55:23 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.9.0 Subject: Re: wishlist: support for shorter pointers Content-Language: en-GB To: =?UTF-8?Q?Rafa=c5=82_Pietrak?= , Martin Uecker , Ian Lance Taylor Cc: "Richard Earnshaw (lists)" , "gcc@gcc.gnu.org" References: <439affd4-11fe-de80-94c8-6fc64cbf76ec@ztk-rp.eu> <112e711791835d56cca38654f83a009cb46707d4.camel@gwdg.de> <940e9ae5-8649-5a28-e29f-06f0b2982892@ztk-rp.eu> <6c881d3fc76d112d52ec668d05b68394ae792f30.camel@gwdg.de> <1eeef918-80d0-12a3-e7e9-5a75b25fb769@ztk-rp.eu> <8825a11f-e462-8d97-3cdf-a5015250f3c1@westcontrol.com> <45292545-b4e1-a2c8-38d0-a7773f309ca5@ztk-rp.eu> From: David Brown In-Reply-To: <45292545-b4e1-a2c8-38d0-a7773f309ca5@ztk-rp.eu> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-ClientProxiedBy: SV0P279CA0021.NORP279.PROD.OUTLOOK.COM (2603:10a6:f10:12::8) To SV0P279MB0233.NORP279.PROD.OUTLOOK.COM (2603:10a6:f10:b::13) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SV0P279MB0233:EE_|OS5P279MB0869:EE_ X-MS-Office365-Filtering-Correlation-Id: f1e0ce63-4775-4e4c-f10b-08db7d4eb763 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: kCIY9RwAi2FnLPz1crzZ8UxhPK5OEc3ckoD6MWd+J6nhgq5W64g3YlBDTAjWJjEvXPaShyORaFoEqmyPBoKE+rmGY4+p3HJcaermsl3Vys1rR0dCE/Fe4BNIyZMui8ORhnxPos2P2tXLc2gF6lJrwEiZG/0uRkXrG5AHkJ0W2hd4xQ8HfzKKoxt6N/0IserY3fyvgml65bQLj2QhUdPClcoAMEtbOmSKo0MFyafz6MfQUhdLcVb/DKSD1vk5ciSOWrFmOIGbn8hnT0QXTvxwgOQkAvXNAKM5NZ9Lp+oYyZdhJkLuBQhEZRvN1/SLrDeLdDLlUG/bUJPaWeRI8PlAbHaja9SQcyto7gymYcV48L0FpmP9AkhJn1xFSXCik857pA83Ei6AWVV+2QKFN9QjFG3CjeEb2a3LQrH7p76imXfs98GzexurZffwOfSLIt91Es8se53WnFTKXkFd3XxzVwtofdugJWFHY5egF6nzZhUDAcujC87RO7lobRFbObJFtL7MEvMxJjOVfNrtfxxjTQ6eWKyX8jz7kFDVggN2DL3zF+vC9DbUfuNgY5A2xp81jSEL1KoVwGUYxSROCRunH5ZCFSN6Qzrk/zdk4RphKpiBFw6LmqgrNRnrGtjo2dqV642GPHTbkjIFZEwRY2Rhfw== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SV0P279MB0233.NORP279.PROD.OUTLOOK.COM;PTR:;CAT:NONE;SFS:(13230028)(4636009)(346002)(376002)(366004)(136003)(39840400004)(396003)(451199021)(54906003)(5660300002)(8936002)(8676002)(41300700001)(316002)(66899021)(2906002)(83380400001)(31686004)(2616005)(4326008)(66946007)(66476007)(66556008)(38100700002)(86362001)(186003)(478600001)(6506007)(26005)(53546011)(110136005)(6486002)(36756003)(31696002)(6512007)(43740500002)(45980500001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?UGU1Vmt2d212UHlwTnlPMVNFZlM2bnRhTHlIVFZ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EvTmFaY0NKWWFiV01pcERoVkZNSlo1SGRWZW84b0NmWXdRVUpyTUVY?= =?utf-8?B?aUJjSDFxN0VTMkV1TnZRQWJEdUprR2I1cW14MkUzektmWEo3U1ExbVppTm9V?= =?utf-8?B?cTlUbytUd1d2QzduRElWaUxPZGpCc3pGeENpK1VhRGRUS2dtOVdiYnhOWVhp?= =?utf-8?B?R0ZYRXA2MHZmS3ZMMU5oNzZlSmtmTjRGUDNFNkFTRERlOHAyei9YR01EdEVW?= =?utf-8?B?TFhxYStlTTlSZFFidERqNEYza2hhamVuNEdvd1RPdEdLTVdZVlczc0srRGl4?= =?utf-8?Q?zs8khyALlxp/czw/f88LWT2f4?= X-OriginatorOrg: westcontrol.com X-MS-Exchange-CrossTenant-Network-Message-Id: f1e0ce63-4775-4e4c-f10b-08db7d4eb763 X-MS-Exchange-CrossTenant-AuthSource: SV0P279MB0233.NORP279.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Jul 2023 11:55:24.1587 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: c75fbd3c-42ad-4db0-9cff-972faf83ae45 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: maxAIT3o9tW3VxI6eoemv2R5rkIQcIqE82chMJiQtHYA0O8obWB5eshDoJByEUcCbdxKoATcA5u7wT36fm15Fg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: OS5P279MB0869 X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE 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 05/07/2023 11:42, Rafał Pietrak via Gcc wrote: > Hi, > > W dniu 5.07.2023 o 11:11, David Brown pisze: >> On 05/07/2023 10:05, Rafał Pietrak via Gcc wrote: > [-----------] >> I am not sure if you are clear about this, but the address space >> definition macros here are for use in the source code for the >> compiler, not in user code.  There is (AFAIK) no way for user code to >> create address spaces - you need to check out the source code for GCC, >> modify it to support your new address space, and build your own >> compiler.  This is perfectly possible (it's all free and open source, >> after all), but it is not a minor undertaking - especially if you >> don't like C++ ! > > Hmmm. > > Wouldn't it be easier and more natural to make the "named spaces" a > synonym to specific linker sections (like section names, or section name > prefix when instead of ".data.array.*" one gets ".mynamespace.array.*")? You can, of course, write : #define __smalldata __attribute__((section(".smalldata))) I'd rather see the "section" attribute extended to allow it to specify a prefix or suffix (to make subsections) than more named address spaces. I'm a big fan of only putting things in the compiler if they have to be there - if a feature can be expressed in code (whether it be C, C++, or preprocessor macros), then I see that as the best choice. > > [------] >> I realise that learning at least some C++ is a significant step beyond >> learning C - but /using/ C++ classes or templates is no harder than C >> coding.  And it is far easier, faster and less disruptive to make a >> C++ header library implementing such features than adding new named >> address spaces into the compiler itself. >> >> The one key feature that is missing is that named address spaces can >> affect the allocation details of data, which cannot be done with C++ >> classes.  You could make a "small_data" class template, but variables >> would still need to be marked __attribute__((section(".smalldata"))) >> when used.  I think this could be handled very neatly with one single >> additional feature in GCC - allow arbitrary GCC variable attributes to >> be specified for types, which would then be applied to any variables >> declared for that type. > > OK. I see your point. > > But let's have look at it. You say, that "names spaces affect allocation > details, which cannot be done with C++". Pls consider: > 1. for small embedded devices C++ is not a particularly "seller". We > even turn to assembler occasionally. I have been writing code for small embedded systems for about 30 years. I used to write a lot in assembly, but it is very rare now. Almost all of the assembly I write these days is inline assembly in gcc format - and a lot of that actually contains no assembly at all, but is for careful control of dependencies or code re-arrangements. The smallest device I have ever used was an AVR Tiny with no ram at all - just 2K flash, a 3-level return stack and its 32 8-bit registers. I programmed that in C (with gcc). C++ /is/ a big "seller" in this market. It is definitely growing, just as the market for commercial toolchains with non-portable extensions is dropping and 8-bit CISC devices are being replaced by Cortex-M0 cores. There is certainly plenty of C-only coding going on, but C++ is growing. > 2. affecting allocation details is usually the hole point of engineering > skills when dealing with small embedded devices - the hole point is to > have tools to do that. > When you are dealing with 8-bit CISC devices like the 8051 or the COP8, then allocation strategies are critical, and good tools are essential. But for current microcontrollers, they are not nearly as important because you have a single flat address space - pointers to read-only data in flash and pointers to data in ram are fully compatible. You do sometimes need to place particular bits of data in particular places, but that is usually for individual large data blocks such as putting certain buffers in non-cached memory, or a large array in external memory. Section attributes suffice for that. Allocation control is certainly important at times, but it's far from being as commonly needed as you suggest. (Dynamic allocation is a different matter, but I don't believe we are talking about that here.) > So your current objections to named spaces ... are in fact in favor of > them. Isn't it so? > Not really, no - I would rather see better ways to handle allocation and section control than more named address spaces. David