Sign in Join

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

Mailing lists / fpc-devel / 2004-12

THandle and 64bit platforms

24 messages · 9 people · –

Reply by email Subscribe to this list Your subscription

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

Marc Weustink

Hi,

From what I understand from the definition of THandle in sysunixh.inc it

is defined as a LongInt, even on 64 bit platforms. Currently I'm porting Lazarus to x64 and there I need a 64bit THandle, how to solve it ?

Marc

Reply by email

Peter Vreman
to Marc Weustink
Show quoted text 6 lines
Hi, >From what I understand from the definition of THandle in sysunixh.inc it is defined as a LongInt, even on 64 bit platforms. Currently I'm porting Lazarus to x64 and there I need a 64bit THandle, how to solve it ?

File descriptors are still 32bit on x86_64, therefor Thandle=32bit.

Reply by email

Marc Weustink
to Peter Vreman
Show quoted text 9 lines
> Hi, > > From what I understand from the definition of THandle in > sysunixh.inc it is defined as a LongInt, even on 64 bit platforms. > Currently I'm porting Lazarus to x64 and there I need a 64bit > THandle, how to solve it ? File descriptors are still 32bit on x86_64, therefor Thandle=32bit.

A THandle is more than a file descriptor alone.
Since the LCL is VCL compatible and thus MS biassed, there are more THandles than filedescriptors alone. To keep code compatible and portable, I need a 64 bit THandle on 64 bit platforms. (on win64 a handle is also 64bit).
Or would you suggest to use HANDLE for a 64bit handle and THandle for 32bit ?

Marc

Reply by email

Peter Vreman
to Marc Weustink
Show quoted text 17 lines
> >> Hi, >> >> From what I understand from the definition of THandle in >> sysunixh.inc it is defined as a LongInt, even on 64 bit platforms. >> Currently I'm porting Lazarus to x64 and there I need a 64bit >> THandle, how to solve it ? > >File descriptors are still 32bit on x86_64, therefor Thandle=32bit. A THandle is more than a file descriptor alone. Since the LCL is VCL compatible and thus MS biassed, there are more THandles than filedescriptors alone. To keep code compatible and portable, I need a 64 bit THandle on 64 bit platforms. (on win64 a handle is also 64bit). Or would you suggest to use HANDLE for a 64bit handle and THandle for 32bit ?

THandle is platform dependent. On win64 THandle=QWord.

Currently Thandle=longint for unix, but Thandle=DWord for win32.

Reply by email

Marc Weustink
to Peter Vreman
Show quoted text 21 lines
>>> Hi, >>> >>> From what I understand from the definition of THandle in >>> sysunixh.inc it is defined as a LongInt, even on 64 bit platforms. >>> Currently I'm porting Lazarus to x64 and there I need a 64bit >>> THandle, how to solve it ? >> >>File descriptors are still 32bit on x86_64, therefor Thandle=32bit. > > A THandle is more than a file descriptor alone. > Since the LCL is VCL compatible and thus MS biassed, there are more > THandles than filedescriptors alone. To keep code compatible and portable, > I need a 64 bit THandle on 64 bit platforms. (on win64 a handle is also > 64bit). > Or would you suggest to use HANDLE for a 64bit handle and THandle for > 32bit ? THandle is platform dependent. On win64 THandle=QWord. Currently Thandle=longint for unix, but Thandle=DWord for win32.

Yes, I am aware of that, my question however is is how to get things working.

In the LCL a THandle is used everywhere and in most cases it represents a pointer. It is also part of the emulated message records. All members of it are defined as PtrInt. On placed where a handle is iused, it should map on a PtrInt.

Woudl you suggest me to
a) forbid the use of thandle
b) change all records and places where thandle is used c) create a intermediate function which maps a handle to a pointer (and still change a load of records)

Marc

Reply by email

Peter Vreman
to Marc Weustink
Show quoted text 35 lines
>>>> Hi, >>>> >>>> From what I understand from the definition of THandle in >>>> sysunixh.inc it is defined as a LongInt, even on 64 bit platforms. >>>> Currently I'm porting Lazarus to x64 and there I need a 64bit >>>> THandle, how to solve it ? >>> >>>File descriptors are still 32bit on x86_64, therefor Thandle=32bit. >> >> A THandle is more than a file descriptor alone. >> Since the LCL is VCL compatible and thus MS biassed, there are more >> THandles than filedescriptors alone. To keep code compatible >and portable, >> I need a 64 bit THandle on 64 bit platforms. (on win64 a handle is also >> 64bit). >> Or would you suggest to use HANDLE for a 64bit handle and THandle for >> 32bit ? > >THandle is platform dependent. On win64 THandle=QWord. > >Currently Thandle=longint for unix, but Thandle=DWord for win32. Yes, I am aware of that, my question however is is how to get things working. In the LCL a THandle is used everywhere and in most cases it represents a pointer. It is also part of the emulated message records. All members of it are defined as PtrInt. On placed where a handle is iused, it should map on a PtrInt. Woudl you suggest me to a) forbid the use of thandle b) change all records and places where thandle is used c) create a intermediate function which maps a handle to a pointer (and still change a load of records)

