Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1247974

bitops.h: improve sign extending API

From Martin Kepplinger <martink@posteo.de>
Newsgroups linux.kernel
Subject bitops.h: improve sign extending API
Date 2015-10-15 18:30 +0200
Message-ID <qjTzI-3md-11@gated-at.bofh.it> (permalink)
Organization linux.* mail to news gateway

Show all headers | View raw


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 {


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Back to linux.kernel | Previous | Next — Next in thread | Find similar | Unroll thread


Thread

bitops.h: improve sign extending API Martin Kepplinger <martink@posteo.de> - 2015-10-15 18:30 +0200
  [PATCH 2/2] bitops.h: add sign_extend64() Martin Kepplinger <martink@posteo.de> - 2015-10-15 18:30 +0200
  [PATCH 1/2] bitops.h: Improve sign_extend32()'s documentation Martin Kepplinger <martink@posteo.de> - 2015-10-15 18:30 +0200
    Re: [PATCH 1/2] bitops.h: Improve sign_extend32()'s documentation "George Spelvin" <linux@horizon.com> - 2015-10-15 20:10 +0200

csiph-web