summaryrefslogtreecommitdiffstats
path: root/CryptoPkg/Library/BaseCryptLib/SysCall/TimerWrapper.c
diff options
context:
space:
mode:
Diffstat (limited to 'CryptoPkg/Library/BaseCryptLib/SysCall/TimerWrapper.c')
-rw-r--r--CryptoPkg/Library/BaseCryptLib/SysCall/TimerWrapper.c56
1 files changed, 31 insertions, 25 deletions
diff --git a/CryptoPkg/Library/BaseCryptLib/SysCall/TimerWrapper.c b/CryptoPkg/Library/BaseCryptLib/SysCall/TimerWrapper.c
index 027e5a942e..7d28446d4b 100644
--- a/CryptoPkg/Library/BaseCryptLib/SysCall/TimerWrapper.c
+++ b/CryptoPkg/Library/BaseCryptLib/SysCall/TimerWrapper.c
@@ -15,17 +15,17 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
// -- Time Management Routines --
//
-#define IsLeap(y) (((y) % 4) == 0 && (((y) % 100) != 0 || ((y) % 400) == 0))
-#define SECSPERMIN (60)
-#define SECSPERHOUR (60 * 60)
-#define SECSPERDAY (24 * SECSPERHOUR)
+#define IsLeap(y) (((y) % 4) == 0 && (((y) % 100) != 0 || ((y) % 400) == 0))
+#define SECSPERMIN (60)
+#define SECSPERHOUR (60 * 60)
+#define SECSPERDAY (24 * SECSPERHOUR)
//
// The arrays give the cumulative number of days up to the first of the
// month number used as the index (1 -> 12) for regular and leap years.
// The value at index 13 is for the whole year.
//
-UINTN CumulativeDays[2][14] = {
+UINTN CumulativeDays[2][14] = {
{
0,
0,
@@ -61,10 +61,13 @@ UINTN CumulativeDays[2][14] = {
};
/* Get the system time as seconds elapsed since midnight, January 1, 1970. */
-//INTN time(
+// INTN time(
// INTN *timer
// )
-time_t time (time_t *timer)
+time_t
+time (
+ time_t *timer
+ )
{
EFI_STATUS Status;
EFI_TIME Time;
@@ -84,7 +87,7 @@ time_t time (time_t *timer)
// UTime should now be set to 00:00:00 on Jan 1 of the current year.
//
for (Year = 1970, CalTime = 0; Year != Time.Year; Year++) {
- CalTime = CalTime + (time_t)(CumulativeDays[IsLeap(Year)][13] * SECSPERDAY);
+ CalTime = CalTime + (time_t)(CumulativeDays[IsLeap (Year)][13] * SECSPERDAY);
}
//
@@ -92,7 +95,7 @@ time_t time (time_t *timer)
//
CalTime = CalTime +
(time_t)((Time.TimeZone != EFI_UNSPECIFIED_TIMEZONE) ? (Time.TimeZone * 60) : 0) +
- (time_t)(CumulativeDays[IsLeap(Time.Year)][Time.Month] * SECSPERDAY) +
+ (time_t)(CumulativeDays[IsLeap (Time.Year)][Time.Month] * SECSPERDAY) +
(time_t)(((Time.Day > 0) ? Time.Day - 1 : 0) * SECSPERDAY) +
(time_t)(Time.Hour * SECSPERHOUR) +
(time_t)(Time.Minute * 60) +
@@ -108,7 +111,10 @@ time_t time (time_t *timer)
//
// Convert a time value from type time_t to struct tm.
//
-struct tm * gmtime (const time_t *timer)
+struct tm *
+gmtime (
+ const time_t *timer
+ )
{
struct tm *GmTime;
UINT16 DayNo;
@@ -127,38 +133,38 @@ struct tm * gmtime (const time_t *timer)
return NULL;
}
- ZeroMem ((VOID *) GmTime, (UINTN) sizeof (struct tm));
+ ZeroMem ((VOID *)GmTime, (UINTN)sizeof (struct tm));
- DayNo = (UINT16) (*timer / SECSPERDAY);
- DayRemainder = (UINT16) (*timer % SECSPERDAY);
+ DayNo = (UINT16)(*timer / SECSPERDAY);
+ DayRemainder = (UINT16)(*timer % SECSPERDAY);
- GmTime->tm_sec = (int) (DayRemainder % SECSPERMIN);
- GmTime->tm_min = (int) ((DayRemainder % SECSPERHOUR) / SECSPERMIN);
- GmTime->tm_hour = (int) (DayRemainder / SECSPERHOUR);
- GmTime->tm_wday = (int) ((DayNo + 4) % 7);
+ GmTime->tm_sec = (int)(DayRemainder % SECSPERMIN);
+ GmTime->tm_min = (int)((DayRemainder % SECSPERHOUR) / SECSPERMIN);
+ GmTime->tm_hour = (int)(DayRemainder / SECSPERHOUR);
+ GmTime->tm_wday = (int)((DayNo + 4) % 7);
for (Year = 1970, YearNo = 0; DayNo > 0; Year++) {
- TotalDays = (UINT16) (IsLeap (Year) ? 366 : 365);
+ TotalDays = (UINT16)(IsLeap (Year) ? 366 : 365);
if (DayNo >= TotalDays) {
- DayNo = (UINT16) (DayNo - TotalDays);
+ DayNo = (UINT16)(DayNo - TotalDays);
YearNo++;
} else {
break;
}
}
- GmTime->tm_year = (int) (YearNo + (1970 - 1900));
- GmTime->tm_yday = (int) DayNo;
+ GmTime->tm_year = (int)(YearNo + (1970 - 1900));
+ GmTime->tm_yday = (int)DayNo;
for (MonthNo = 12; MonthNo > 1; MonthNo--) {
- if (DayNo >= CumulativeDays[IsLeap(Year)][MonthNo]) {
- DayNo = (UINT16) (DayNo - (UINT16) (CumulativeDays[IsLeap(Year)][MonthNo]));
+ if (DayNo >= CumulativeDays[IsLeap (Year)][MonthNo]) {
+ DayNo = (UINT16)(DayNo - (UINT16)(CumulativeDays[IsLeap (Year)][MonthNo]));
break;
}
}
- GmTime->tm_mon = (int) MonthNo - 1;
- GmTime->tm_mday = (int) DayNo + 1;
+ GmTime->tm_mon = (int)MonthNo - 1;
+ GmTime->tm_mday = (int)DayNo + 1;
GmTime->tm_isdst = 0;
GmTime->tm_gmtoff = 0;