mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* bitops.h: improve sign extending API
@ 2015-10-15 16:18 Martin Kepplinger
  2015-10-15 16:18 ` [PATCH 1/2] bitops.h: Improve sign_extend32()'s documentation Martin Kepplinger
  2015-10-15 16:18 ` [PATCH 2/2] bitops.h: add sign_extend64() Martin Kepplinger
  0 siblings, 2 replies; 4+ messages in thread
From: Martin Kepplinger @ 2015-10-15 16:18 UTC (permalink / raw)
  To: mingo, akpm, linux, linux, maxime.coquelin, dvlasenk, yury.norov,
	torvalds
  Cc: linux-kernel

PATCH 1/2 improves the doc of sign_extend32()

This should help to avoid different manual approaches to sign extension


PATCH 2/2 adds sign_extend64()

An informal example of what could follow in
arch/sh/kernel/traps_64.c after PATCH 2/2:

@@ -101,7 +102,7 @@ static int generate_and_check_address(struct pt_regs *regs,
                __s64 displacement;
                displacement = (opcode >> 10) & 0x3ff;
-               displacement = ((displacement << 54) >> 54); /* sign extend */
+               displacement = sign_extend64(displacement, 9);
                addr = (__u64)((__s64)base_address + (displacement << width_shift));
        } else {



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2015-10-15 18:06 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-10-15 16:18 bitops.h: improve sign extending API Martin Kepplinger
2015-10-15 16:18 ` [PATCH 1/2] bitops.h: Improve sign_extend32()'s documentation Martin Kepplinger
2015-10-15 18:06   ` George Spelvin
2015-10-15 16:18 ` [PATCH 2/2] bitops.h: add sign_extend64() Martin Kepplinger

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®