From: Willy Tarreau <w@1wt.eu>
To: Arnd Bergmann <arnd@arndb.de>
Cc: "Zhangjin Wu" <falcon@tinylab.org>,
"Thomas Weißschuh" <thomas@t-8ch.de>,
linux-kernel <linux-kernel@vger.kernel.org>,
linux-kselftest <linux-kselftest@vger.kernel.org>,
linux-riscv <linux-riscv@lists.infradead.org>
Subject: Re: [PATCH v3 11/12] selftests/nolibc: add new gettimeofday test cases
Date: Sun, 4 Jun 2023 13:27:54 +0200 [thread overview]
Message-ID: <ZHx1OliMqHx9U1Lw@1wt.eu> (raw)
In-Reply-To: <51e1db37-3981-4ea5-9348-b6f6b31ecc8a@app.fastmail.com>
On Sun, Jun 04, 2023 at 11:24:39AM +0200, Arnd Bergmann wrote:
> On Sun, Jun 4, 2023, at 10:29, ??? wrote:
> >
> > Sorry for missing part of your feedbacks, I will check if -nostdlib
> > stops the linking of libgcc_s or my own separated test script forgot
> > linking the libgcc_s manually.
>
> According to the gcc documentation, -nostdlib drops libgcc.a, but
> adding -lgcc is the recommended way to bring it back.
>
> > And as suggestion from Thomas' reply,
> >
> >>> Perhaps we really need to add the missing __divdi3 and __aeabi_ldivmod and the
> >>> ones for the other architectures, or get one from lib/math/div64.c.
> >
> >>No, these ones come from the compiler via libgcc_s, we must not try to
> > reimplement them. And we should do our best to avoid depending on them
> > to avoid the error you got above.
> >
> > So, the explicit conversion is used instead in the patch.
>
> I think a cast to a 32-bit type is ideal when converting the
> clock_gettime() result into microseconds, since the kernel guarantees
> that the timespec value is normalized, with all zeroes in the
> upper 34 bits. Going through __aeabi_ldivmod would make the
> conversion much slower.
>
> For user supplied non-normalized timeval values, it's not obvious
> whether we need the full 64-bit division
We don't have to care about these here for the microsecond part,
because for decades these were exclusively 32-bit. Also the only
one consuming this field would have been settimeofday() and it's
already documented as returning EINVAL if tv_usec is not within
the expected 0..999999 range.
And when in doubt we should keep in mind that nolibc's purpose is not
to become a yet-another full-blown libc alternative but just a small
piece of software allowing to produce portable and compact binaries
for testing or booting. Being a bit stricter than other libcs for the
sake of code compactness is better here. Originally for example it was
necessary to always pass the 3 arguments to open(). Over time we managed
to make simple code compile with both glibc and nolibc, but when it
comes at the cost of adding size and burden for the developers, such
as forcing them to add libgcc, I prefer that we slightly limit the
domain of application instead.
Thanks!
Willy
next prev parent reply other threads:[~2023-06-04 11:28 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-03 7:59 [PATCH v3 00/12] nolibc: add generic part1 of prepare for rv32 Zhangjin Wu
2023-06-03 8:00 ` [PATCH v3 01/12] selftests/nolibc: syscall_args: use generic __NR_statx Zhangjin Wu
2023-06-03 8:02 ` [PATCH v3 02/12] tools/nolibc: add missing nanoseconds support for __NR_statx Zhangjin Wu
2023-06-04 11:18 ` Willy Tarreau
2023-06-04 12:00 ` Thomas Weißschuh
2023-06-04 12:53 ` Willy Tarreau
2023-06-03 8:04 ` [PATCH v3 03/12] selftests/nolibc: allow specify extra arguments for qemu Zhangjin Wu
2023-06-03 8:05 ` [PATCH v3 04/12] selftests/nolibc: fix up compile warning with glibc on x86_64 Zhangjin Wu
2023-06-03 8:06 ` [PATCH v3 05/12] selftests/nolibc: not include limits.h for nolibc Zhangjin Wu
2023-06-03 8:08 ` [PATCH v3 06/12] selftests/nolibc: use INT_MAX instead of __INT_MAX__ Zhangjin Wu
2023-06-03 8:09 ` [PATCH v3 07/12] tools/nolibc: arm: add missing my_syscall6 Zhangjin Wu
2023-06-03 8:11 ` [PATCH v3 08/12] tools/nolibc: open: fix up compile warning for arm Zhangjin Wu
2023-06-03 8:13 ` [PATCH v3 09/12] selftests/nolibc: support two errnos with EXPECT_SYSER2() Zhangjin Wu
2023-06-03 8:14 ` [PATCH v3 10/12] selftests/nolibc: remove gettimeofday_bad1/2 completely Zhangjin Wu
2023-06-03 8:16 ` [PATCH v3 11/12] selftests/nolibc: add new gettimeofday test cases Zhangjin Wu
2023-06-04 6:46 ` Thomas Weißschuh
[not found] ` <tencent_4668A50A08C3D31E7531619E@qq.com>
2023-06-04 9:24 ` Arnd Bergmann
2023-06-04 11:27 ` Willy Tarreau [this message]
2023-06-04 11:38 ` Arnd Bergmann
2023-06-04 11:46 ` Willy Tarreau
2023-06-05 11:12 ` Zhangjin Wu
2023-06-03 8:17 ` [PATCH v3 12/12] selftests/nolibc: test_fork: fix up duplicated print Zhangjin Wu
2023-06-04 6:49 ` [PATCH v3 00/12] nolibc: add generic part1 of prepare for rv32 Thomas Weißschuh
2023-06-04 12:54 ` Willy Tarreau
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=ZHx1OliMqHx9U1Lw@1wt.eu \
--to=w@1wt.eu \
--cc=arnd@arndb.de \
--cc=falcon@tinylab.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=thomas@t-8ch.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