The RTL should stay clean of Windows specific issues.THandle is defined as the same type as filedescriptors on the target OS. When you need some handle for Windows emulation you can create your own type TLCLHandle that will be 64bit for all platforms.

Reply by email

Unknown author
to Peter Vreman
Peter Vreman wrote 40 lines
>>>>> Hi, >>>>> >>>>> From what I understand from the definition of THandle in >>>>> sysunixh.inc it is defined as a LongInt, even on 64 bit platforms. >>>>> Currently I'm porting Lazarus to x64 and there I need a 64bit >>>>> THandle, how to solve it ? >>>> >>>>File descriptors are still 32bit on x86_64, therefor Thandle=32bit. >>> >>> A THandle is more than a file descriptor alone. >>> Since the LCL is VCL compatible and thus MS biassed, there are more >>> THandles than filedescriptors alone. To keep code compatible >>and portable, >>> I need a 64 bit THandle on 64 bit platforms. (on win64 a handle is also >>> 64bit). >>> Or would you suggest to use HANDLE for a 64bit handle and THandle for >>> 32bit ? >> >>THandle is platform dependent. On win64 THandle=QWord. >> >>Currently Thandle=longint for unix, but Thandle=DWord for win32. > > Yes, I am aware of that, my question however is is how to get things > working. > > In the LCL a THandle is used everywhere and in most cases it represents a > pointer. It is also part of the emulated message records. All members of > it are defined as PtrInt. On placed where a handle is iused, it should map > on a PtrInt. > > Woudl you suggest me to > a) forbid the use of thandle > b) change all records and places where thandle is used > c) create a intermediate function which maps a handle to a pointer > (and still change a load of records) The RTL should stay clean of Windows specific issues.THandle is defined as the same type as filedescriptors on the target OS. When you need some handle for Windows emulation you can create your own type TLCLHandle that will be 64bit for all platforms.

I guess this is supposed to be "64-bit on 64-bit platforms" ?

In general, Peter is right, and it would be better to introduce a separate type for the 'windows handle': TWinHandle or TLCLHandle which is platform dependent.

OTOH, We could also reverse the argument and introduce TFileHandle, so as to clearly mark the fact that it is for files only...

Michael.

Reply by email

Marc Weustink
to Unknown author
Show quoted text 44 lines
On Mon, 20 Dec 2004, Peter Vreman wrote: > >>>>> Hi, > >>>>> > >>>>> From what I understand from the definition of THandle in > >>>>> sysunixh.inc it is defined as a LongInt, even on 64 bit platforms. > >>>>> Currently I'm porting Lazarus to x64 and there I need a 64bit > >>>>> THandle, how to solve it ? > >>>> > >>>>File descriptors are still 32bit on x86_64, therefor Thandle=32bit. > >>> > >>> A THandle is more than a file descriptor alone. > >>> Since the LCL is VCL compatible and thus MS biassed, there are more > >>> THandles than filedescriptors alone. To keep code compatible > >>> and portable, > >>> I need a 64 bit THandle on 64 bit platforms. (on win64 a handle is also > >>> 64bit). > >>> Or would you suggest to use HANDLE for a 64bit handle and THandle for > >>> 32bit ? > >> > >>THandle is platform dependent. On win64 THandle=QWord. > >> > >>Currently Thandle=longint for unix, but Thandle=DWord for win32. > > > > Yes, I am aware of that, my question however is is how to get things > > working. > > > > In the LCL a THandle is used everywhere and in most cases it represents a > > pointer. It is also part of the emulated message records. All members of > > it are defined as PtrInt. On placed where a handle is iused, it should > > map on a PtrInt. > > > > Woudl you suggest me to > > a) forbid the use of thandle > > b) change all records and places where thandle is used > > c) create a intermediate function which maps a handle to a pointer > > (and still change a load of records) > > The RTL should stay clean of Windows specific issues.THandle is defined as > the same type as filedescriptors on the target OS. When you need some > handle for Windows emulation you can create your own type TLCLHandle that > will be 64bit for all platforms. I guess this is supposed to be "64-bit on 64-bit platforms" ?

Guess so :)

In general, Peter is right,

