Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Tor
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
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
orbea
Tor
Commits
5eaba5ac
Commit
5eaba5ac
authored
14 years ago
by
Nick Mathewson
Browse files
Options
Downloads
Patches
Plain Diff
Implement replacements for timer(add,cmp,sub) on platforms lacking them.
parent
22f7042b
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/common/compat.h
+42
-0
42 additions, 0 deletions
src/common/compat.h
with
42 additions
and
0 deletions
src/common/compat.h
+
42
−
0
View file @
5eaba5ac
...
...
@@ -333,6 +333,48 @@ struct tm *tor_localtime_r(const time_t *timep, struct tm *result);
struct
tm
*
tor_gmtime_r
(
const
time_t
*
timep
,
struct
tm
*
result
);
#endif
#ifndef timeradd
/** Replacement for timeradd on platforms that do not have it: sets tvout to
* the sum of tv1 and tv2. */
#define timeradd(tv1,tv2,tvout) \
do { \
(tvout)->tv_sec = (tv1)->tv_sec + (tv2)->tv_sec; \
(tvout)->tv_usec = (tv2)->tv_usec + (tv2)->tv_usec; \
if ((tvout)->tv_usec >= 1000000) { \
(tvout)->tv_usec -= 1000000; \
(tvout)->tv_sec++; \
} \
} while (0)
#endif
#ifndef timersub
/** Replacement for timersub on platforms that do not have it: sets tvout to
* tv1 minus tv2. */
#define timersub(tv1,tv2,tvout) \
do { \
(tvout)->tv_sec = (tv1)->tv_sec - (tv2)->tv_sec; \
(tvout)->tv_usec = (tv2)->tv_usec - (tv2)->tv_usec; \
if ((tvout)->tv_usec < 0) { \
(tvout)->tv_usec += 1000000; \
(tvout)->tv_sec--; \
} \
} while (0)
#endif
#ifndef timercmp
/** Replacement for timersub on platforms that do not have it: returns true
* iff the relational operator "op" makes the expression tv1 op tv2 true.
*
* Note that while this definition should work for all boolean opeators, some
* platforms' native timercmp definitions do not support >=, <=, or ==. So
* don't use those.
*/
#define timercmp(tv1,tv2,op) \
(((tv1)->tv_sec == (tv2)->tv_sec) ? \
((tv1)->tv_usec op (tv2)->tv_usec) : \
((tv1)->tv_sec op (tv2)->tv_sec))
#endif
/* ===== File compatibility */
int
replace_file
(
const
char
*
from
,
const
char
*
to
);
int
touch_file
(
const
char
*
fname
);
...
...
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