public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: Laszlo Ersek <lersek@redhat.com>
To: edk2-devel@lists.01.org
Cc: Mohammad Younas Khan Pathan <pmdyounaskhan786@gmail.com>,
	"Leif Lindholm (Linaro address)" <leif.lindholm@linaro.org>,
	Michael Kinney <michael.d.kinney@intel.com>,
	Andrew Fish <afish@apple.com>,
	Brian Richardson <brian.richardson@intel.com>,
	Ruiyu Ni <ruiyu.ni@intel.com>
Subject: Re: Bug 868 - Need to add several functions related to date and time in BaseLib.
Date: Wed, 6 Jun 2018 22:32:49 +0200	[thread overview]
Message-ID: <200d1795-908a-94af-b936-a5de6718bc00@redhat.com> (raw)
In-Reply-To: <CAN9uzB=J7XCmvEBJXJw68XwqCzFn6Jkuft9CLA1ncXU2uqZJhw@mail.gmail.com>

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


      reply	other threads:[~2018-06-06 20:32 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200d1795-908a-94af-b936-a5de6718bc00@redhat.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox