source: branches/AlphaChannel/Platform.pas

Last change on this file was 207, checked in by chronos, 4 years ago
  • Fixed: Removed more compiler hints and warnings.
File size: 1.2 KB
Line 
1unit Platform;
2
3{$mode delphi}{$H+}
4
5interface
6
7uses
8 {$IFDEF Windows}Windows,{$ENDIF}
9 {$IFDEF Linux}Unix,{$ENDIF}
10 Classes, SysUtils, DateUtils, SyncObjs;
11
12function NowPrecise: TDateTime;
13
14implementation
15
16{$IFDEF Windows}
17var
18 PerformanceFrequency: Int64;
19{$ENDIF}
20
21var
22 NowPreciseLock: TCriticalSection;
23
24function NowPrecise: TDateTime;
25var
26 {$IFDEF Linux}T: TimeVal;{$ENDIF}
27 {$IFDEF Windows}TimerValue: Int64;{$ENDIF}
28begin
29// Result := Now;
30 //try
31 //NowPreciseLock.Acquire;
32 {$IFDEF Windows}
33 QueryPerformanceCounter(TimerValue);
34 //Result := Int64(TimeStampToMSecs(DateTimeToTimeStamp(Now)) * 1000) // an alternative Win32 timebase
35 Result := TimerValue / PerformanceFrequency;
36 {$ENDIF}
37
38 {$IFDEF Linux}
39 fpgettimeofday(@t, nil);
40 // Build a 64 bit microsecond tick from the seconds and microsecond longints
41 Result := t.tv_sec + t.tv_usec / 1000000;
42 {$ENDIF}
43
44 Result := Result * OneSecond;
45 //Result := (Trunc(Now / OneSecond) + Frac(Result)) * OneSecond;
46 //finally
47 //NowPreciseLock.Release;
48 //end;
49end;
50
51initialization
52
53{$IFDEF Windows}
54QueryPerformanceFrequency(PerformanceFrequency);
55{$ENDIF}
56NowPreciseLock := TCriticalSection.Create;
57
58finalization
59
60NowPreciseLock.Free;
61
62end.
63
Note: See TracBrowser for help on using the repository browser.