Expose timespec and timeval macros when __BSD_VISIBLE is defined. This
allows userland application to use the following macros: timespecclear, timespecisset, timespeccmp, timespecadd, timespecsub; timevalclear, timevalisset, timevalcmp. MFC after: 1 month
This commit is contained in:
parent
590f9303e5
commit
285a4c7c59
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=247300
@ -156,9 +156,6 @@ timeval2bintime(const struct timeval *tv, struct bintime *bt)
|
|||||||
/* 18446744073709 = int(2^64 / 1000000) */
|
/* 18446744073709 = int(2^64 / 1000000) */
|
||||||
bt->frac = tv->tv_usec * (uint64_t)18446744073709LL;
|
bt->frac = tv->tv_usec * (uint64_t)18446744073709LL;
|
||||||
}
|
}
|
||||||
#endif /* __BSD_VISIBLE */
|
|
||||||
|
|
||||||
#ifdef _KERNEL
|
|
||||||
|
|
||||||
/* Operations on timespecs */
|
/* Operations on timespecs */
|
||||||
#define timespecclear(tvp) ((tvp)->tv_sec = (tvp)->tv_nsec = 0)
|
#define timespecclear(tvp) ((tvp)->tv_sec = (tvp)->tv_nsec = 0)
|
||||||
@ -197,7 +194,7 @@ timeval2bintime(const struct timeval *tv, struct bintime *bt)
|
|||||||
|
|
||||||
/* timevaladd and timevalsub are not inlined */
|
/* timevaladd and timevalsub are not inlined */
|
||||||
|
|
||||||
#endif /* _KERNEL */
|
#endif /* __BSD_VISIBLE */
|
||||||
|
|
||||||
#ifndef _KERNEL /* NetBSD/OpenBSD compatible interfaces */
|
#ifndef _KERNEL /* NetBSD/OpenBSD compatible interfaces */
|
||||||
|
|
||||||
|
@ -323,14 +323,14 @@ main(int ac, char **av)
|
|||||||
fprintf(trussinfo->outfile, "%5d: ",
|
fprintf(trussinfo->outfile, "%5d: ",
|
||||||
trussinfo->pid);
|
trussinfo->pid);
|
||||||
if (trussinfo->flags & ABSOLUTETIMESTAMPS) {
|
if (trussinfo->flags & ABSOLUTETIMESTAMPS) {
|
||||||
timespecsubt(&trussinfo->curthread->after,
|
timespecsubt_to(&trussinfo->curthread->after,
|
||||||
&trussinfo->start_time, &timediff);
|
&trussinfo->start_time, &timediff);
|
||||||
fprintf(trussinfo->outfile, "%ld.%09ld ",
|
fprintf(trussinfo->outfile, "%ld.%09ld ",
|
||||||
(long)timediff.tv_sec,
|
(long)timediff.tv_sec,
|
||||||
timediff.tv_nsec);
|
timediff.tv_nsec);
|
||||||
}
|
}
|
||||||
if (trussinfo->flags & RELATIVETIMESTAMPS) {
|
if (trussinfo->flags & RELATIVETIMESTAMPS) {
|
||||||
timespecsubt(&trussinfo->curthread->after,
|
timespecsubt_to(&trussinfo->curthread->after,
|
||||||
&trussinfo->curthread->before, &timediff);
|
&trussinfo->curthread->before, &timediff);
|
||||||
fprintf(trussinfo->outfile, "%ld.%09ld ",
|
fprintf(trussinfo->outfile, "%ld.%09ld ",
|
||||||
(long)timediff.tv_sec,
|
(long)timediff.tv_sec,
|
||||||
@ -349,14 +349,14 @@ main(int ac, char **av)
|
|||||||
fprintf(trussinfo->outfile, "%5d: ",
|
fprintf(trussinfo->outfile, "%5d: ",
|
||||||
trussinfo->pid);
|
trussinfo->pid);
|
||||||
if (trussinfo->flags & ABSOLUTETIMESTAMPS) {
|
if (trussinfo->flags & ABSOLUTETIMESTAMPS) {
|
||||||
timespecsubt(&trussinfo->curthread->after,
|
timespecsubt_to(&trussinfo->curthread->after,
|
||||||
&trussinfo->start_time, &timediff);
|
&trussinfo->start_time, &timediff);
|
||||||
fprintf(trussinfo->outfile, "%ld.%09ld ",
|
fprintf(trussinfo->outfile, "%ld.%09ld ",
|
||||||
(long)timediff.tv_sec,
|
(long)timediff.tv_sec,
|
||||||
timediff.tv_nsec);
|
timediff.tv_nsec);
|
||||||
}
|
}
|
||||||
if (trussinfo->flags & RELATIVETIMESTAMPS) {
|
if (trussinfo->flags & RELATIVETIMESTAMPS) {
|
||||||
timespecsubt(&trussinfo->curthread->after,
|
timespecsubt_to(&trussinfo->curthread->after,
|
||||||
&trussinfo->curthread->before, &timediff);
|
&trussinfo->curthread->before, &timediff);
|
||||||
fprintf(trussinfo->outfile, "%ld.%09ld ",
|
fprintf(trussinfo->outfile, "%ld.%09ld ",
|
||||||
(long)timediff.tv_sec, timediff.tv_nsec);
|
(long)timediff.tv_sec, timediff.tv_nsec);
|
||||||
|
@ -1126,14 +1126,14 @@ print_syscall(struct trussinfo *trussinfo, const char *name, int nargs,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (trussinfo->flags & ABSOLUTETIMESTAMPS) {
|
if (trussinfo->flags & ABSOLUTETIMESTAMPS) {
|
||||||
timespecsubt(&trussinfo->curthread->after,
|
timespecsubt_to(&trussinfo->curthread->after,
|
||||||
&trussinfo->start_time, &timediff);
|
&trussinfo->start_time, &timediff);
|
||||||
len += fprintf(trussinfo->outfile, "%ld.%09ld ",
|
len += fprintf(trussinfo->outfile, "%ld.%09ld ",
|
||||||
(long)timediff.tv_sec, timediff.tv_nsec);
|
(long)timediff.tv_sec, timediff.tv_nsec);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (trussinfo->flags & RELATIVETIMESTAMPS) {
|
if (trussinfo->flags & RELATIVETIMESTAMPS) {
|
||||||
timespecsubt(&trussinfo->curthread->after,
|
timespecsubt_to(&trussinfo->curthread->after,
|
||||||
&trussinfo->curthread->before, &timediff);
|
&trussinfo->curthread->before, &timediff);
|
||||||
len += fprintf(trussinfo->outfile, "%ld.%09ld ",
|
len += fprintf(trussinfo->outfile, "%ld.%09ld ",
|
||||||
(long)timediff.tv_sec, timediff.tv_nsec);
|
(long)timediff.tv_sec, timediff.tv_nsec);
|
||||||
@ -1165,9 +1165,9 @@ print_syscall_ret(struct trussinfo *trussinfo, const char *name, int nargs,
|
|||||||
if (!sc)
|
if (!sc)
|
||||||
return;
|
return;
|
||||||
clock_gettime(CLOCK_REALTIME, &trussinfo->curthread->after);
|
clock_gettime(CLOCK_REALTIME, &trussinfo->curthread->after);
|
||||||
timespecsubt(&trussinfo->curthread->after,
|
timespecsubt_to(&trussinfo->curthread->after,
|
||||||
&trussinfo->curthread->before, &timediff);
|
&trussinfo->curthread->before, &timediff);
|
||||||
timespecadd(&sc->time, &timediff, &sc->time);
|
timespecadd_to(&sc->time, &timediff, &sc->time);
|
||||||
sc->ncalls++;
|
sc->ncalls++;
|
||||||
if (errorp)
|
if (errorp)
|
||||||
sc->nerror++;
|
sc->nerror++;
|
||||||
@ -1205,7 +1205,7 @@ print_summary(struct trussinfo *trussinfo)
|
|||||||
fprintf(trussinfo->outfile, "%-20s%5jd.%09ld%8d%8d\n",
|
fprintf(trussinfo->outfile, "%-20s%5jd.%09ld%8d%8d\n",
|
||||||
sc->name, (intmax_t)sc->time.tv_sec,
|
sc->name, (intmax_t)sc->time.tv_sec,
|
||||||
sc->time.tv_nsec, sc->ncalls, sc->nerror);
|
sc->time.tv_nsec, sc->ncalls, sc->nerror);
|
||||||
timespecadd(&total, &sc->time, &total);
|
timespecadd_to(&total, &sc->time, &total);
|
||||||
ncall += sc->ncalls;
|
ncall += sc->ncalls;
|
||||||
nerror += sc->nerror;
|
nerror += sc->nerror;
|
||||||
}
|
}
|
||||||
|
@ -62,7 +62,7 @@ struct trussinfo
|
|||||||
SLIST_HEAD(, threadinfo) threadlist;
|
SLIST_HEAD(, threadinfo) threadlist;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define timespecsubt(tvp, uvp, vvp) \
|
#define timespecsubt_to(tvp, uvp, vvp) \
|
||||||
do { \
|
do { \
|
||||||
(vvp)->tv_sec = (tvp)->tv_sec - (uvp)->tv_sec; \
|
(vvp)->tv_sec = (tvp)->tv_sec - (uvp)->tv_sec; \
|
||||||
(vvp)->tv_nsec = (tvp)->tv_nsec - (uvp)->tv_nsec; \
|
(vvp)->tv_nsec = (tvp)->tv_nsec - (uvp)->tv_nsec; \
|
||||||
@ -72,7 +72,7 @@ struct trussinfo
|
|||||||
} \
|
} \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
#define timespecadd(tvp, uvp, vvp) \
|
#define timespecadd_to(tvp, uvp, vvp) \
|
||||||
do { \
|
do { \
|
||||||
(vvp)->tv_sec = (tvp)->tv_sec + (uvp)->tv_sec; \
|
(vvp)->tv_sec = (tvp)->tv_sec + (uvp)->tv_sec; \
|
||||||
(vvp)->tv_nsec = (tvp)->tv_nsec + (uvp)->tv_nsec; \
|
(vvp)->tv_nsec = (tvp)->tv_nsec + (uvp)->tv_nsec; \
|
||||||
|
Loading…
Reference in New Issue
Block a user