(sorry, I couldn't resist :)

and it would be better to introduce a separate type for the 'windows handle': TWinHandle or TLCLHandle which is platform dependent.

I've been thinking of a TLCLHandle, but one of the goals of Lazarus is to keep Delphi apps easy portable. And replacing all THandles with TLCLHandle doesn't sound very port friendly to me. Besides, since THandle is defined in system, if someone forgets to change it, the ported app will probably compile with only a easy to miss warning, whith all resulting errors. But I understand that this has nothing to with the choice of a THandle beeing 32 bit.

OTOH, We could also reverse the argument and introduce TFileHandle, so as to clearly mark the fact that it is for files only...

That would be my choice also.
For me a THandle is a generic abstract identifier, which can identify a file, a window, a process, a thread, a event, a bitmap, a pen, a brush, a region, a font, a DC, a whatever_I_forgot_more
THandle is used as basetype for all these types of handles. And personally I think it is a bit limitted to use it only for a filehandle.

Marc

Reply by email

Tomas Hajny
to Marc Weustink

Date sent: Mon, 20 Dec 2004 21:02:04 +0100
To: "FPC developers' list"
From: Marc Weustink
Subject: RE: [fpc-devel] THandle and 64bit platforms Send reply to: FPC developers' list

Show quoted text 22 lines
> > >>>>File descriptors are still 32bit on x86_64, therefor > > >>>>Thandle=32bit. > > >>> > > >>> A THandle is more than a file descriptor alone. > > >>> Since the LCL is VCL compatible and thus MS biassed, there are > > >>> more THandles than filedescriptors alone. To keep code > > >>> compatible and portable, I need a 64 bit THandle on 64 bit > > >>> platforms. (on win64 a handle is also 64bit). Or would you > > >>> suggest to use HANDLE for a 64bit handle and THandle for 32bit > > >>> ? > > >> > > >>THandle is platform dependent. On win64 THandle=QWord. > > >> > > >>Currently Thandle=longint for unix, but Thandle=DWord for win32. > > > > > > Yes, I am aware of that, my question however is is how to get > > > things working. > > > > > > In the LCL a THandle is used everywhere and in most cases it > > > represents a pointer. It is also part of the emulated message > > > records. All members of it are defined as PtrInt. On placed > > > where a handle is iused, it should map on a PtrInt.

.
.

Show quoted text 6 lines
That would be my choice also. For me a THandle is a generic abstract identifier, which can identify a file, a window, a process, a thread, a event, a bitmap, a pen, a brush, a region, a font, a DC, a whatever_I_forgot_more THandle is used as basetype for all these types of handles. And personally I think it is a bit limitted to use it only for a filehandle.

Well, whereas I agree that handles can be more than file descriptors, I don't see any connection between this fact and requirement to have handles of the same size as pointers (although I understand your reason)... In addition, having handles incompatible to file descriptors would break Delphi compatibility as well. Proper emulation of Windows handles would IMHO probably really require some kind of mapping between handles and pointers as mentioned in one of your previous e-mails.

Tomas

Reply by email

Tomas Hajny
to Unknown author: In principle, a windows handle is an 'opaque' type. You're not supposed to make any…

Date sent: Mon, 20 Dec 2004 22:50:06 +0100 (CET) From:
To: ,
"FPC developers' list"
Subject: RE: [fpc-devel] THandle and 64bit platforms Copies to: Send reply to: FPC developers' list

.
.

Show quoted text 12 lines
> > > > > In the LCL a THandle is used everywhere and in most cases it > > > > > represents a pointer. It is also part of the emulated > > > > > message records. All members of it are defined as PtrInt. On > > > > > placed where a handle is iused, it should map on a PtrInt. > . > . In principle, a windows handle is an 'opaque' type. You're not supposed to make any assumptions about it's size or internal structure. That Windows uses the same handle type for the I/O API and it's GUI subsystem is an unfortunate coincidence.

Probably more design decision than "coincidence" - the same type is used for everything, not just I/O and GUI, but processes, threads and all kinds of system resources too.

Show quoted text 7 lines
Thinking about it some more I think the more 'correct' choice for Lazarus is to introduce a TLCLHandle type, which will be equal to a HANDLE (or THANDLE) type on Windows, but which probably will equal a pointer under e.g. GTK, and hence a 64-bit pointer on 64-bit platforms. This will take some work :-)

.
.

Would THandle exist on non-Windows platforms under your concept then? If so, what would it be on Linux x86-64 (by pure coincidence, of course ;-) )?

Tomas

Reply by email

