From: Thibault Godouet Date: Fri, 12 Jun 2015 20:18:24 +0000 (+0100) Subject: added min/max convenience functions X-Git-Tag: ver3_3_0~17 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=ad44ceabd06f3c9c18fece98f55e4e54891a030c;p=thirdparty%2Ffcron.git added min/max convenience functions --- diff --git a/subs.c b/subs.c index 1288f84..bdae71f 100644 --- a/subs.c +++ b/subs.c @@ -427,3 +427,51 @@ my_setenv_overwrite(const char *name, const char *value) #endif } + +time_t +tmax(time_t x, time_t y) +/* return the larger value (maximum) of x and y */ +{ + if (x > y) { + return x; + } + else { + return y; + } +} + +time_t +tmin(time_t x, time_t y) +/* return the smaller value (minimum) of x and y */ +{ + if (x < y) { + return x; + } + else { + return y; + } +} + +int +imax(int x, int y) +/* return the larger value (maximum) of x and y */ +{ + if (x > y) { + return x; + } + else { + return y; + } +} + +int +imin(int x, int y) +/* return the smaller value (minimum) of x and y */ +{ + if (x < y) { + return x; + } + else { + return y; + } +} diff --git a/subs.h b/subs.h index cef4a17..23a1590 100644 --- a/subs.h +++ b/subs.h @@ -44,4 +44,10 @@ extern int get_word(char **str); extern void my_unsetenv(const char *name); extern void my_setenv_overwrite(const char *name, const char *value); +extern time_t tmax(time_t x, time_t y); +extern time_t tmin(time_t x, time_t y); +extern int imax(int x, int y); +extern int imin(int x, int y); + +extern time_t my_time(void); #endif /* __SUBS_H__ */