Skip to content

Commit

Permalink
CryptoPkg: Apply gettimeofday() solution to BaseCryptLibMbedTls
Browse files Browse the repository at this point in the history
BaseCryptLib turn gettimeofday() from a Macro into a function call,
apply the same change to BaseCryptLibMbedTls

Signed-off-by: Amy Chan <[email protected]>
  • Loading branch information
AmyChan-Intel committed Nov 22, 2024
1 parent 836942f commit 947fed4
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 38 deletions.
33 changes: 14 additions & 19 deletions CryptoPkg/Library/BaseCryptLibMbedTls/SysCall/ConstantTimeClock.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,25 +19,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent

#include <Base.h>
#include <Library/BaseMemoryLib.h>

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 <CrtLibSupport.h>

//
// -- Time Management Routines --
Expand Down Expand Up @@ -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;
}
33 changes: 14 additions & 19 deletions CryptoPkg/Library/BaseCryptLibMbedTls/SysCall/TimerWrapper.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include <Library/UefiRuntimeServicesTableLib.h>
#include <Library/BaseMemoryLib.h>
#include <Library/MemoryAllocationLib.h>

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 <CrtLibSupport.h>

//
// -- Time Management Routines --
Expand Down Expand Up @@ -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;
}

0 comments on commit 947fed4

Please sign in to comment.