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!usenet.blueworldhosting.com!feeder01.blueworldhosting.com!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Simon Clubley Newsgroups: comp.lang.ada Subject: Comments requested for a couple of Ada-Comments submissions Date: Fri, 11 Jul 2014 00:02:20 +0000 (UTC) Organization: A noiseless patient Spider Message-ID: Injection-Date: Fri, 11 Jul 2014 00:02:20 +0000 (UTC) Injection-Info: mx05.eternal-september.org; posting-host="e458ff8b81bc0c159989eb0e36c6e372"; logging-data="10652"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/TIwfWZNNLwzYgwy17B4cStSD2Blzq5kA=" User-Agent: slrn/0.9.8.1 (VMS/Multinet) Cancel-Lock: sha1:mXNcH+BekTBy592EHlPnDxHgIZc= Xref: number.nntp.dca.giganews.com comp.lang.ada:187504 Date: 2014-07-11T00:02:20+00:00 List-Id: Hello, Since it's my first time sending anything to Ada-Comments, I was hoping for feedback before I submit them. I'm looking for things like style, content, unclear language, etc. Among other things, I don't want to waste Randy's time if I've missed something obvious. :-) The two issues are below and thanks for any feedback, Simon. ----------------------------------------------------------------------------- Issue 1: Partial Aggregate notation !topic Updating multiple record bitfields as an atomic operation !reference Ada 2012 RM{clause unsure} !from Simon Clubley 2014-07-10 !keywords bitfields records device registers atomic updating Ada can model the bitfields in a device register as a record type containing those bitfields and can map an instance of that record type to the address of that device register. However, sometimes there is a requirement to be able to update a subset of those bitfields as an atomic operation while preserving the contents of the other bitfields in the record. In Ada, the only way to do this (apart from C style bitmasks on a integer variable) is to read the device register into a temporary instance of the record type, modify the temporary variable and write the temporary variable back to the device register. This, to put it mildly, is ugly. A far better approach would be a new partial aggregate syntax in which the list of bitfields to be modified would be listed along with their new values. The compiler would then generate a Read-Modify-Write sequence and, as the operation would be on the record as a whole, C.6(15) would be guaranteed to apply when Atomic is used and there would be one single read of the device register and a single write to the device register. One suggested syntax would be: A := (A changing C => D, E => F); or A := (A updating C => D, E => F); where A is a record and C and E are record components. When this syntax discussion took place in comp.lang.ada one suggestion was "overriding" but I didn't like that because that keyword made it seem as if A was the one doing the overriding, not the later C and E references. I do think we need a new keyword because we are talking about adding a subset update capability to Ada and that new usage should stand out in any code. Thanks, Simon. ----------------------------------------------------------------------------- Issue 2: Does Atomic apply to record components ? !topic Does Atomic on a record apply to it's components ? !reference Ada 2012 RMC.6(15) !from Simon Clubley 2014-07-10 !keywords Atomic update record components C.6(15) states: For an atomic object (including an atomic component) all reads and updates of the object as a whole are indivisible. Scenario: Consider a 32 bit record marked as Atomic. This record consists of multiple bitfields and is used to model the bitfields in a 32 bit memory mapped device register. The hardware requires the device register to be read from and written to in units of 32 bits. Now consider the following statement: Device_Register.bitfield := 1; When this specific bitfield in the record, say 4 bits wide, is written to, does the Atomic attribute on the record require the register to be accessed in units of 32 bits or is the compiler permitted to generate code to access, say, 8 bits of the register only ? There are conflicting opinions in comp.lang.ada. The words "as a whole" in C.6(15) were used to justify the position that access to this single bitfield is not required to be in units of the record size which on the surface seemed reasonable. However, other opinions are that C.6(15) does apply when accessing this single bitfield. Which opinion is correct ? I would like C.6(15) to apply, but I am more interested in obtaining a firm decision so that we actually know one way or another. You should be aware that generated code posted in comp.lang.ada shows that for a ARM target, ldrb/strb (ie: byte level access) was used instead of ldr/str (ie: 32 bit level access) when the bitfield was within the first 8 bits of the register. This broke the hardware requirement this register be accessed in units of 32 bits. Thank you, Simon. ----------------------------------------------------------------------------- -- Simon Clubley, clubley@remove_me.eisner.decus.org-Earth.UFP Microsoft: Bringing you 1980s technology to a 21st century world