Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2014-11

Address size compiler

10 messages · 5 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Michael Van Canneyt
to Jonas Maebe
Jonas Maebe wrote 14 lines
Steve Hildebrandt wrote on ma, 10 nov 2014: > How oder where is the addres size for the current compiler target defined? See the last three entries in table G.2. at http://www.freepascal.org/docs-html/prog/progap7.html Alternatively, you can use {$if sizeof(pointer)=8} <64 bit pointers> {$elseif sizeof(pointer)=4} <32 bit pointer> etc...

I think he means in the compiler, but for the target the compiler is not compiling for.

For a cross-compiler, sizeof(pointer) sizeof(pointer on target arch)

Michael.

Reply by email

Steve Hildebrandt
to Jonas Maebe: Steve Hildebrandt wrote on ma, 10 nov 2014: See the last three entries in table G.2. at…
Jonas Maebe wrote 22 lines
Steve Hildebrandt wrote on ma, 10 nov 2014: > How oder where is the addres size for the current compiler target > defined? See the last three entries in table G.2. at http://www.freepascal.org/docs-html/prog/progap7.html Alternatively, you can use {$if sizeof(pointer)=8} <64 bit pointers> {$elseif sizeof(pointer)=4} <32 bit pointer> etc... Jonas _______________________________________________ fpc-devel maillist - http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel

Sry I should have mentioned I'm currently working on the compiler and I'm not to sure if I can use OS_ADDR for RTTI generation.

Steve

Reply by email

Jonas Maebe
to Steve Hildebrandt

Steve Hildebrandt wrote on ma, 10 nov 2014:

Sry I should have mentioned I'm currently working on the compiler and I'm not to sure if I can use OS_ADDR for RTTI generation.

If you want a tcgsize, use def_cgsize(voidcodepointertype) for references to code and def_cgsize(voidpointertype) for references to data.

If you want to create an initialised data entry, use tai_const.Create_nil_codeptr/Create_nil_dataptr for nil code/data pointers, tai_const.Create_int_codeptr/Create_int_dataptr for code/data pointers with an absolute value known at compile time, or in case you have a symbol name, use
tai_const.createname/createname_global with either AT_FUNCTION or AT_DATA depending on whether it's code or data (and depending on whether it's a global symbol or not, which you can determine via tabstractnormalvarsym.globalasmsym, or via "po_public in procdef.procoptions" for a procdef)

Jonas

Reply by email

Steve Hildebrandt
to Jonas Maebe
Jonas Maebe wrote 27 lines
Steve Hildebrandt wrote on ma, 10 nov 2014: > Sry I should have mentioned I'm currently working on the compiler and > I'm not to sure if I can use OS_ADDR for RTTI generation. If you want a tcgsize, use def_cgsize(voidcodepointertype) for references to code and def_cgsize(voidpointertype) for references to data. If you want to create an initialised data entry, use tai_const.Create_nil_codeptr/Create_nil_dataptr for nil code/data pointers, tai_const.Create_int_codeptr/Create_int_dataptr for code/data pointers with an absolute value known at compile time, or in case you have a symbol name, use tai_const.createname/createname_global with either AT_FUNCTION or AT_DATA depending on whether it's code or data (and depending on whether it's a global symbol or not, which you can determine via tabstractnormalvarsym.globalasmsym, or via "po_public in procdef.procoptions" for a procdef) Jonas _______________________________________________ fpc-devel maillist - http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel

Thanks def_cgsize(voidcodepointertype) was what I was looking for.

Steve

Reply by email

Kostas Michalopoulos
to Michael Van Canneyt: I think he means in the compiler, but for the target the compiler is not compiling for.…

On Mon, Nov 10, 2014 at 4:07 PM, Michael Van Canneyt <

Show quoted text 5 lines
wrote: For a cross-compiler, sizeof(pointer) sizeof(pointer on target arch)

So wait, the following code:

{$if sizeof(pointer)=8} Code1 {$elseif sizeof(pointer)=4} Code2 {$endif}

will evaluate Code1 for a FPC compiler that is itself compiled as a x86_64 (64bit) linux program but itself targets Win32 (32bit)? If so, this is highly counterintuitive (and i don't see the usefulness of it).

Reply by email

Jonas Maebe
to Kostas Michalopoulos
Kostas Michalopoulos wrote 16 lines
On Mon, Nov 10, 2014 at 4:07 PM, Michael Van Canneyt < > wrote: > > For a cross-compiler, sizeof(pointer) sizeof(pointer on target > arch) > So wait, the following code: {$if sizeof(pointer)=8} Code1 {$elseif sizeof(pointer)=4} Code2 {$endif} will evaluate Code1 for a FPC compiler that is itself compiled as a x86_64 (64bit) linux program but itself targets Win32 (32bit)?

You cut away the important part of the original message: "I think he means in the compiler". I.e., this is inside the compiler source code itself.

Jonas

Reply by email

Sven Barth
to Kostas Michalopoulos: On Mon, Nov 10, 2014 at 4:07 PM, Michael Van Canneyt < So wait, the following code: {$if…

Am 19.11.2014 16:15 schrieb "Kostas Michalopoulos" <

Show quoted text 13 lines
: On Mon, Nov 10, 2014 at 4:07 PM, Michael Van Canneyt < wrote: > > > For a cross-compiler, sizeof(pointer) sizeof(pointer on target arch) So wait, the following code: {$if sizeof(pointer)=8} Code1 {$elseif sizeof(pointer)=4} Code2 {$endif}

Michael's message wasn't meant as literal code. A compiler compiled for x86_64 will have sizeof(pointer)=8, but the pointer size of the target architecture (AFAIK called "aint" in the compiler, but I'm not sure currently) might be different from that, so inside the compiler One should know exactly which kind of Pointer one is talking about.

Regards,
Sven

Reply by email

Kostas Michalopoulos
to Sven Barth

Yes this is what i meant. I'd expect that the sizeof(pointer) to return the target architecture's pointer size, not the architecture of the compiler's own executable.

Sven Barth wrote 29 lines
Am 19.11.2014 16:15 schrieb "Kostas Michalopoulos" < >: > > > On Mon, Nov 10, 2014 at 4:07 PM, Michael Van Canneyt < > wrote: >> >> >> For a cross-compiler, sizeof(pointer) sizeof(pointer on target arch) > > > So wait, the following code: > > {$if sizeof(pointer)=8} Code1 {$elseif sizeof(pointer)=4} Code2 {$endif} Michael's message wasn't meant as literal code. A compiler compiled for x86_64 will have sizeof(pointer)=8, but the pointer size of the target architecture (AFAIK called "aint" in the compiler, but I'm not sure currently) might be different from that, so inside the compiler One should know exactly which kind of Pointer one is talking about. Regards, Sven _______________________________________________ fpc-devel maillist - http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel

Reply by email