timing_load_creds: Add timersub macro for platforms where it is missing

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)
This commit is contained in:
Tomas Mraz 2022-12-02 09:00:33 +01:00
parent f97ddfc305
commit f2e4629608

View File

@ -21,6 +21,20 @@
# 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)