Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Synchronet
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Main
Synchronet
Commits
84a2bb32
Commit
84a2bb32
authored
3 years ago
by
Deucе
Browse files
Options
Downloads
Patches
Plain Diff
Add xp_timer64()
This is a millisecond timer that tries to avoid floating-point operations.
parent
ab673a5c
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!463
MRC mods by Codefenix (2024-10-20)
Pipeline
#2716
failed
3 years ago
Stage: build
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/xpdev/genwrap.c
+36
-0
36 additions, 0 deletions
src/xpdev/genwrap.c
src/xpdev/genwrap.h
+1
-0
1 addition, 0 deletions
src/xpdev/genwrap.h
with
37 additions
and
0 deletions
src/xpdev/genwrap.c
+
36
−
0
View file @
84a2bb32
...
...
@@ -825,6 +825,42 @@ long double xp_timer(void)
return
(
ret
);
}
/****************************************************************************/
/* Returns the current value of the systems best timer (in MILLISECONDS) */
/* Any value < 0 indicates an error */
/****************************************************************************/
uint64_t
xp_timer64
(
void
)
{
uint64_t
ret
;
#if defined(__unix__)
struct
timespec
ts
;
if
(
clock_gettime
(
CLOCK_MONOTONIC
,
&
ts
)
==
0
)
{
ret
=
ts
.
tv_sec
*
1000
;
ret
+=
ts
.
tv_nsec
/
1000000
;
}
else
ret
=
-
1
;
#elif defined(_WIN32)
LARGE_INTEGER
freq
;
LARGE_INTEGER
tick
;
if
(
if
(
QueryPerformanceFrequency
(
&
freq
)
&&
QueryPerformanceCounter
(
&
tick
))
{
static
BOOL
intable
=
(
freq
%
1000
)
==
0
;
if
(
intable
)
ret
=
tick
.
QuadPart
/
(
freq
.
QuadPart
/
1000
);
else
ret
=
((
double
)
tick
.
QuadPart
)
/
(((
double
)
freq
.
QuadPart
)
/
1000
);
}
else
{
ret
=
GetTickCount
();
}
#else
#error no high-resolution time for this platform
#endif
return
(
ret
);
}
/* Returns TRUE if specified process is running */
BOOL
check_pid
(
pid_t
pid
)
{
...
...
This diff is collapsed.
Click to expand it.
src/xpdev/genwrap.h
+
1
−
0
View file @
84a2bb32
...
...
@@ -353,6 +353,7 @@ DLLEXPORT void xp_randomize(void);
DLLEXPORT
long
xp_random
(
int
);
DLLEXPORT
long
double
xp_timer
(
void
);
DLLEXPORT
uint64_t
xp_timer64
(
void
);
DLLEXPORT
char
*
os_version
(
char
*
str
);
DLLEXPORT
char
*
os_cmdshell
(
void
);
DLLEXPORT
char
*
lastchar
(
const
char
*
str
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment