X-Git-Url: http://www.lcore.org/git/lcore.git/blobdiff_plain/e27ef2c6aab3a2a8051314bd37bb3b2386775f36..f0a6e6591b3d306641b78dfed4a4066935e82096:/lcorernd.pas?ds=sidebyside diff --git a/lcorernd.pas b/lcorernd.pas index 3e43bb1..8f79856 100644 --- a/lcorernd.pas +++ b/lcorernd.pas @@ -130,9 +130,11 @@ var implementation +{$include pgtypes.inc} + {$ifndef nolcorernd} uses - {$ifdef win32}windows,activex,{$endif} + {$ifdef mswindows}windows,activex,{$endif} {$ifdef unix} {$ifdef ver1_0} linux, @@ -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; @@ -165,7 +184,7 @@ var pool:array[0..(pooldwords+seeddwords-1)] of wordtype; reseedcountdown:integer; -{$ifdef win32} +{$ifdef mswindows} function collect_seeding(var output;const bufsize:integer):integer; var l:packed record @@ -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)); @@ -248,12 +259,11 @@ var f:file; a:integer; l:packed record - devrnd:array[0..3] of integer; + devrnd:array[0..7] of integer; rdtscbuf:array[0..1] of integer; 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;