public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* Bug 868 - Need to add several functions related to date and time in BaseLib.
@ 2018-06-06  8:21 Mohammad Younas Khan Pathan
  2018-06-06 20:32 ` Laszlo Ersek
  0 siblings, 1 reply; 2+ messages in thread
From: Mohammad Younas Khan Pathan @ 2018-06-06  8:21 UTC (permalink / raw)
  To: edk2-devel

Hi All,

If there is any generic library function, then we do not need to have
2 or more definitions for same function like IsLeapYear().

Searching for 'isleapyear'
By Mask:
			*.c
ArmPlatformPkg\Library\PL031RealTimeClockLib\PL031RealTimeClockLib.c(199)
:IsLeapYear (
ArmPlatformPkg\Library\PL031RealTimeClockLib\PL031RealTimeClockLib.c(227)
:      (Time->Month == 2 && (!IsLeapYear (Time) && Time->Day > 28))
EmbeddedPkg\Library\HalRuntimeServicesExampleLib\Rtc.c(134) :IsLeapYear (
EmbeddedPkg\Library\HalRuntimeServicesExampleLib\Rtc.c(163) :
(Time->Month == 2 && (!IsLeapYear (Time) && Time->Day > 28))
EmulatorPkg\RealTimeClockRuntimeDxe\RealTimeClock.c(33) :IsLeapYear (
EmulatorPkg\RealTimeClockRuntimeDxe\RealTimeClock.c(279) :
(Time->Month == 2 && (!IsLeapYear (Time) && Time->Day > 28))
EmulatorPkg\RealTimeClockRuntimeDxe\RealTimeClock.c(288) :IsLeapYear (
Nt32Pkg\RealTimeClockRuntimeDxe\RealTimeClock.c(37) :IsLeapYear (
Nt32Pkg\RealTimeClockRuntimeDxe\RealTimeClock.c(356) :
(Time->Month == 2 && (!IsLeapYear (Time) && Time->Day > 28))
Nt32Pkg\RealTimeClockRuntimeDxe\RealTimeClock.c(365) :IsLeapYear (
PcAtChipsetPkg\PcatRealTimeClockRuntimeDxe\PcRtc.c(1021) :
(Time->Month == 2 && (!IsLeapYear (Time) && Time->Day > 28))
PcAtChipsetPkg\PcatRealTimeClockRuntimeDxe\PcRtc.c(1038) :IsLeapYear (
PcAtChipsetPkg\PcatRealTimeClockRuntimeDxe\PcRtc.c(1178) :      if
((From->Month == 2) && !IsLeapYear(From)) {

Similarly for other functions, can we have the common functions used
for time in BaseLib or some common library?

Can we move them to BaseLib or any other common library?

Bug link:
https://bugzilla.tianocore.org/show_bug.cgi?id=868

Please provide your suggestions on the same.

Thank you,
Younas khan.


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Bug 868 - Need to add several functions related to date and time in BaseLib.
  2018-06-06  8:21 Bug 868 - Need to add several functions related to date and time in BaseLib Mohammad Younas Khan Pathan
@ 2018-06-06 20:32 ` Laszlo Ersek
  0 siblings, 0 replies; 2+ messages in thread
From: Laszlo Ersek @ 2018-06-06 20:32 UTC (permalink / raw)
  To: edk2-devel
  Cc: Mohammad Younas Khan Pathan, Leif Lindholm (Linaro address),
	Michael Kinney, Andrew Fish, Brian Richardson, Ruiyu Ni

On 06/06/18 10:21, Mohammad Younas Khan Pathan wrote:
> Hi All,
> 
> If there is any generic library function, then we do not need to have
> 2 or more definitions for same function like IsLeapYear().
> 
> Searching for 'isleapyear'
> By Mask:
> 			*.c
> ArmPlatformPkg\Library\PL031RealTimeClockLib\PL031RealTimeClockLib.c(199)
> :IsLeapYear (
> ArmPlatformPkg\Library\PL031RealTimeClockLib\PL031RealTimeClockLib.c(227)
> :      (Time->Month == 2 && (!IsLeapYear (Time) && Time->Day > 28))
> EmbeddedPkg\Library\HalRuntimeServicesExampleLib\Rtc.c(134) :IsLeapYear (
> EmbeddedPkg\Library\HalRuntimeServicesExampleLib\Rtc.c(163) :
> (Time->Month == 2 && (!IsLeapYear (Time) && Time->Day > 28))
> EmulatorPkg\RealTimeClockRuntimeDxe\RealTimeClock.c(33) :IsLeapYear (
> EmulatorPkg\RealTimeClockRuntimeDxe\RealTimeClock.c(279) :
> (Time->Month == 2 && (!IsLeapYear (Time) && Time->Day > 28))
> EmulatorPkg\RealTimeClockRuntimeDxe\RealTimeClock.c(288) :IsLeapYear (
> Nt32Pkg\RealTimeClockRuntimeDxe\RealTimeClock.c(37) :IsLeapYear (
> Nt32Pkg\RealTimeClockRuntimeDxe\RealTimeClock.c(356) :
> (Time->Month == 2 && (!IsLeapYear (Time) && Time->Day > 28))
> Nt32Pkg\RealTimeClockRuntimeDxe\RealTimeClock.c(365) :IsLeapYear (
> PcAtChipsetPkg\PcatRealTimeClockRuntimeDxe\PcRtc.c(1021) :
> (Time->Month == 2 && (!IsLeapYear (Time) && Time->Day > 28))
> PcAtChipsetPkg\PcatRealTimeClockRuntimeDxe\PcRtc.c(1038) :IsLeapYear (
> PcAtChipsetPkg\PcatRealTimeClockRuntimeDxe\PcRtc.c(1178) :      if
> ((From->Month == 2) && !IsLeapYear(From)) {
> 
> Similarly for other functions, can we have the common functions used
> for time in BaseLib or some common library?
> 
> Can we move them to BaseLib or any other common library?
> 
> Bug link:
> https://bugzilla.tianocore.org/show_bug.cgi?id=868
> 
> Please provide your suggestions on the same.

Not sure about BaseLib (or even TimerLib), but we should indeed move
this function to a generic utility package -- maybe a
"TimeCalculationLib" class that manipulates pure time concepts and
values, without any hardware accesses (even abstracted ones).

(

For that same library class, I would probably nominate a function that I
posted earlier, under "TimerTickDiffLib", namely the GetTickDifference()
function.

Because, values returned by TimerLib's GetPerformanceCounter() function
cannot simply be subtracted from each other, because (a) counters don't
necessarily increment until they wrap around (they can be decrementing
too), and (b) the wrap-around's *low* bound may not be zero.

Such differences are needed all over the tree, and even recently a buggy
subtraction was added, as far as I remember...

... Yes: see the GetElapsedTick() function in commit 0edb7ec5ced0,
"MdeModulePkg/PciHostBridge: Count the (mm)io overhead when polling",
2018-05-09. The GetElapsedTick() function does not consider issue (b) above.

The exact same issue can be seen in IsSyncTimerTimeout(),
"UefiCpuPkg/PiSmmCpuDxeSmm/SyncTimer.c".

For comparison, see the GetTickDifference() function here (you'll have
to scroll down a bit):

http://mid.mail-archive.com/8cba2a58-1333-7733-031d-0883dbd844c6@redhat.com

)

Thanks
Laszlo


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-06-06 20:32 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-06-06  8:21 Bug 868 - Need to add several functions related to date and time in BaseLib Mohammad Younas Khan Pathan
2018-06-06 20:32 ` Laszlo Ersek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox