Operating System - OpenVMS
1752794 Members
6127 Online
108789 Solutions
New Discussion юеВ

Re: IA64 / PASCAL Definition for LIB$GET/FREE_VM_64

 
SOLVED
Go to solution

IA64 / PASCAL Definition for LIB$GET/FREE_VM_64

The runtime library LIB$GET/FREE_VM_64 expects as parameter "base_address" the address of an 64bit pointervariable receiving / holding the address of the memory area hjusr allocated / to be freed.

The definition in PASCAL$LIB_ROUTINES.PAS contains the following definitions:

TYPE
lib$routines$$typ2 = ^$QUAD;

[ASYNCHRONOUS] FUNCTION lib$free_vm_64 (
number_of_bytes : $QUAD;
base_address : lib$routines$$typ2;
zone_id : $UQUAD := %IMMED 0) : INTEGER; EXTERNAL;

If I interprete this correctly, then baseaddress is a pointer to a $QUAD. Because no explizit mechanism ist specified, this pointer is passed per reference. So I think, the value passed as parameter is the 32bit address ("per ref mechanism") of a 32bit pointer pointing to an $QUAD. This is one indirection to much.

I used the following calling sequence which works.

VAR
myaddress : UNSIGNED64;

BEGIN
lib$free_vm_64 (
number_of_bytes := nnnnn,
base_address := %REF myaddress)
END

------------------------------------------

Is this definition really wrong or do I interprete the definition from the manual the wrong way ?

Martin

4 REPLIES 4
John Gillings
Honored Contributor

Re: IA64 / PASCAL Definition for LIB$GET/FREE_VM_64

Martin,

According to the Pascal Reference Manual, Table A-6 (footnote 5):

"By default, pointers on OpenVMS I64 and OpenVMS Alpha systems are 32 bits in size. However, the QUAD attribute can be used on pointer declarations to specify 64-bit pointers. See the HP Pascal for OpenVMS User Manual for more information."

So, I'd guess the definition should be:

TYPE
lib$routines$$typ2 = [QUAD] ^$QUAD;

to define a 64 bit pointer. The simplest way to determine exactly what's going on is to write a program declaring different variations of attributes and types, then compile with /SHOW=ALL and see the Structure Layout Listing to see the allocation size of the objects you've defined.
A crucible of informative mistakes

Re: IA64 / PASCAL Definition for LIB$GET/FREE_VM_64

OK,l that seems correct and better than the %ref workaround.

The typoe $QUAD in the definition
lib$routines$$typ2 = [QUAD]^$QUAD;
is irrelevant. I.e.
lib$routines$$typ2 = [QUAD]^UNSIGNED;
would be correct to.

But in any case I think the (original) definition is incorrect. Maybe some gui from the pascal development will read this and comment.

It is not prior.
John Reagan
Respected Contributor
Solution

Re: IA64 / PASCAL Definition for LIB$GET/FREE_VM_64

There is a section in the release notes titled "Using 64-bit Pointers with System Definition Files" that discusses this issue.

In summary

- the definitions are indeed incorrect in that they don't know about quad-pointers in Pascal

- we'll try to improve them post V8.3

- use the %REF foreign mechanism specifier to override the incorrect definition inside of PASCAL$LIB_ROUTINES.PAS/PEN

Re: IA64 / PASCAL Definition for LIB$GET/FREE_VM_64

John,
Thanks for the confirmation.

I'll try to get an offical case logged too so that HP can processe the issue in the normal ways.

Martin