ccan: update for FreeBSD compile fixes.
Also gets some new timemono helpers, but we don't use them (yet). Changelog-Fixed: Compilation on FreeBSD. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> Closes: https://github.com/ElementsProject/lightning/issues/7758
This commit is contained in:
committed by
Alex Myers
parent
9d160eb8fb
commit
6468d439e0
@@ -1,3 +1,3 @@
|
||||
CCAN imported from http://ccodearchive.net.
|
||||
|
||||
CCAN version: init-2590-gaf04734d
|
||||
CCAN version: init-2593-gca094039
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include <sys/socket.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
bool fdpass_send(int sockout, int fd)
|
||||
{
|
||||
|
||||
@@ -7,13 +7,13 @@ int main(void)
|
||||
struct timemono t1, t2;
|
||||
struct timerel t3;
|
||||
|
||||
plan_tests(5);
|
||||
plan_tests(10);
|
||||
|
||||
/* Test time_mono */
|
||||
t1 = time_mono();
|
||||
t2 = time_mono();
|
||||
|
||||
ok1(!time_less_(t2.ts, t1.ts));
|
||||
ok1(!timemono_before(t2, t1));
|
||||
|
||||
t3.ts.tv_sec = 1;
|
||||
t3.ts.tv_nsec = 0;
|
||||
@@ -24,5 +24,11 @@ int main(void)
|
||||
ok1(timemono_add(t1, t3).ts.tv_sec == t1.ts.tv_sec + 1);
|
||||
ok1(timemono_add(t2, t3).ts.tv_nsec == t2.ts.tv_nsec);
|
||||
|
||||
ok1(timemono_sub(timemono_add(t1, t3), t3).ts.tv_sec == t1.ts.tv_sec);
|
||||
ok1(timemono_sub(timemono_add(t1, t3), t3).ts.tv_nsec == t1.ts.tv_nsec);
|
||||
|
||||
ok1(timemono_after(timemono_add(t1, t3), t1));
|
||||
ok1(!timemono_after(t1, timemono_add(t1, t3)));
|
||||
ok1(!timemono_after(t1, t1));
|
||||
return exit_status();
|
||||
}
|
||||
|
||||
@@ -193,6 +193,23 @@ static inline bool time_greater(struct timerel a, struct timerel b)
|
||||
return time_greater_(a.ts, b.ts);
|
||||
}
|
||||
|
||||
/**
|
||||
* timemono_after - is a after b?
|
||||
* @a: one monotonic time.
|
||||
* @b: another monotonic time.
|
||||
*
|
||||
* Example:
|
||||
* static bool timed_out(const struct timemono *start)
|
||||
* {
|
||||
* #define TIMEOUT time_from_msec(1000)
|
||||
* return timemono_after(time_mono(), timemono_add(*start, TIMEOUT));
|
||||
* }
|
||||
*/
|
||||
static inline bool timemono_after(struct timemono a, struct timemono b)
|
||||
{
|
||||
return time_greater_(a.ts, b.ts);
|
||||
}
|
||||
|
||||
static inline bool time_less_(struct timespec a, struct timespec b)
|
||||
{
|
||||
if (TIME_CHECK(a).tv_sec < TIME_CHECK(b).tv_sec)
|
||||
@@ -220,6 +237,23 @@ static inline bool time_before(struct timeabs a, struct timeabs b)
|
||||
return time_less_(a.ts, b.ts);
|
||||
}
|
||||
|
||||
/**
|
||||
* timemono_before - is a before b?
|
||||
* @a: one monotonic time.
|
||||
* @b: another monotonic time.
|
||||
*
|
||||
* Example:
|
||||
* static bool still_valid(const struct timemono *start)
|
||||
* {
|
||||
* #define TIMEOUT time_from_msec(1000)
|
||||
* return timemono_before(time_mono(), timemono_add(*start, TIMEOUT));
|
||||
* }
|
||||
*/
|
||||
static inline bool timemono_before(struct timemono a, struct timemono b)
|
||||
{
|
||||
return time_less_(a.ts, b.ts);
|
||||
}
|
||||
|
||||
/**
|
||||
* time_less - is a before b?
|
||||
* @a: one relative time.
|
||||
@@ -404,6 +438,29 @@ static inline struct timeabs timeabs_sub(struct timeabs abs, struct timerel rel)
|
||||
return t;
|
||||
}
|
||||
|
||||
/**
|
||||
* timemono_sub - subtract a relative time from a monotonic time
|
||||
* @mono: the monotonic time.
|
||||
* @rel: the relative time.
|
||||
*
|
||||
* This returns a well formed struct timemono of @mono - @rel.
|
||||
*
|
||||
* Example:
|
||||
* // We do one every second.
|
||||
* static struct timemono previous_time(void)
|
||||
* {
|
||||
* return timemono_sub(time_mono(), time_from_msec(1000));
|
||||
* }
|
||||
*/
|
||||
static inline struct timemono timemono_sub(struct timemono mono, struct timerel rel)
|
||||
{
|
||||
struct timemono t;
|
||||
|
||||
t.ts = time_sub_(mono.ts, rel.ts);
|
||||
return t;
|
||||
}
|
||||
|
||||
|
||||
static inline struct timespec time_add_(struct timespec a, struct timespec b)
|
||||
{
|
||||
struct timespec sum;
|
||||
@@ -488,6 +545,8 @@ static inline struct timerel timerel_add(struct timerel a, struct timerel b)
|
||||
* @div: number to divide it by.
|
||||
*
|
||||
* Example:
|
||||
* #include <sys/wait.h>
|
||||
*
|
||||
* // How long does it take to do a fork?
|
||||
* static struct timerel forking_time(void)
|
||||
* {
|
||||
|
||||
Reference in New Issue
Block a user