[fpc-devel] Fix for SwapEndian

Marc Weustink marc at dommelstein.net
Tue Apr 29 23:36:34 CEST 2008


Jonas Maebe wrote:
> 
> On 29 Apr 2008, at 17:00, Michael Schnell wrote:
> 
>>>> I think shr is supposed to work sign-extending with signed types.
>>>
>>> The above statement may cause some confusion, so people who think 
>>> that "shr" means "shift arithmetic right", please read the comment 
>>> added tohttp://bugs.freepascal.org/view.php?id=10545
>> OOPs !?!?!?!
>>
>> They say: "SHR is /always/ unsigned in TP/FPC/Delphi."
>>
>> This would mean that the patch the OP mentioned should not be necessary
> 
> No, it doesn't. The reason is explained in the comment.
> 
>> The stuff about first converting and then shifting seems quite queer 
>> (unless the types left and right are different which imposes queer 
>> behavior in C, too).
> 
> In Pascal, calculations are usually performed using the native integer 
> type, regardless of the left and right types (there are some exceptions, 
> but not many). That is not true for C.

Sorry, didn't realize that when I wrote those. (maybe still some 16 bit 
artifact)
The reason that some of them are dups of swap is that imo the only 
usefull implementation of swap is the word version. This was valid enoug 
for me to implement all in a same way/name.

Marc




More information about the fpc-devel mailing list