mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Simon Schuster <schuster.simon@siemens-energy.com>
To: Vineet Gupta <vgupta@kernel.org>
Cc: Dinh Nguyen <dinguyen@kernel.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	Arnd Bergmann <arnd@arndb.de>, Sasha Levin <sashal@kernel.org>,
	linux-kernel@vger.kernel.org,
	David Laight <david.laight.linux@gmail.com>
Subject: Re: [PATCH v2 1/3] lib: extract 32bit mul/div helpers from nios2 into GENERIC_LIB
Date: Fri, 6 Nov 2026 14:07:38 +0100	[thread overview]
Message-ID: <20261106130738.avum4t2nhdnmenyu@dev-vm-schuster> (raw)
In-Reply-To: <bba7f6da-82ee-46cc-bd8f-b0e3e027f5e2@kernel.org>

Hello Vineet,

On Tue, Nov 03, 2026 at 08:23:23PM -0800, Vineet Gupta wrote:
> > +/*
> > + * Software 32-bit multiply for cores built without the hardware multiplier.
> > + */
> > +s32 notrace __mulsi3(s32 a, s32 b);
> > +s32 notrace __divsi3(s32 a, s32 b);
> > +s32 notrace __udivsi3(s32 a, s32 b);
> > +s32 notrace __modsi3(s32 a, s32 b);
> > +s32 notrace __umodsi3(s32 a, s32 b);
> 
> Shouldn't the 'u' prefixed functions have unsigned int args, result.
> It seems libgcc/?divmod.c doesn't but ARC does have nint_t for those which
> is unsigned.
> Nios it seems was removed from gcc?

As David has correctly pointed out, nios2 was dropped from gcc with
release line 14.y being the last one to contain it.
So at least for nios2, it seems like it has always been the case that
__udivsi3/__umodsi3 were declared as taking and returning SItypes:

https://github.com/gcc-mirror/gcc/blob/releases/gcc-14/libgcc/config/nios2/lib2-divmod.c#L106

Given that both implementations continue to pass it through to a very
similarly looking udivmodsi4 as u32, I would assume that this has partly
relied on 'why should the compiler do any strange upcasts here, it will
just pass through the registers and be done with it and this is
implementation-defined-good-enough', so I would not mind rolling a v3
with u32s for __umodsi3 and __udivsi3. Are these the only two symbols
you are concerned about, and would these signatures work for you?

u32 notrace __udivsi3(u32 a, u32 b);
u32 notrace __umodsi3(u32 a, u32 b);

Best regards
Simon

  parent reply	other threads:[~2026-11-06 13:07 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-03 13:30 [PATCH v2 0/3] lib: Add software mul/div helpers and use them from nios2 Simon Schuster
2026-11-03 13:30 ` [PATCH v2 1/3] lib: extract 32bit mul/div helpers from nios2 into GENERIC_LIB Simon Schuster
2026-11-04  4:23   ` Vineet Gupta
2026-11-05 10:57     ` David Laight
2026-11-06 13:07     ` Simon Schuster [this message]
2026-11-03 13:30 ` [PATCH v2 2/3] nios2: export __divsi3_table Simon Schuster
2026-11-03 13:30 ` [PATCH v2 3/3] nios2: Drop usage of libgcc in favour of GENERIC_LIB_* Simon Schuster
2026-11-03 15:40 ` [PATCH v2 0/3] lib: Add software mul/div helpers and use them from nios2 Arnd Bergmann

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=20261106130738.avum4t2nhdnmenyu@dev-vm-schuster \
    --to=schuster.simon@siemens-energy.com \
    --cc=akpm@linux-foundation.org \
    --cc=arnd@arndb.de \
    --cc=david.laight.linux@gmail.com \
    --cc=dinguyen@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sashal@kernel.org \
    --cc=vgupta@kernel.org \
    /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

all inboxes | Powered by JetHome®