mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-06-05 07:58:31 +02:00
+ add reverse_longword() function that reverses the bit pattern for a longword, just like reverse_byte() and reverse_word() do for Byte and Word respectively
git-svn-id: trunk@39264 -
This commit is contained in:
parent
1c9ea4c120
commit
af6f094420
@ -69,6 +69,8 @@ interface
|
||||
function reverse_byte(b: byte): byte;
|
||||
{# Return @var(w) with the bit order reversed }
|
||||
function reverse_word(w: word): word;
|
||||
{# Return @var(l) with the bit order reversed }
|
||||
function reverse_longword(l: longword): longword;
|
||||
|
||||
function next_prime(l: longint): longint;
|
||||
|
||||
@ -292,6 +294,21 @@ implementation
|
||||
TWordRec(reverse_word).lo := reverse_byte(TWordRec(w).hi);
|
||||
end;
|
||||
|
||||
|
||||
function reverse_longword(l: longword): longword;
|
||||
type
|
||||
TLongWordRec = packed record
|
||||
b: array[0..3] of Byte;
|
||||
end;
|
||||
|
||||
begin
|
||||
TLongWordRec(reverse_longword).b[0] := reverse_byte(TLongWordRec(l).b[3]);
|
||||
TLongWordRec(reverse_longword).b[1] := reverse_byte(TLongWordRec(l).b[2]);
|
||||
TLongWordRec(reverse_longword).b[2] := reverse_byte(TLongWordRec(l).b[1]);
|
||||
TLongWordRec(reverse_longword).b[3] := reverse_byte(TLongWordRec(l).b[0]);
|
||||
end;
|
||||
|
||||
|
||||
function align(i,a:longint):longint;{$ifdef USEINLINE}inline;{$endif}
|
||||
{
|
||||
return value <i> aligned <a> boundary
|
||||
|
Loading…
Reference in New Issue
Block a user