function randombits(b:integer):longint;\r
\r
{generate a version 4 random uuid}\r
-function generate_uuid:string;\r
+function generate_uuid:ansistring;\r
\r
{$ifndef nolcorernd}\r
\r
\r
implementation\r
\r
+{$include pgtypes.inc}\r
+\r
{$ifndef nolcorernd}\r
uses\r
- {$ifdef win32}windows,activex,{$endif}\r
+ {$ifdef mswindows}windows,activex,{$endif}\r
{$ifdef unix}\r
{$ifdef ver1_0}\r
linux,\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
pool:array[0..(pooldwords+seeddwords-1)] of wordtype;\r
reseedcountdown:integer;\r
\r
-{$ifdef win32}\r
+{$ifdef mswindows}\r
function collect_seeding(var output;const bufsize:integer):integer;\r
var\r
l:packed record\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
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
tv:ttimeval;\r
pid:integer;\r
end absolute output;\r
- rdtsc_0,rdtsc_1:integer;\r
\r
begin\r
result := 0;\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
end;\r
\r
const\r
- ch:array[0..15] of char='0123456789abcdef';\r
+ ch:array[0..15] of ansichar='0123456789abcdef';\r
\r
-function generate_uuid:string;\r
+function generate_uuid:ansistring;\r
var\r
buf:array[0..7] of word;\r
-function inttohex(w:word):string;\r
+function inttohex(w:word):ansistring;\r
begin\r
result := ch[w shr 12] + ch[(w shr 8) and $f] + ch[(w shr 4) and $f] + ch[w and $f];\r
end;\r