Unknown author
to Tomas Hajny: Date sent: Mon, 20 Dec 2004 21:02:04 +0100 To: "FPC developers' list"…
Tomas Hajny wrote 47 lines
Date sent: Mon, 20 Dec 2004 21:02:04 +0100 To: "FPC developers' list" From: Marc Weustink Subject: RE: [fpc-devel] THandle and 64bit platforms Send reply to: FPC developers' list > > > >>>>File descriptors are still 32bit on x86_64, therefor > > > >>>>Thandle=32bit. > > > >>> > > > >>> A THandle is more than a file descriptor alone. > > > >>> Since the LCL is VCL compatible and thus MS biassed, there are > > > >>> more THandles than filedescriptors alone. To keep code > > > >>> compatible and portable, I need a 64 bit THandle on 64 bit > > > >>> platforms. (on win64 a handle is also 64bit). Or would you > > > >>> suggest to use HANDLE for a 64bit handle and THandle for 32bit > > > >>> ? > > > >> > > > >>THandle is platform dependent. On win64 THandle=QWord. > > > >> > > > >>Currently Thandle=longint for unix, but Thandle=DWord for win32. > > > > > > > > Yes, I am aware of that, my question however is is how to get > > > > things working. > > > > > > > > In the LCL a THandle is used everywhere and in most cases it > > > > represents a pointer. It is also part of the emulated message > > > > records. All members of it are defined as PtrInt. On placed > > > > where a handle is iused, it should map on a PtrInt. . . > That would be my choice also. > For me a THandle is a generic abstract identifier, which can identify > a file, a window, a process, a thread, a event, a bitmap, a pen, a > brush, a region, a font, a DC, a whatever_I_forgot_more THandle is > used as basetype for all these types of handles. And personally I > think it is a bit limitted to use it only for a filehandle. Well, whereas I agree that handles can be more than file descriptors, I don't see any connection between this fact and requirement to have handles of the same size as pointers (although I understand your reason)... In addition, having handles incompatible to file descriptors would break Delphi compatibility as well. Proper emulation of Windows handles would IMHO probably really require some kind of mapping between handles and pointers as mentioned in one of your previous e-mails.

In principle, a windows handle is an 'opaque' type. You're not supposed to make any assumptions about it's size or internal structure.

That Windows uses the same handle type for the I/O API and it's GUI subsystem is an unfortunate coincidence.

Thinking about it some more I think the more 'correct' choice for Lazarus is to introduce a TLCLHandle type, which will be equal to a HANDLE (or THANDLE) type on Windows, but which probably will equal a pointer under e.g. GTK, and hence a 64-bit pointer on 64-bit platforms.

This will take some work :-)

That said, the RTL should also avoid confusion with the Windows/Delphi THandle type, and introduce a cross-platform and opaque TFileHandle type. Which will happen to be equal to THandle on 32-bit windows. On 32-bit Linux, the definition of THandle will then also equal TFileHandle.

This will also take some work :-)

The 2.000.000.000 EUR question is then, who will do this work? ;-)

Michael.

Reply by email

Unknown author
to Tomas Hajny: Date sent: Mon, 20 Dec 2004 22:50:06 +0100 (CET) From: "FPC developers' list"…
Tomas Hajny wrote 27 lines
Date sent: Mon, 20 Dec 2004 22:50:06 +0100 (CET) From: To: , "FPC developers' list" Subject: RE: [fpc-devel] THandle and 64bit platforms Copies to: Send reply to: FPC developers' list . . > > > > > > In the LCL a THandle is used everywhere and in most cases it > > > > > > represents a pointer. It is also part of the emulated > > > > > > message records. All members of it are defined as PtrInt. On > > > > > > placed where a handle is iused, it should map on a PtrInt. > > . > > . > In principle, a windows handle is an 'opaque' type. > You're not supposed to make any assumptions about it's size or > internal structure. > > That Windows uses the same handle type for the I/O API and it's GUI > subsystem is an unfortunate coincidence. Probably more design decision than "coincidence" - the same type is used for everything, not just I/O and GUI, but processes, threads and all kinds of system resources too.

A matter of preference, I prefer the Unix way of pid_t, mode_t, size_t. Allows more freedom, in my opinion.

The handles are not compatible anyway. It doesn't make much sense to send a windows message to a file handle ;-)

Show quoted text 11 lines
> Thinking about it some more I think the more 'correct' choice for > Lazarus is to introduce a TLCLHandle type, which will be equal to a > HANDLE (or THANDLE) type on Windows, but which probably will equal a > pointer under e.g. GTK, and hence a 64-bit pointer on 64-bit > platforms. > > This will take some work :-) . . Would THandle exist on non-Windows platforms under your concept then?

Yes. But only for compatibility.

If so, what would it be on Linux x86-64 (by pure coincidence, of course ;-) )?

Whatever TFileHandle is, obviously :)

Michael.

Reply by email

