+ 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:
svenbarth 2018-06-20 21:10:19 +00:00
parent 1c9ea4c120
commit af6f094420

View File

@ -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