X-Git-Url: http://git.ozlabs.org/?p=ccan;a=blobdiff_plain;f=ccan%2Ftime%2Ftime.h;fp=ccan%2Ftime%2Ftime.h;h=f2b335cf45de0af387c2b0a9e1cba09c73ceb86a;hp=54d92c57b89090152a9c1a42e10c656ee0c2e82c;hb=a7f2b2c4d3e62cbbcb71628363e39f6730fd8f5e;hpb=8b83ecf3a2c7f52e2f5a6e23d330fea43e917fce;ds=sidebyside diff --git a/ccan/time/time.h b/ccan/time/time.h index 54d92c57..f2b335cf 100644 --- a/ccan/time/time.h +++ b/ccan/time/time.h @@ -388,6 +388,28 @@ static inline struct timeabs timeabs_add(struct timeabs a, struct timerel b) return t; } +/** + * timemono_add - add a relative to a monotonic time + * @a: the monotonic time. + * @b: a relative time. + * + * The times must not overflow, or the results are undefined. + * + * Example: + * // We do one every second. + * static struct timemono next_timem(void) + * { + * return timemono_add(time_mono(), time_from_msec(1000)); + * } + */ +static inline struct timemono timemono_add(struct timemono a, struct timerel b) +{ + struct timemono t; + + t.ts = time_add_(a.ts, b.ts); + return t; +} + /** * timerel_add - add two relative times * @a: one relative time.