From: Jeff Lucovsky Date: Sun, 29 Jan 2023 13:36:42 +0000 (-0500) Subject: time: SCTime additions -- neq, initializer X-Git-Tag: suricata-7.0.0-rc2~539 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=59ab1c20eca573321ba1b8be19943be1cd2b4000;p=thirdparty%2Fsuricata.git time: SCTime additions -- neq, initializer Issue: 5818 This commit adds an initializer for the SCTime_t type and a comparison macro for "not equal". Use them as follows: SCTime_t my_var = SCTIME_INITIALIZER; if (SCTIME_CMP_NEQ(sctime1_val, sctime2_val)) { } --- diff --git a/src/util-time.h b/src/util-time.h index 81a2e943b7..96f5479789 100644 --- a/src/util-time.h +++ b/src/util-time.h @@ -47,6 +47,12 @@ typedef struct { (t).secs = 0; \ (t).usecs = 0; \ } + +#define SCTIME_INITIALIZER \ + (SCTime_t) \ + { \ + .secs = 0, .usecs = 0 \ + } #define SCTIME_USECS(t) ((uint64_t)(t).usecs) #define SCTIME_SECS(t) ((uint64_t)(t).secs) #define SCTIME_MSECS(t) (SCTIME_SECS(t) * 1000 + SCTIME_USECS(t) / 1000) @@ -83,6 +89,7 @@ typedef struct { #define SCTIME_CMP_GT(a, b) SCTIME_CMP((a), (b), >) #define SCTIME_CMP_LT(a, b) SCTIME_CMP((a), (b), <) #define SCTIME_CMP_LTE(a, b) SCTIME_CMP((a), (b), <=) +#define SCTIME_CMP_NEQ(a, b) SCTIME_CMP((a), (b), !=) void TimeInit(void); void TimeDeinit(void);