lcore.org gitweb
/
lcore.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
wrapped rdtsc and added x64 support
[lcore.git]
/
lcorernd.pas
diff --git
a/lcorernd.pas
b/lcorernd.pas
index 648c87aa67cbb357ab4cd7d19c479dda6caa6d7d..3a8ea0c993b280d0cefc63024a5367a31c317922 100644
(file)
--- a/
lcorernd.pas
+++ b/
lcorernd.pas
@@
-130,6
+130,8
@@
var
\r
implementation
\r
\r
\r
implementation
\r
\r
+{$include pgtypes.inc}
\r
+
\r
{$ifndef nolcorernd}
\r
uses
\r
{$ifdef mswindows}windows,activex,{$endif}
\r
{$ifndef nolcorernd}
\r
uses
\r
{$ifdef mswindows}windows,activex,{$endif}
\r
@@
-144,6
+146,23
@@
uses
\r
{$ifdef unix}{$include unixstuff.inc}{$endif}
\r
\r
\r
{$ifdef unix}{$include unixstuff.inc}{$endif}
\r
\r
+procedure rdtsc(buf: pointer);
\r
+asm
\r
+ {$ifdef cpux86}
\r
+ mov ecx, buf
\r
+ db $0f; db $31 {rdtsc}
\r
+ mov [ecx], edx
\r
+ mov [ecx+4], eax
\r
+ {$endif}
\r
+
\r
+ {$ifdef cpux64}
\r
+ mov rcx, buf
\r
+ rdtsc
\r
+ mov [rcx], edx
\r
+ mov [rcx+4], eax
\r
+ {$endif}
\r
+end;
\r
+
\r
type
\r
{hashtype must be array of bytes}
\r
hashtype=tmd5;
\r
type
\r
{hashtype must be array of bytes}
\r
hashtype=tmd5;
\r
@@
-178,7
+197,6
@@
var
cursor:tpoint;
\r
hs:theapstatus;
\r
end absolute output;
\r
cursor:tpoint;
\r
hs:theapstatus;
\r
end absolute output;
\r
- rdtsc_0,rdtsc_1:integer;
\r
begin
\r
result := 0;
\r
if (bufsize < sizeof(l)) then exit;
\r
begin
\r
result := 0;
\r
if (bufsize < sizeof(l)) then exit;
\r
@@
-194,15
+212,8
@@
begin
queryperformancecounter(tlargeinteger(l.qpcbuf));
\r
\r
{RDTSC}
\r
queryperformancecounter(tlargeinteger(l.qpcbuf));
\r
\r
{RDTSC}
\r
- {$ifdef cpu386}
\r
- asm
\r
- db $0F; db $31
\r
- mov rdtsc_0,eax
\r
- mov rdtsc_1,edx
\r
- end;
\r
- l.rdtscbuf[0] := rdtsc_0;
\r
- l.rdtscbuf[1] := rdtsc_1;
\r
- {$endif}
\r
+ rdtsc(@l.rdtscbuf);
\r
+
\r
{GETSYSTEMTIME}
\r
getsystemtime(tsystemtime(l.systemtimebuf));
\r
\r
{GETSYSTEMTIME}
\r
getsystemtime(tsystemtime(l.systemtimebuf));
\r
\r
@@
-253,7
+264,6
@@
var
tv:ttimeval;
\r
pid:integer;
\r
end absolute output;
\r
tv:ttimeval;
\r
pid:integer;
\r
end absolute output;
\r
- rdtsc_0,rdtsc_1:integer;
\r
\r
begin
\r
result := 0;
\r
\r
begin
\r
result := 0;
\r
@@
-280,15
+290,7
@@
begin
move(wtmpcached,l.devrnd,sizeof(l.devrnd));
\r
end;
\r
{get more randomness in case there's no /dev/random}
\r
move(wtmpcached,l.devrnd,sizeof(l.devrnd));
\r
end;
\r
{get more randomness in case there's no /dev/random}
\r
- {$ifdef cpu386}{$ASMMODE intel}
\r
- asm
\r
- db $0F; db $31
\r
- mov rdtsc_0,eax
\r
- mov rdtsc_1,edx
\r
- end;
\r
- l.rdtscbuf[0] := rdtsc_0;
\r
- l.rdtscbuf[1] := rdtsc_1;
\r
- {$endif}
\r
+ rdtsc(@l.rdtscbuf);
\r
\r
gettimeofday(l.tv);
\r
l.pid := getpid;
\r
\r
gettimeofday(l.tv);
\r
l.pid := getpid;
\r