X-Git-Url: http://www.lcore.org/git/lcore.git/blobdiff_plain/8a616f3f3967a8446407e6a63f675d19191ad568..90c7057fc0ae5d85a6443e7633642ef43553ab28:/lcorernd.pas?ds=inline diff --git a/lcorernd.pas b/lcorernd.pas index 648c87a..3a8ea0c 100644 --- a/lcorernd.pas +++ b/lcorernd.pas @@ -130,6 +130,8 @@ var implementation +{$include pgtypes.inc} + {$ifndef nolcorernd} uses {$ifdef mswindows}windows,activex,{$endif} @@ -144,6 +146,23 @@ uses {$ifdef unix}{$include unixstuff.inc}{$endif} +procedure rdtsc(buf: pointer); +asm + {$ifdef cpux86} + mov ecx, buf + db $0f; db $31 {rdtsc} + mov [ecx], edx + mov [ecx+4], eax + {$endif} + + {$ifdef cpux64} + mov rcx, buf + rdtsc + mov [rcx], edx + mov [rcx+4], eax + {$endif} +end; + type {hashtype must be array of bytes} hashtype=tmd5; @@ -178,7 +197,6 @@ var cursor:tpoint; hs:theapstatus; end absolute output; - rdtsc_0,rdtsc_1:integer; begin result := 0; if (bufsize < sizeof(l)) then exit; @@ -194,15 +212,8 @@ begin queryperformancecounter(tlargeinteger(l.qpcbuf)); {RDTSC} - {$ifdef cpu386} - asm - db $0F; db $31 - mov rdtsc_0,eax - mov rdtsc_1,edx - end; - l.rdtscbuf[0] := rdtsc_0; - l.rdtscbuf[1] := rdtsc_1; - {$endif} + rdtsc(@l.rdtscbuf); + {GETSYSTEMTIME} getsystemtime(tsystemtime(l.systemtimebuf)); @@ -253,7 +264,6 @@ var tv:ttimeval; pid:integer; end absolute output; - rdtsc_0,rdtsc_1:integer; begin result := 0; @@ -280,15 +290,7 @@ begin move(wtmpcached,l.devrnd,sizeof(l.devrnd)); end; {get more randomness in case there's no /dev/random} - {$ifdef cpu386}{$ASMMODE intel} - asm - db $0F; db $31 - mov rdtsc_0,eax - mov rdtsc_1,edx - end; - l.rdtscbuf[0] := rdtsc_0; - l.rdtscbuf[1] := rdtsc_1; - {$endif} + rdtsc(@l.rdtscbuf); gettimeofday(l.tv); l.pid := getpid;