From: Simon Clubley <clubley@remove_me.eisner.decus.org-Earth.UFP>
Subject: Re: Oberon and Wirthian languages
Date: Thu, 24 Apr 2014 18:51:34 +0000 (UTC)
Date: 2014-04-24T18:51:34+00:00 [thread overview]
Message-ID: <ljbmfm$j7u$1@dont-email.me> (raw)
In-Reply-To: brsggrFmd3gU1@mid.individual.net
On 2014-04-24, Niklas Holsti <niklas.holsti@tidorum.invalid> wrote:
> On 14-04-24 03:20 , Simon Clubley wrote:
>> On 2014-04-23, Simon Wright <simon@pushface.org> wrote:
>>>
>>> But hardware isn't (usually) elegant! If what the hardware designer
>>> wants is for you to read the register, change the values you need to in
>>> the local copy, then write the modified value back, that's what the code
>>> should do, surely, without relying on compiler magic with obscure
>>> pragmas to make it happen? (Ada's pragma Atomic is quite obscure enough
>>> already!)
>>
>> The problem is the compiler does this automatically when you use C style
>> masks,
>
> Not really so, for the most common forms of C. AIUI, before C 2011 there
> was no way in C to declare that a particular variable or type should be
> "atomic" in the sense of being read and written indivisibly; this was
> only possible by using the predefined integer type sig_atomic_t.
>
Sorry, I probably wasn't clear enough.
What I meant was that if you write (in C) something like:
device_register = (device_register & mask1) | mask2;
while accessing a volatile register then gcc generates exactly one read
and exactly one write and the size of the access is the size of the
device_register declaration.
This is true at least on ARM and I have never seen any complaints about
it being untrue on other architectures.
> The C 1999 standard requires sig_atomic_t to be at least 8 bits wide, so
> it may be uncomfortably narrow on some machines. Of course, reasonable C
> compilers make sig_atomic_t be the widest type for which the target
> machine allows atomic load/store. On the other hand, some 32-bit
> machines have 16-bit I/O control registers, so a 32-bit sig_atomic_t
> would be too wide to be used for I/O control!
>
> Even qualifying the type or variable as volatile does not help, because
> volatility does not imply atomicity.
>
That's interesting. I wonder if this is a case of gcc implementing the
"expected" behaviour and there's now a large set of code which relies on
this "expected" behaviour.
>> but you have to do the work manually when you try to write clean
>> code by using record bitfields (in Ada) or bitfield structs (in C) and
>> need to do the read/write exactly once and want to update more than one
>> of the bitfields at the same time.
>>
>> This whole discussion started when someone suggested that in a C
>> replacement language we should drop the use of masks when possible
>> in favour of a bitfield approach. I _strongly_ agree with this, but
>> neither C or Ada, as they stand, make it easy to do this.
>>
>> I proposed the following syntax for a C replacement language:
>>
>> atomic using uart0.config1
>> .flag1 := 0;
>> .enable := 1;
>> .txdis := 0;
>> end atomic;
>
> This resembles the Pascal "with" statement, which is like an Ada "use"
> statement for the record variable: the record components are directly
> visible (without qualification) in the scope of the "with" statement.
>
> I would prefer a more general, expression-based solution: extend the
> aggregate notation with a form which combines an expression of a
> composite type, which provides the initial component values, and a
> partial aggregate, which uses named association to set new values for
> some of the components. This would be similar to an extension aggregate,
> but would override the initial values of some components, not combine an
> ancestor part with an extension part.
>
> For example, assume that the variables A and B are of a record type with
> the components x and y and some more components, Then, instead of the
> three statements
>
> B := A;
> B.x := 42;
> B.y := False;
>
> we could say something like
>
> B := (A overriding x => 42, y => False);
>
> (The "overriding" keyword is a bit misleading here, because it implies
> that the left-hand operand (A) overrides the right-hand aggregate, while
> the opposite should happen. Oh well.)
>
Although I agree the syntax needs changing, I do like the general
idea behind this suggestion.
> This form of aggregate could implement the "atomic using", for example:
>
> uart0.config1 := (uart0.config1
> overriding flag1 => 0, enable => 1, txdis => 0);
>
> Declaring uart0.config1 as atomic provides the single-read, single-write
> property in this assignment.
>
Yes, it certainly does.
> This "overriding aggregate" would be useful in other ways, too, by
> making some temporary variables unnecessary. Perhaps it would be
> especially useful in contract aspects, where temporaries cannot be declared.
>
It will be interesting to see if Randy and company have any comments on
this syntax.
Simon.
--
Simon Clubley, clubley@remove_me.eisner.decus.org-Earth.UFP
Microsoft: Bringing you 1980s technology to a 21st century world
next prev parent reply other threads:[~2014-04-24 18:51 UTC|newest]
Thread overview: 144+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-04-11 2:39 Heartbleed Charles H. Sampson
2014-04-11 7:59 ` Heartbleed Maciej Sobczak
2014-04-11 10:50 ` Heartbleed Pascal J. Bourguignon
2014-04-12 1:46 ` Heartbleed Charles H. Sampson
2014-04-11 12:43 ` Heartbleed kalvin.news
2014-04-11 19:33 ` Heartbleed Simon Clubley
2014-04-12 4:58 ` Heartbleed Shark8
2014-04-12 7:15 ` Heartbleed Nasser M. Abbasi
2014-04-12 9:28 ` Heartbleed Georg Bauhaus
2014-04-12 9:33 ` Heartbleed Georg Bauhaus
2014-04-12 11:42 ` Heartbleed Pascal J. Bourguignon
2014-04-12 15:37 ` Heartbleed Nasser M. Abbasi
2014-04-12 18:56 ` Heartbleed Pascal J. Bourguignon
2014-04-12 20:29 ` Heartbleed Yannick Duchêne (Hibou57)
2014-04-12 20:34 ` Heartbleed Dmitry A. Kazakov
2014-04-12 20:47 ` Heartbleed Yannick Duchêne (Hibou57)
2014-04-12 20:53 ` Heartbleed Yannick Duchêne (Hibou57)
2014-04-15 10:02 ` Heartbleed Yannick Duchêne (Hibou57)
2014-04-15 12:35 ` Heartbleed Dmitry A. Kazakov
2014-04-12 21:57 ` Heartbleed Niklas Holsti
2014-04-13 13:08 ` Heartbleed Georg Bauhaus
2014-04-13 13:55 ` Heartbleed Pascal J. Bourguignon
2014-04-13 15:13 ` Heartbleed Dennis Lee Bieber
2014-04-13 15:36 ` Heartbleed Nasser M. Abbasi
2014-04-12 18:39 ` Heartbleed Simon Wright
2014-04-12 19:15 ` Heartbleed Pascal J. Bourguignon
2014-04-12 19:18 ` Heartbleed Pascal J. Bourguignon
2014-04-12 20:40 ` Heartbleed Yannick Duchêne (Hibou57)
2014-04-12 20:44 ` Heartbleed Yannick Duchêne (Hibou57)
2014-04-12 21:31 ` Heartbleed Niklas Holsti
2014-04-12 14:58 ` Heartbleed Dennis Lee Bieber
2014-04-12 18:28 ` Heartbleed Yannick Duchêne (Hibou57)
2014-04-12 18:22 ` Heartbleed Yannick Duchêne (Hibou57)
2014-04-12 18:38 ` Heartbleed Simon Clubley
2014-04-12 20:24 ` Heartbleed Yannick Duchêne (Hibou57)
2014-04-12 21:48 ` Heartbleed Simon Clubley
2014-04-17 6:15 ` Heartbleed Jacob Sparre Andersen
2014-04-17 15:55 ` Heartbleed Shark8
2014-04-17 21:01 ` Heartbleed Simon Clubley
2014-04-17 21:51 ` Heartbleed Shark8
2014-04-17 21:54 ` Heartbleed Alan Jump
2014-04-17 22:02 ` Heartbleed Adam Beneschan
2014-04-17 22:35 ` Heartbleed Simon Clubley
2014-04-17 22:55 ` Heartbleed Jeffrey Carter
2014-04-18 8:48 ` Heartbleed Simon Clubley
2014-04-18 18:02 ` Heartbleed Jeffrey Carter
2014-04-18 20:31 ` Heartbleed Yannick Duchêne (Hibou57)
2014-04-18 23:16 ` Heartbleed Pascal J. Bourguignon
2014-04-19 18:29 ` Heartbleed Simon Clubley
2014-04-21 22:50 ` Heartbleed Randy Brukardt
2014-04-18 1:38 ` Heartbleed Yannick Duchêne (Hibou57)
2014-04-18 14:59 ` Heartbleed Nasser M. Abbasi
2014-04-18 17:12 ` Heartbleed Alan Browne
2014-04-18 17:30 ` Heartbleed J-P. Rosen
2014-04-18 18:04 ` Heartbleed Jeffrey Carter
2014-04-18 18:34 ` Heartbleed Simon Clubley
2014-04-18 20:45 ` Heartbleed Jeffrey Carter
2014-04-18 21:35 ` Heartbleed Dennis Lee Bieber
2014-04-18 22:20 ` Heartbleed Jeffrey Carter
2014-04-18 22:41 ` Heartbleed Adam Beneschan
2014-04-19 15:53 ` Heartbleed Dennis Lee Bieber
2014-04-18 18:37 ` Heartbleed Alan Browne
2014-04-18 20:45 ` Heartbleed Jeffrey Carter
2014-04-18 21:06 ` Heartbleed Alan Browne
2014-04-18 22:20 ` Heartbleed Jeffrey Carter
2014-04-19 14:04 ` Heartbleed Alan Browne
2014-04-18 20:49 ` Heartbleed Shark8
2014-04-18 21:07 ` Heartbleed Alan Browne
2014-04-18 22:56 ` Heartbleed Nasser M. Abbasi
2014-04-19 4:27 ` Heartbleed tmoran
2014-04-18 21:17 ` Heartbleed Shark8
2014-04-19 18:59 ` Heartbleed Simon Clubley
2014-04-19 19:21 ` Heartbleed Shark8
2014-04-18 1:29 ` Heartbleed Yannick Duchêne (Hibou57)
2014-04-18 10:42 ` Heartbleed J-P. Rosen
2014-04-19 11:50 ` Oberon and Wirthian languages (was: Heartbleed) Ludovic Brenta
2014-04-19 12:46 ` Oberon and Wirthian languages Georg Bauhaus
2014-04-19 19:17 ` Simon Clubley
2014-04-19 19:25 ` Shark8
2014-04-19 16:35 ` Oberon and Wirthian languages (was: Heartbleed) Yannick Duchêne (Hibou57)
2014-04-19 19:32 ` Simon Clubley
2014-04-19 22:30 ` Dennis Lee Bieber
2014-04-19 22:35 ` Oberon and Wirthian languages Alan Browne
2014-04-19 16:53 ` Georg Bauhaus
2014-04-19 17:32 ` Simon Wright
2014-04-19 17:35 ` Jeffrey Carter
2014-04-19 18:06 ` Yannick Duchêne (Hibou57)
2014-04-19 18:53 ` Shark8
2014-04-19 20:08 ` Simon Clubley
2014-04-19 22:16 ` Simon Clubley
2014-04-21 13:06 ` Oberon and Wirthian languages (was: Heartbleed) Simon Clubley
2014-04-21 18:13 ` Simon Clubley
2014-04-21 18:45 ` Oberon and Wirthian languages Shark8
2014-04-21 23:26 ` Randy Brukardt
2014-04-22 0:21 ` Simon Clubley
2014-04-22 5:48 ` Shark8
2014-04-21 18:16 ` Jeffrey Carter
2014-04-22 0:34 ` Simon Clubley
2014-04-22 3:01 ` Jeffrey Carter
2014-04-22 23:31 ` Randy Brukardt
2014-04-22 6:41 ` Simon Wright
2014-04-22 12:25 ` Simon Clubley
2014-04-22 19:13 ` Niklas Holsti
2014-04-22 20:46 ` Simon Clubley
2014-04-22 23:38 ` Randy Brukardt
2014-04-23 12:16 ` Simon Clubley
2014-04-23 20:55 ` Simon Wright
2014-04-24 0:20 ` Simon Clubley
2014-04-24 13:05 ` Niklas Holsti
2014-04-24 18:51 ` Simon Clubley [this message]
2014-04-24 20:11 ` Niklas Holsti
2014-04-25 1:37 ` Randy Brukardt
2014-04-25 21:33 ` Simon Clubley
2014-04-25 21:55 ` Randy Brukardt
2014-04-25 23:16 ` Dennis Lee Bieber
2014-04-26 6:31 ` Niklas Holsti
2014-04-26 0:23 ` Nasser M. Abbasi
2014-04-26 2:46 ` Shark8
2014-04-26 2:52 ` Shark8
2014-04-26 6:37 ` Niklas Holsti
2014-04-26 6:19 ` Georg Bauhaus
2014-04-26 6:35 ` Georg Bauhaus
2014-04-26 6:42 ` Niklas Holsti
2014-04-26 17:15 ` Simon Clubley
2014-04-26 6:29 ` Niklas Holsti
2014-04-26 7:36 ` Dmitry A. Kazakov
2014-04-26 7:52 ` Georg Bauhaus
2014-04-26 8:09 ` Dmitry A. Kazakov
2014-04-26 18:32 ` Simon Clubley
2014-05-08 2:36 ` Randy Brukardt
2014-05-08 17:48 ` Niklas Holsti
2014-05-08 19:22 ` Randy Brukardt
2014-04-26 7:23 ` Simon Wright
2014-04-26 9:27 ` Niklas Holsti
2014-04-26 12:34 ` Simon Wright
2014-04-27 10:38 ` Simon Wright
2014-04-27 15:36 ` Simon Clubley
2014-04-27 14:26 ` Brian Drummond
2014-04-22 23:30 ` Randy Brukardt
2014-04-23 12:17 ` Simon Clubley
2014-05-14 9:39 ` Heartbleed gvdschoot
2014-04-12 22:01 ` Heartbleed Yannick Duchêne (Hibou57)
2014-04-18 17:58 ` Heartbleed Alan Browne
2014-04-18 17:24 ` Heartbleed - attacks? Alan Browne
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox