]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
timing_load_creds: Add timersub macro for platforms where it is missing
authorTomas Mraz <tomas@openssl.org>
Fri, 2 Dec 2022 08:00:33 +0000 (09:00 +0100)
committerTomas Mraz <tomas@openssl.org>
Tue, 6 Dec 2022 17:18:23 +0000 (18:18 +0100)
Fixes #19812

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Hugo Landau <hlandau@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/19817)

test/timing_load_creds.c

index a293f3ece29c2e63ec5f2d3eadce0444d42832de..9be068986fe86e398627338e5a110ad8d7d554c4 100644 (file)
 # include <openssl/bio.h>
 # include "internal/e_os.h"
 
+# ifndef timersub
+/* struct timeval * subtraction; a must be greater than or equal to b */
+#  define timersub(a, b, res)                                         \
+     do {                                                             \
+         (res)->tv_sec = (a)->tv_sec - (b)->tv_sec;                   \
+         if ((a)->tv_usec < (b)->tv_usec) {                           \
+             (res)->tv_usec = (a)->tv_usec + 1000000 - (b)->tv_usec); \
+             --(res)->tv_sec;                                         \
+         } else {                                                     \
+             (res)->tv_usec = (a)->tv_usec - (b)->tv_usec);           \
+         }                                                            \
+     } while(0)
+# endif
+
 static char *prog;
 
 static void readx509(const char *contents, int size)