mailarchive of the ptxdist mailing list
 help / color / mirror / Atom feed
From: Ian Abbott <abbotti@mev.co.uk>
To: ptxdist@pengutronix.de
Cc: Ian Abbott <abbotti@mev.co.uk>
Subject: [ptxdist] [PATCH] libtahu: Change CFLAGS to use 64-bit system time
Date: Mon, 20 Feb 2023 13:41:05 +0000	[thread overview]
Message-ID: <20230220134105.28904-1-abbotti@mev.co.uk> (raw)

libtahu exposes a library function `get_current_timestamp()` to return
the real-time clock as the number of milliseconds since the Unix epoch
as a 64-bit value.  It calls `clock_gettime(CLOCK_REALTIME, &ts)` (where
`ts` is a `struct timespec`) to get the system time and does some simple
arithmetic on `ts.tv_sec` and `ts.tv_nsec` to convert the time to a
number of milliseconds.

Ideally, we want `ts.tv_sec` to have a 64-bit type to avoid Y2038
problems, but on most 32-bit architectures, `ts.tv_sec` will have a
32-bit type by default.  Try and select the 64-bit time interface even
on 32-bit architectures by appending `-D_FILE_OFFSET_BITS=64` and
`-D_TIME_BITS=64` to the `CFLAGS` variable when invoking `make`.  This
works for glibc 2.34 or later when the system is running on Linux kernel
5.1 or later.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
---
 rules/libtahu.make | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/rules/libtahu.make b/rules/libtahu.make
index 26c064c6d..3e392216d 100644
--- a/rules/libtahu.make
+++ b/rules/libtahu.make
@@ -37,11 +37,12 @@ LIBTAHU_CONF_TOOL	:= NO
 # Compile
 # ----------------------------------------------------------------------------
 
-#LIBTAHU_MAKE_ENV	:= $(CROSS_ENV)
-
+LIBTAHU_CPPFLAGS := -Iinclude -D_FILE_OFFSET_BITS=64 -D_TIME_BITS=64
+LIBTAHU_CFLAGS := -O2 -g -g3 -fPIC
 # Just build the dynamic library.
 LIBTAHU_MAKE_OPT	:= \
 	$(CROSS_ENV_PROGS) \
+	CFLAGS='$(CROSS_CPPFLAGS) $(LIBTAHU_CPPFLAGS) $(CROSS_CFLAGS) $(LIBTAHU_CFLAGS)' \
 	lib/libtahu.so
 
 # ----------------------------------------------------------------------------
-- 
2.39.1




             reply	other threads:[~2023-02-20 13:42 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-20 13:41 Ian Abbott [this message]
2023-02-23 15:42 ` Michael Olbrich
2023-02-24  9:55   ` Ian Abbott
2023-02-24 14:43     ` Michael Olbrich
2023-02-24 12:03   ` Ian Abbott
2023-02-24 14:45     ` Michael Olbrich
2023-02-24 16:10       ` Ian Abbott

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=20230220134105.28904-1-abbotti@mev.co.uk \
    --to=abbotti@mev.co.uk \
    --cc=ptxdist@pengutronix.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