summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjonas <jonas@3ad0048d-3df7-0310-abae-a5850022a9f2>2007-03-09 13:55:39 +0000
committerjonas <jonas@3ad0048d-3df7-0310-abae-a5850022a9f2>2007-03-09 13:55:39 +0000
commit9baf6929edcc5952fe5a5581ed68d210601aa4ae (patch)
treef323c08fd6ed593cfa60348f6c981def2ec92b34
parent8b699e2b8355291f3162f0a8220f979389f01221 (diff)
downloadfpc-9baf6929edcc5952fe5a5581ed68d210601aa4ae.tar.gz
Merged revisions 6752 via svnmerge from
svn+ssh://jonas@svn.freepascal.org/FPC/svn/fpc/trunk ........ r6752 | jonas | 2007-03-08 23:30:12 +0100 (Thu, 08 Mar 2007) | 3 lines * fixed swap(integer) due to counter-intuitive TP/Delphi compatible shr-behaviour ........ git-svn-id: http://svn.freepascal.org/svn/fpc/branches/fixes_2_2@6755 3ad0048d-3df7-0310-abae-a5850022a9f2
-rw-r--r--rtl/inc/system.inc6
1 files changed, 5 insertions, 1 deletions
diff --git a/rtl/inc/system.inc b/rtl/inc/system.inc
index 99e8a90c5f..8627619a4d 100644
--- a/rtl/inc/system.inc
+++ b/rtl/inc/system.inc
@@ -190,7 +190,11 @@ End;
Function Swap (X : Integer) : Integer;{$ifdef SYSTEMINLINE}inline;{$endif}
Begin
- swap:=(X and $ff) shl 8 + (X shr 8)
+ { the extra 'and $ff' in the right term is necessary because the }
+ { 'X shr 8' is turned into "longint(X) shr 8", so if x < 0 then }
+ { the sign bits from the upper 16 bits are shifted in rather than }
+ { zeroes. Another bug for TP/Delphi compatibility... }
+ swap:=(X and $ff) shl 8 + ((X shr 8) and $ff)
End;
Function swap (X : Longint) : Longint;{$ifdef SYSTEMINLINE}inline;{$endif}