public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Stefan Roese <sr@denx.de>
To: u-boot@lists.denx.de
Cc: trini@konsulko.com, sjg@chromium.org, cchavva@marvell.com,
	awilliams@marvell.com
Subject: [PATCH v3 1/8] time: Import time_after64() and friends from Linux
Date: Fri,  5 Aug 2022 16:26:03 +0200	[thread overview]
Message-ID: <20220805142610.375427-2-sr@denx.de> (raw)
In-Reply-To: <20220805142610.375427-1-sr@denx.de>

When using us times it makes sense to use 64bit variables for storage.
The currently implemented time_after() and friends functions only handle
32bit variables. This patch now includes the 64bit variants as well
from Linux. This will be used by the upcoming generic cyclic function
infrastructure.

These macros were copied from include/linux/jiffies.h of Linux 5.18.

Signed-off-by: Stefan Roese <sr@denx.de>
---
v3:
- No change
v2:
- No change

 include/time.h | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/include/time.h b/include/time.h
index 9deb2cf61cc4..3b2ba0912470 100644
--- a/include/time.h
+++ b/include/time.h
@@ -83,6 +83,25 @@ uint64_t usec_to_tick(unsigned long usec);
 	(time_after_eq(a,b) && \
 	 time_before(a,c))
 
+/* Same as above, but does so with platform independent 64bit types.
+ * These must be used when utilizing jiffies_64 (i.e. return value of
+ * get_jiffies_64() */
+#define time_after64(a,b)	\
+	(typecheck(__u64, a) &&	\
+	 typecheck(__u64, b) && \
+	 ((__s64)((b) - (a)) < 0))
+#define time_before64(a,b)	time_after64(b,a)
+
+#define time_after_eq64(a,b)	\
+	(typecheck(__u64, a) && \
+	 typecheck(__u64, b) && \
+	 ((__s64)((a) - (b)) >= 0))
+#define time_before_eq64(a,b)	time_after_eq64(b,a)
+
+#define time_in_range64(a, b, c) \
+	(time_after_eq64(a, b) && \
+	 time_before_eq64(a, c))
+
 /**
  * usec2ticks() - Convert microseconds to internal ticks
  *
-- 
2.37.1


  reply	other threads:[~2022-08-05 14:27 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-05 14:26 [PATCH v3 0/8] Add support for cyclic function execution infrastruture Stefan Roese
2022-08-05 14:26 ` Stefan Roese [this message]
2022-08-05 16:48   ` [PATCH v3 1/8] time: Import time_after64() and friends from Linux Simon Glass
2022-08-05 14:26 ` [PATCH v3 2/8] cyclic: Add basic support for cyclic function execution infrastruture Stefan Roese
2022-08-05 16:48   ` Simon Glass
2022-08-15 13:49     ` Stefan Roese
2022-08-05 14:26 ` [PATCH v3 3/8] cyclic: Integrate cyclic infrastructure into WATCHDOG_RESET Stefan Roese
2022-08-05 16:48   ` Simon Glass
2022-08-15 16:16     ` Stefan Roese
2022-08-15 17:37       ` Simon Glass
2022-08-16 10:10         ` Stefan Roese
2022-08-05 14:26 ` [PATCH v3 4/8] cyclic: Integrate cyclic functionality at bootup in board_r/f Stefan Roese
2022-08-05 16:48   ` Simon Glass
2022-08-05 14:26 ` [PATCH v3 5/8] cyclic: Add 'cyclic list' command Stefan Roese
2022-08-05 16:48   ` Simon Glass
2022-08-15 16:24     ` Stefan Roese
2022-08-05 14:26 ` [PATCH v3 6/8] sandbox: Add cyclic demo function Stefan Roese
2022-08-05 16:48   ` Simon Glass
2022-08-16  8:38     ` Stefan Roese
2022-08-05 14:26 ` [PATCH v3 7/8] mips: octeon_nic23: Add PCIe FLR fixup via cyclic infrastructure Stefan Roese
2022-08-05 14:26 ` [PATCH v3 8/8] cyclic: Add documentation Stefan Roese
2022-08-05 16:48   ` Simon Glass
2022-08-15 16:18     ` Stefan Roese

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-all 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=20220805142610.375427-2-sr@denx.de \
    --to=sr@denx.de \
    --cc=awilliams@marvell.com \
    --cc=cchavva@marvell.com \
    --cc=sjg@chromium.org \
    --cc=trini@konsulko.com \
    --cc=u-boot@lists.denx.de \
    /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