From a64a90a7b6f31a4d381e3c5d16144201b01da600 Mon Sep 17 00:00:00 2001 From: Amy Chan Date: Wed, 6 Nov 2024 12:10:09 +0800 Subject: [PATCH] CryptoPkg: Apply gettimeofday() solution to BaseCryptLibMbedTls BaseCryptLib turn gettimeofday() from a Macro into a function call, apply the same change to BaseCryptLibMbedTls Signed-off-by: Amy Chan --- .../SysCall/ConstantTimeClock.c | 33 ++++++++----------- .../SysCall/TimerWrapper.c | 33 ++++++++----------- 2 files changed, 28 insertions(+), 38 deletions(-) diff --git a/CryptoPkg/Library/BaseCryptLibMbedTls/SysCall/ConstantTimeClock.c b/CryptoPkg/Library/BaseCryptLibMbedTls/SysCall/ConstantTimeClock.c index 2ec13ef9d0e5..e6e0f1ec2df0 100644 --- a/CryptoPkg/Library/BaseCryptLibMbedTls/SysCall/ConstantTimeClock.c +++ b/CryptoPkg/Library/BaseCryptLibMbedTls/SysCall/ConstantTimeClock.c @@ -19,25 +19,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #include #include - -typedef int time_t; - -// -// Structures Definitions -// -struct tm { - int tm_sec; /* seconds after the minute [0-60] */ - int tm_min; /* minutes after the hour [0-59] */ - int tm_hour; /* hours since midnight [0-23] */ - int tm_mday; /* day of the month [1-31] */ - int tm_mon; /* months since January [0-11] */ - int tm_year; /* years since 1900 */ - int tm_wday; /* days since Sunday [0-6] */ - int tm_yday; /* days since January 1 [0-365] */ - int tm_isdst; /* Daylight Savings Time flag */ - long tm_gmtoff; /* offset from CUT in seconds */ - char *tm_zone; /* timezone abbreviation */ -}; +#include // // -- Time Management Routines -- @@ -73,3 +55,16 @@ _time64 ( { return time (t); } + +long timezone; + +int +gettimeofday ( + struct timeval *tv, + struct timezone *tz + ) +{ + tv->tv_sec = 0; + tv->tv_usec = 0; + return 0; +} diff --git a/CryptoPkg/Library/BaseCryptLibMbedTls/SysCall/TimerWrapper.c b/CryptoPkg/Library/BaseCryptLibMbedTls/SysCall/TimerWrapper.c index b7cd4d318194..738db4e0ce9f 100644 --- a/CryptoPkg/Library/BaseCryptLibMbedTls/SysCall/TimerWrapper.c +++ b/CryptoPkg/Library/BaseCryptLibMbedTls/SysCall/TimerWrapper.c @@ -11,25 +11,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #include #include #include - -typedef int time_t; - -// -// Structures Definitions -// -struct tm { - int tm_sec; /* seconds after the minute [0-60] */ - int tm_min; /* minutes after the hour [0-59] */ - int tm_hour; /* hours since midnight [0-23] */ - int tm_mday; /* day of the month [1-31] */ - int tm_mon; /* months since January [0-11] */ - int tm_year; /* years since 1900 */ - int tm_wday; /* days since Sunday [0-6] */ - int tm_yday; /* days since January 1 [0-365] */ - int tm_isdst; /* Daylight Savings Time flag */ - long tm_gmtoff; /* offset from CUT in seconds */ - char *tm_zone; /* timezone abbreviation */ -}; +#include // // -- Time Management Routines -- @@ -196,3 +178,16 @@ _time64 ( { return time (t); } + +long timezone; + +int +gettimeofday ( + struct timeval *tv, + struct timezone *tz + ) +{ + tv->tv_sec = (long)time (NULL); + tv->tv_usec = 0; + return 0; +}