Florian Klaempfl
to Unknown author: In principle, a windows handle is an 'opaque' type. You're not supposed to make any…
Show quoted text 71 lines
On Mon, 20 Dec 2004, Tomas Hajny wrote: >Date sent: Mon, 20 Dec 2004 21:02:04 +0100 >To: "FPC developers' list" >From: Marc Weustink >Subject: RE: [fpc-devel] THandle and 64bit platforms >Send reply to: FPC developers' list > > > >>>>>>>>File descriptors are still 32bit on x86_64, therefor >>>>>>>>Thandle=32bit. >>>>>>> >>>>>>>A THandle is more than a file descriptor alone. >>>>>>>Since the LCL is VCL compatible and thus MS biassed, there are >>>>>>>more THandles than filedescriptors alone. To keep code >>>>>>>compatible and portable, I need a 64 bit THandle on 64 bit >>>>>>>platforms. (on win64 a handle is also 64bit). Or would you >>>>>>>suggest to use HANDLE for a 64bit handle and THandle for 32bit >>>>>>>? >>>>>> >>>>>>THandle is platform dependent. On win64 THandle=QWord. >>>>>> >>>>>>Currently Thandle=longint for unix, but Thandle=DWord for win32. >>>>> >>>>>Yes, I am aware of that, my question however is is how to get >>>>>things working. >>>>> >>>>>In the LCL a THandle is used everywhere and in most cases it >>>>>represents a pointer. It is also part of the emulated message >>>>>records. All members of it are defined as PtrInt. On placed >>>>>where a handle is iused, it should map on a PtrInt. > > . > . > >>That would be my choice also. >>For me a THandle is a generic abstract identifier, which can identify >>a file, a window, a process, a thread, a event, a bitmap, a pen, a >>brush, a region, a font, a DC, a whatever_I_forgot_more THandle is >>used as basetype for all these types of handles. And personally I >>think it is a bit limitted to use it only for a filehandle. > >Well, whereas I agree that handles can be more than file descriptors, >I don't see any connection between this fact and requirement to have >handles of the same size as pointers (although I understand your >reason)... In addition, having handles incompatible to file >descriptors would break Delphi compatibility as well. Proper >emulation of Windows handles would IMHO probably really require some >kind of mapping between handles and pointers as mentioned in one of >your previous e-mails. In principle, a windows handle is an 'opaque' type. You're not supposed to make any assumptions about it's size or internal structure. That Windows uses the same handle type for the I/O API and it's GUI subsystem is an unfortunate coincidence. Thinking about it some more I think the more 'correct' choice for Lazarus is to introduce a TLCLHandle type, which will be equal to a HANDLE (or THANDLE) type on Windows, but which probably will equal a pointer under e.g. GTK, and hence a 64-bit pointer on 64-bit platforms. This will take some work :-) That said, the RTL should also avoid confusion with the Windows/Delphi THandle type, and introduce a cross-platform and opaque TFileHandle type.

It's text/file/file of in pascal ;)

Which will happen to be equal to THandle on 32-bit windows. On 32-bit Linux, the definition of THandle will then also equal TFileHandle. This will also take some work :-)

I guess this is no solution. It makes porting delphi apps very hard. What's the problem if thandle is 64 bit on 64 bit systems? You can still store a 32 bit file handle in it.

Reply by email

Unknown author
to Florian Klaempfl
Florian Klaempfl wrote 74 lines
wrote: > > On Mon, 20 Dec 2004, Tomas Hajny wrote: > > >>Date sent: Mon, 20 Dec 2004 21:02:04 +0100 >>To: "FPC developers' list" >>From: Marc Weustink >>Subject: RE: [fpc-devel] THandle and 64bit platforms >>Send reply to: FPC developers' list >> >> >> >>>>>>>>>File descriptors are still 32bit on x86_64, therefor >>>>>>>>>Thandle=32bit. >>>>>>>> >>>>>>>>A THandle is more than a file descriptor alone. >>>>>>>>Since the LCL is VCL compatible and thus MS biassed, there are >>>>>>>>more THandles than filedescriptors alone. To keep code >>>>>>>>compatible and portable, I need a 64 bit THandle on 64 bit >>>>>>>>platforms. (on win64 a handle is also 64bit). Or would you >>>>>>>>suggest to use HANDLE for a 64bit handle and THandle for 32bit >>>>>>>>? >>>>>>> >>>>>>>THandle is platform dependent. On win64 THandle=QWord. >>>>>>> >>>>>>>Currently Thandle=longint for unix, but Thandle=DWord for win32. >>>>>> >>>>>>Yes, I am aware of that, my question however is is how to get >>>>>>things working. >>>>>> >>>>>>In the LCL a THandle is used everywhere and in most cases it >>>>>>represents a pointer. It is also part of the emulated message >>>>>>records. All members of it are defined as PtrInt. On placed >>>>>>where a handle is iused, it should map on a PtrInt. >> >> . >> . >> >>>That would be my choice also. >>>For me a THandle is a generic abstract identifier, which can identify >>>a file, a window, a process, a thread, a event, a bitmap, a pen, a >>>brush, a region, a font, a DC, a whatever_I_forgot_more THandle is >>>used as basetype for all these types of handles. And personally I >>>think it is a bit limitted to use it only for a filehandle. >> >>Well, whereas I agree that handles can be more than file descriptors, >>I don't see any connection between this fact and requirement to have >>handles of the same size as pointers (although I understand your >>reason)... In addition, having handles incompatible to file >>descriptors would break Delphi compatibility as well. Proper >>emulation of Windows handles would IMHO probably really require some >>kind of mapping between handles and pointers as mentioned in one of >>your previous e-mails. > > > In principle, a windows handle is an 'opaque' type. > You're not supposed to make any assumptions about it's size or internal > structure. > > That Windows uses the same handle type for the I/O API and it's GUI > subsystem is an unfortunate coincidence. > > Thinking about it some more I think the more 'correct' choice for Lazarus > is to introduce a TLCLHandle type, which will be equal to a HANDLE > (or THANDLE) type on Windows, but which probably will equal a pointer > under e.g. GTK, and hence a 64-bit pointer on 64-bit platforms. > > This will take some work :-) > > That said, the RTL should also avoid confusion with the Windows/Delphi > THandle type, and introduce a cross-platform and opaque TFileHandle type. It's text/file/file of in pascal ;)

