[Info-vax] 64-bit (was Re: New CEO of VMS Software)
mjos_examine
m6502x64 at gmail.com
Wed Jan 10 12:19:16 EST 2024
On 2024-01-09 6:47 p.m., Arne Vajhøj wrote:
> I don't have a problem with API's expecting 32 bit pointers being present.
>
> I have a problem with the situations where there is a function
> expecting 32 bit pointers but no function expecting 64 bit pointers.
> When one for whatever reason have a pointer to something
> up in P2 space. Allocating memory in P0 space, copy from
> P2 to P0, call function, copy back if necessary and
> deallocate it not elegant.
It looks like the compiler (and linker) will suitably warn, which is good.
--- snip mytest.c ---
/* experimenting with pointers */
#include <stdio.h>
# pragma __pointer_size __save
# pragma __pointer_size 64
char *my64bitpointer = (char *) 0x100000000;
# pragma __pointer_size 32
char *my32bitpointer = (char *) 0x10000000;
void my32bitfunction(char *ptr);
# pragma __pointer_size __restore
char *testdefault1, *testdefault2;
int main(int argc, char *argv[])
{
printf("my64bitpointer's address is %llp\n", my64bitpointer);
printf("my32bitpointer's address is %p\n", my32bitpointer);
testdefault1 = my64bitpointer;
testdefault2 = my32bitpointer;
my32bitfunction(my64bitpointer);
my32bitfunction(my32bitpointer);
}
# pragma __pointer_size __save
# pragma __pointer_size 32
void my32bitfunction(char *ptr)
{
printf("This is my function that requires a 32-bit parameter.\n");
}
# pragma __pointer_size __restore
================================
$ cc mytest.c
# pragma __pointer_size __save
.........^
%CC-I-PRAGIGNORE, The pointer size control pointer_size pragma is not
active. Pragma is ignored.
at line number 5 in file DKA100:[test]mytest.c;2
char *my64bitpointer = (char *) 0x100000000;
.......................^
%CC-I-INTCONSTTRUNC, In the initializer for my64bitpointer, conversion
of the constant "(char ...)0X0000000100000000" to pointer to char type
will cause data loss.
at line number 7 in file DKA100:[test]mytest.c;2
$ link mytest
$ run mytest
my64bitpointer's address is 0
my32bitpointer's address is 10000000
This is my function that requires a 32-bit parameter.
This is my function that requires a 32-bit parameter.
================================
$ cc /POINTER_SIZE=32 mytest.c
testdefault1 = my64bitpointer;
...................^
%CC-W-MAYLOSEDATA2, In this statement, "my64bitpointer" has a larger
data size than "short pointer to char".
Assignment can result in data loss.
at line number 19 in file DKA100:[test]mytest.c;2
my32bitfunction(my64bitpointer);
....................^
%CC-W-MAYLOSEDATA2, In this statement, "my64bitpointer" has a larger
data size than "short pointer to char".
Assignment can result in data loss.
at line number 21 in file DKA100:[test]mytest.c;2
$ link mytest
%ILINK-W-COMPWARN, compilation warnings
module: MYTEST
file: DKA100:[test]mytest.OBJ;6
$ run mytest
my64bitpointer's address is 100000000
my32bitpointer's address is 10000000
This is my function that requires a 32-bit parameter.
This is my function that requires a 32-bit parameter.
================================
$ cc /POINTER_SIZE=64 mytest.c
my32bitfunction(my64bitpointer);
....................^
%CC-W-MAYLOSEDATA2, In this statement, "my64bitpointer" has a larger
data size than "short pointer to char".
Assignment can result in data loss.
at line number 21 in file DKA100:[test]mytest.c;2
$ link mytest
%ILINK-W-COMPWARN, compilation warnings
module: MYTEST
file: DKA100:[test]mytest.OBJ;7
$ run mytest
my64bitpointer's address is 100000000
my32bitpointer's address is 10000000
This is my function that requires a 32-bit parameter.
This is my function that requires a 32-bit parameter.
More information about the Info-vax
mailing list