Communicator e3000 MPE/iX Release 7.0 Express 1 (Software Release C.70.01) (30216-90328)
Chapter 5 119
Technical Articles
Pascal/iX has $VOLATILE_WITH Option Enhancement
pointer to the top level record type is volatile. This is the safest alternative, at the cost
of code efficiency.
When a WITH statement is seen, the $VOLATILE_WITH level currently in effect will
be applied to all WITH result pointers (temps) for that statement.
Only the "top type" is checked, because it is unlikely that a user will want the temp
volatility to be based on every level of the whole expression. We go down one level to
the first pointer because the pointer/pointed-to-type misunderstanding may be
commonplace, given the previous ambiguity in volatile declarations.
If the "top type" in a WITH expression contains a volatile, you will get the following
error message:
VOLATILE RECORD OR POINTER IN WITH EXPRESSION; $VOLATILE_WITH
REQUIRED (895)
If you encounter this error, you should consider what you want to be volatile,
possibly change your type declarations if they are incorrect, and add the appropriate
$VOLATILE_WITH option.
For example, given the original code fragments:
ptr_type = ^ $extnaddr,VOLATILE$ mytype;
...
var l_dptr : ptr_type; {l_dptr is volatile}
...
with ..., l_dptr^ {l_dptr is volatile, l_dptr^ is not}
To generate the safest code, simply insert a $VOLATILE_WITH 2$ option at some point
before the WITH statement. This will cause the suspicious WITH temp to be volatile;
the compiler will generate code to always reload the temp and all subsequent
expressions based on the temp. With this change, the WITH temp is reloaded on each
reference, and all loads and stores through that pointer are present in the generated
code.To generate more efficient code, carefully examine the type declarations to be sure
you know what you want to be volatile. In this example, the thing that the user really
wants to be volatile is the record type being pointed to, and the WITH temp (a pointer to
that record type) should not be volatile. This means that ptr_type should be changed to
a pointer to a volatile, and the $VOLATILE_WITH 0$ option can be used.
For example:
ptr_type = ^ $extnaddr$ v_mytype;
v_mytype = $VOLATILE$ mytype;
...
var l_dptr : ptr_type; {l_dptr^ is volatile}
...
$VOLATILE_WITH 0$
with ..., l_dptr^