Not in sysutils and TStream, which is what Lazarus uses :-)

Show quoted text 9 lines
> Which will happen to be equal to THandle on 32-bit windows. > On 32-bit Linux, the definition of THandle will then also equal TFileHandle. > > This will also take some work :-) I guess this is no solution. It makes porting delphi apps very hard. What's the problem if thandle is 64 bit on 64 bit systems? You can still store a 32 bit file handle in it.

But, as far as I understood, this is exactly the problem: According to Peter, THandle is still 32-bit on Linux/64, and Marc wants it to be 64 bit ?

Michael.

Reply by email

Marc Weustink
to Unknown author: In principle, a windows handle is an 'opaque' type. You're not supposed to make any…
Show quoted text 39 lines
On Mon, 20 Dec 2004, Tomas Hajny wrote: > From: Marc Weustink > > > > >>>>File descriptors are still 32bit on x86_64, therefor > > > > >>>>Thandle=32bit. > > > > >>> > > > > >>> A THandle is more than a file descriptor alone. > > > > >>> Since the LCL is VCL compatible and thus MS biassed, there are > > > > >>> more THandles than filedescriptors alone. To keep code > > > > >>> compatible and portable, I need a 64 bit THandle on 64 bit > > > > >>> platforms. (on win64 a handle is also 64bit). Or would you > > > > >>> suggest to use HANDLE for a 64bit handle and THandle for 32bit > > > > >>> ? > > > > >> > > > > >>THandle is platform dependent. On win64 THandle=QWord. > > > > >> > > > > >>Currently Thandle=longint for unix, but Thandle=DWord for win32. > > > > > > > > > > Yes, I am aware of that, my question however is is how to get > > > > > things working. > > > > > > > > > > In the LCL a THandle is used everywhere and in most cases it > > > > > represents a pointer. It is also part of the emulated message > > > > > records. All members of it are defined as PtrInt. On placed > > > > > where a handle is iused, it should map on a PtrInt. > . > . > > That would be my choice also. > > For me a THandle is a generic abstract identifier, which can identify > > a file, a window, a process, a thread, a event, a bitmap, a pen, a > > brush, a region, a font, a DC, a whatever_I_forgot_more THandle is > > used as basetype for all these types of handles. And personally I > > think it is a bit limitted to use it only for a filehandle. > > Well, whereas I agree that handles can be more than file descriptors, > I don't see any connection between this fact and requirement to have > handles of the same size as pointers (although I understand your > reason)... In addition, having handles incompatible to file > descriptors would break Delphi compatibility as well.

You still can store a TFileDescriptor in a THande

Show quoted text 8 lines
> Proper > emulation of Windows handles would IMHO probably really require some > kind of mapping between handles and pointers as mentioned in one of > your previous e-mails. In principle, a windows handle is an 'opaque' type. You're not supposed to make any assumptions about it's size or internal structure.

That is true (however you need the size of you want to ut it in records)

When I was programming win16, a handle was 16bit. And there it was indeed a handle (or index) to an internal table. On win32 handles became 32bit and more and more the internal pointer behind it.
To go back to the old way on win64 and add an extra indirection is a bit overhead (not in acessing, but in managing)

Show quoted text 7 lines
That Windows uses the same handle type for the I/O API and it's GUI subsystem is an unfortunate coincidence. Thinking about it some more I think the more 'correct' choice for Lazarus is to introduce a TLCLHandle type, which will be equal to a HANDLE (or THANDLE) type on Windows, but which probably will equal a pointer under e.g. GTK, and hence a 64-bit pointer on 64-bit platforms.

Since it is an opaque type, it now is a type Integer. On win32 it way contain a Handle, on gtk it may contain a pointer. A handle/pointer to what is oficially undefined.

This will take some work :-)

For adapting Lazarus I've no problems with it. For ppl wanting to port apps I see more problems. Especially when a shorter version of it exists. Besides I don't know what other Lazarus devels think

Show quoted text 8 lines
That said, the RTL should also avoid confusion with the Windows/Delphi THandle type, and introduce a cross-platform and opaque TFileHandle type. Which will happen to be equal to THandle on 32-bit windows. On 32-bit Linux, the definition of THandle will then also equal TFileHandle. This will also take some work :-) The 2.000.000.000 EUR question is then, who will do this work? ;-)

I did some counting:

Rtl: 489 times (excluding win32, including os2, including comments) Lazarus: 105 times (exluding win32 and docs)

Hmm..... I can give you an answer :)

Marc

Reply by email

Unknown author
to Marc Weustink
Marc Weustink wrote 5 lines
>This will take some work :-) For adapting Lazarus I've no problems with it. For ppl wanting to port apps I see more problems. Especially when a shorter version of it exists. Besides I don't know what other Lazarus devels think

People who want to write portable apps should definitely not make any assumptions about Thandle. Since TLCLhandle=Handle on windows, this should not really be a problem ?

Show quoted text 15 lines
>That said, the RTL should also avoid confusion with the Windows/Delphi >THandle type, and introduce a cross-platform and opaque TFileHandle type. >Which will happen to be equal to THandle on 32-bit windows. >On 32-bit Linux, the definition of THandle will then also equal TFileHandle. > >This will also take some work :-) > >The 2.000.000.000 EUR question is then, who will do this work? ;-) I did some counting: Rtl: 489 times (excluding win32, including os2, including comments) Lazarus: 105 times (exluding win32 and docs) Hmm..... I can give you an answer :)

But I cannot give you 2.000.000.000 EUR :)

Michael.

Reply by email

Marc Weustink
to Unknown author
Show quoted text 12 lines
On Tue, 21 Dec 2004, Marc Weustink wrote: > >This will take some work :-) > > For adapting Lazarus I've no problems with it. For ppl wanting to port apps > I see more problems. Especially when a shorter version of it exists. > Besides I don't know what other Lazarus devels think People who want to write portable apps should definitely not make any assumptions about Thandle. Since TLCLhandle=Handle on windows, this should not really be a problem ?

Except that they may have used it.

Show quoted text 18 lines
> >That said, the RTL should also avoid confusion with the Windows/Delphi > >THandle type, and introduce a cross-platform and opaque TFileHandle type. > >Which will happen to be equal to THandle on 32-bit windows. > >On 32-bit Linux, the definition of THandle will then also equal TFileHandle. > > > >This will also take some work :-) > > > >The 2.000.000.000 EUR question is then, who will do this work? ;-) > > I did some counting: > > Rtl: 489 times (excluding win32, including os2, including comments) > Lazarus: 105 times (exluding win32 and docs) > > Hmm..... I can give you an answer :) But I cannot give you 2.000.000.000 EUR :)

Bummer :(

Marc

Reply by email

Peter Vreman
to Florian Klaempfl: It's text/file/file of in pascal ;) I guess this is no solution. It makes porting delphi…
Show quoted text 15 lines
> That said, the RTL should also avoid confusion with the Windows/Delphi > THandle type, and introduce a cross-platform and opaque TFileHandle > type. It's text/file/file of in pascal ;) > Which will happen to be equal to THandle on 32-bit windows. > On 32-bit Linux, the definition of THandle will then also equal > TFileHandle. > > This will also take some work :-) I guess this is no solution. It makes porting delphi apps very hard. What's the problem if thandle is 64 bit on 64 bit systems? You can still store a 32 bit file handle in it.

It'll give a lot of Warnings when compiling the sources. And there is a risk for rangecheck errors.

I checked Kylix, there THandle=longword which is also incompatible with our THandle=longint under Linux.

My proposal is to rename the current THandle to TFileHandle. And add an platform independent type "THandle=PtrUInt".
Note that this can still cause range check errors under Unix, because invalid filedescriptors have (normally) value -1.

Reply by email

Florian Klaempfl
to Peter Vreman
Peter Vreman wrote 28 lines
>>That said, the RTL should also avoid confusion with the Windows/Delphi >>THandle type, and introduce a cross-platform and opaque TFileHandle >>type. > >It's text/file/file of in pascal ;) > > >>Which will happen to be equal to THandle on 32-bit windows. >>On 32-bit Linux, the definition of THandle will then also equal >>TFileHandle. >> >>This will also take some work :-) > >I guess this is no solution. It makes porting delphi apps very hard. >What's the problem if thandle is 64 bit on 64 bit systems? You can still >store a 32 bit file handle in it. It'll give a lot of Warnings when compiling the sources. And there is a risk for rangecheck errors. I checked Kylix, there THandle=longword which is also incompatible with our THandle=longint under Linux. My proposal is to rename the current THandle to TFileHandle. And add an platform independent type "THandle=PtrUInt". Note that this can still cause range check errors under Unix, because invalid filedescriptors have (normally) value -1.

Sounds good to me.

Reply by email

Marco van de Voort
to Unknown author: People who want to write portable apps should definitely not make any assumptions about…
Show quoted text 12 lines
On Tue, 21 Dec 2004, Marc Weustink wrote: > > > >The 2.000.000.000 EUR question is then, who will do this work? ;-) > > I did some counting: > > Rtl: 489 times (excluding win32, including os2, including comments) > Lazarus: 105 times (exluding win32 and docs) > > Hmm..... I can give you an answer :) But I cannot give you 2.000.000.000 EUR :)

Wait till after newyear's sweepstakes. You never know (unless you, like me, don't buy tickets)

Reply by email

Michael Van Canneyt
to Florian Klaempfl: Sounds good to me.
Florian Klaempfl wrote 32 lines
Peter Vreman wrote: >>>That said, the RTL should also avoid confusion with the Windows/Delphi >>>THandle type, and introduce a cross-platform and opaque TFileHandle >>>type. >> >>It's text/file/file of in pascal ;) >> >> >>>Which will happen to be equal to THandle on 32-bit windows. >>>On 32-bit Linux, the definition of THandle will then also equal >>>TFileHandle. >>> >>>This will also take some work :-) >> >>I guess this is no solution. It makes porting delphi apps very hard. >>What's the problem if thandle is 64 bit on 64 bit systems? You can still >>store a 32 bit file handle in it. > > > It'll give a lot of Warnings when compiling the sources. And there is a > risk for rangecheck errors. > > I checked Kylix, there THandle=longword which is also incompatible with > our THandle=longint under Linux. > > My proposal is to rename the current THandle to TFileHandle. And add an > platform independent type "THandle=PtrUInt". > Note that this can still cause range check errors under Unix, because > invalid filedescriptors have (normally) value -1. Sounds good to me.

If we rename THandle to TFileHandle then we should use it where needed, so we don't get any range check errors.

Michael.

Reply by email

Marc Weustink
to Florian Klaempfl: Sounds good to me.
Show quoted text 37 lines
From: Behalf Of Florian Klaempfl Sent: dinsdag 21 december 2004 8:30 Peter Vreman wrote: >>>That said, the RTL should also avoid confusion with the Windows/Delphi >>>THandle type, and introduce a cross-platform and opaque TFileHandle >>>type. >> >>It's text/file/file of in pascal ;) >> >> >>>Which will happen to be equal to THandle on 32-bit windows. >>>On 32-bit Linux, the definition of THandle will then also equal >>>TFileHandle. >>> >>>This will also take some work :-) >> >>I guess this is no solution. It makes porting delphi apps very hard. >>What's the problem if thandle is 64 bit on 64 bit systems? You >>can still store a 32 bit file handle in it. > > > It'll give a lot of Warnings when compiling the sources. And there is a > risk for rangecheck errors. > > I checked Kylix, there THandle=longword which is also incompatible with > our THandle=longint under Linux. > > My proposal is to rename the current THandle to TFileHandle. And add an > platform independent type "THandle=PtrUInt". > Note that this can still cause range check errors under Unix, because > invalid filedescriptors have (normally) value -1. Sounds good to me.

This would be nice

Marc

Reply by email

Vincent Snijders
to Marc Weustink
Marc Weustink wrote 18 lines
>From: > Behalf Of Florian >Klaempfl >Sent: dinsdag 21 december 2004 8:30 > >Peter Vreman wrote: > > >>My proposal is to rename the current THandle to TFileHandle. And add an >>platform independent type "THandle=PtrUInt". >>Note that this can still cause range check errors under Unix, because >>invalid filedescriptors have (normally) value -1. > >Sounds good to me. This would be nice

As far as I could see in the sources, this renaming has not been done yet. Is there any time schedule? Should I make a bug report?

Vincent.

Reply by email