From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=unavailable autolearn_force=no version=3.4.4 Path: border1.nntp.dca1.giganews.com!nntp.giganews.com!newspeer1.nac.net!feeder.erje.net!eu.feeder.erje.net!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: MatthiasR Newsgroups: comp.lang.ada Subject: Re: Forcing GNAT to use 32-bit load/store instructions on ARM? Date: Sun, 06 Jul 2014 22:40:27 +0200 Organization: - Message-ID: References: <0e0b9ac2-e793-4cc5-8d8d-d3441ca28a58@googlegroups.com> <1j7b0m3yptffy$.1cztnkty8elrv$.dlg@40tude.net> Mime-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 7Bit Injection-Date: Sun, 6 Jul 2014 20:46:57 +0000 (UTC) Injection-Info: mx05.eternal-september.org; posting-host="4231dff81c986ccbf65b9b5cb767c165"; logging-data="32703"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19C07SjcJL9B4lR1ZLsANZAUyQjA5uOO4g=" User-Agent: KNode/4.7.2 Cancel-Lock: sha1:qTOKy/vMbJvZAHbsUQMG6FWerms= Xref: number.nntp.dca.giganews.com comp.lang.ada:187403 Date: 2014-07-06T22:40:27+02:00 List-Id: Randy Brukardt wrote: > Right. If the OP really did exactly as he said, then GNAT has a bug (no > matter what his declaration was). [But I've seen plenty of cases where > someone (including me) thought they'd tried something when they really had > not for one reason or another.] According to the RM, the compiler must not divide a read or write from/to a variable with pragma/aspect 'atomic' into multiple reads/writes. There is nothing said, that the variable always has to be read/written as a whole. So it seems to be perfectly OK to write only one byte of a 32 bit variable, if a value has been assigned to only a part of a record which is contained in this byte. There is something said about this topic in the latest GNAT docs: https://docs.adacore.com/gnat-unw-docs/html/gnat_ugn_8.html#SEC97 They recommend to use a temporary variable to ensure an access to the record variable as a whole. That is not really elegant, because records with representation clauses, directly mapped onto hardware registers, look like the most natural way to access these registers. Reading Ada books, one even could get the impression that record represenation clauses are made primarily for this purpose. Unfortunately there seem to be no way to force a specific access width, so this feature is not really useable (without the mentioned workaround with the temporary variable) on architectures where the allowed access width is not uniform over the whole address range. Matthias