[fpc-devel] Some more THandle problems

Sven Barth pascaldragon at googlemail.com
Sun Nov 21 12:42:13 CET 2010


On 20.11.2010 14:13, Sergei Gorelkin wrote:
> Sven Barth пишет:
>> Hello together!
>>
>> While getting SysUtils and Classes to compile for Native NT I've
>> stumbled upon some more spots where Handle=LongInt/LongWord is assumed.
>>
>> 1. In objpas/sysutils/filutilh.inc and its implementation
>> objpas/sysutils/fina.inc the GetFileHandle functions are defined with
>> return type LongInt, but TFileRec.Handle and TFileRec.Handle are
>> defined as THandle (which is - as we know - QWord on Win64).
>>
>> 2. THandleStream has a field FHandle which is defined as Integer. Now
>> this handle is filled either by the constructor which takes an Integer
>> as well or by e.g. TFileStream which gets its handle from
>> FileOpen/FileCreate. Those return a THandle and you might guess what
>> happens if a value >= 2^32 is returned. ^^
>>
> 1 and 2 fixed in rev. 16383
>

Thank you. :D

>> 3. The handle types for resource streams are defined as PtrUInt while
>> the handle for Native NT is defined as Pointer.
>> For me locally I've fixed this my casting the handles to the
>> FPResource* types, but I might have reached the point where I should
>> change my handle type from Pointer to PtrUInt, because the pros (no
>> more Ordinal <-> Pointer conflicts) outweigh the cons (no more strict
>> following of the ReactOS headers).
>>
> As long as you use a dedicated type like THandle everywhere, redefining
> it should be no trouble.

As I'm either using THandle itself or a type "derived" from it (type 
HANDLE = THandle), I see no real problem here.

> The problem is to spot places where such type is intermixed with other
> types.
>

I don't think that I have such spots.

>> I can provide patches for 1 and 2 in bug reports if you want, but I
>> won't touch the resource related parts mentioned in 3 cause those
>> issues will be fixed when I provide my patch for the Native NT RTL (by
>> changing THandle from Pointer to PtrUInt).
>>
>> But I've discovered some nice THandle problems while THandle was
>> defined as Pointer. :D
>>
> Indeed, these small bits make up the big picture. Thank you!

You're welcome.

Regards,
Sven



More information about the fpc-devel mailing list