comp.lang.ada
 help / color / mirror / Atom feed
From: "Yannick Duchêne (Hibou57)" <yannick_duchene@yahoo.fr>
Subject: Re: Erroneous code generation from GNAT or GCC?
Date: Mon, 29 Apr 2013 03:35:53 +0200
Date: 2013-04-29T03:35:53+02:00	[thread overview]
Message-ID: <op.wv9313hwule2fv@cardamome> (raw)
In-Reply-To: op.wv9y9kouule2fv@cardamome

Le Mon, 29 Apr 2013 01:52:22 +0200, Yannick Duchêne (Hibou57)  
<yannick_duchene@yahoo.fr> a écrit:
> Until now, I though the volatile aspect was typically to be used with  
> object which may be updated as a non‑visible side effect, like with a  
> peripheral writing at some memory area […]
This way of understanding things must not be entirely wrong.

In the above solution involving volatile (once again, like in the other  
thread), the object is locally constant, as it is assigned, and never  
modified. So wanted to turn its declaration into this:


     Element :
        constant Character := Item
        with Volatile => True;


But GNAT complained, with a trustable reason, as it refers to the RM:


     stand alone volatile constant must be imported (RM C.6(13))


Here, according to the RM, a volatile constant declared in the Ada world  
and initialized in the Ada world, is not a valid candidate for a volatile  
aspect:

RM C.6(13) says:
> If an aspect Volatile, Volatile_Components, Atomic, orAtomic_Components  
> is directly specified to have the valueTrue for a stand-alone constant  
> object, then the aspectImport shall also be specified as True for it.

(oops, the `Import` aspect is not of boolean type …but what it means is  
still clear)

This suggest if the object is not modified, then the volatile aspect  
should not be required, unless the so‑called constant is not a constant in  
the strict Ada meaning (imported from the external world, and so which may  
be initialized who‑know‑when, and may also be modified later, externally).

What would help, is a way to tell the compiler the address is used, not  
for its own, but for what it refers to.

If all parameters must be volatile when there address attribute is used,  
that implies systematic copy of everything, as types defined for Ada  
programs, are not to be volatile. Ex. each string should be copied to an  
array of characters whose components are volatile (there is a  
`Volatile_Components` aspect).

Surprisingly, there is not such issue (or I've just never encountered any  
case?) when linking to similar sub‑programs in C or assembly and declared  
imported: there is no need to tell what's referred to by a pointer, is  
really needed. I wanted to try to use machine‑code insertion, to have most  
of or all things in Ada packages and to benefit from Ada checking.

I feel to not really understand how machine‑code insertion works or is  
defined (especially when optimization is enabled), and it looks to me,  
surprisingly a lot harder to set‑up than linking to similar imported  
sub‑programs.

So now, I'm seeking for something which would have the effect of a (an  
invalid) `pragma Volatile (Item'Address'Memory)` which seems to be  
implicit or not required when interfacing to C.


-- 
“Syntactic sugar causes cancer of the semi-colons.” [1]
“Structured Programming supports the law of the excluded muddle.” [1]
[1]: Epigrams on Programming — Alan J. — P. Yale University



  reply	other threads:[~2013-04-29  1:35 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-27 21:08 GNAT not generating any code for sub‑program: known bug? Yannick Duchêne (Hibou57)
2013-04-27 22:22 ` Yannick Duchêne (Hibou57)
2013-04-27 23:48   ` Yannick Duchêne (Hibou57)
2013-04-28  7:14   ` Simon Wright
2013-04-28 17:52     ` Yannick Duchêne (Hibou57)
2013-04-28 19:27       ` Yannick Duchêne (Hibou57)
2013-04-28 20:46         ` Simon Wright
2013-04-28 20:43       ` Simon Wright
2013-04-28 22:35 ` Erroneous code generation from GNAT or GCC? Yannick Duchêne (Hibou57)
2013-04-28 22:49   ` Yannick Duchêne (Hibou57)
2013-04-28 23:52   ` Yannick Duchêne (Hibou57)
2013-04-29  1:35     ` Yannick Duchêne (Hibou57) [this message]
2013-04-30  0:48       ` Yannick Duchêne (Hibou57)
2013-04-30  6:40         ` Simon Wright
2013-04-30 17:04           ` Yannick Duchêne (Hibou57)
2013-04-30 19:06             ` Simon Wright
2013-04-30 21:28               ` Yannick Duchêne (Hibou57)
2013-04-30 22:22                 ` Simon Wright
2013-05-01 18:19               ` J-P. Rosen
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox