Thread (18 messages) flat view 18 messages, 5 authors, 2017-07-14

Re: [PATCH 4/5] powerpc/lib/sstep: Add prty instruction emulation

From: Matt Brown <hidden>
Date: 2017-07-14 00:46:23

On Thu, Jul 13, 2017 at 5:37 PM, Segher Boessenkool
[off-list ref] wrote:
On Thu, Jul 13, 2017 at 01:25:47PM +1000, Matt Brown wrote:
quoted
+static nokprobe_inline void do_prtyw(struct pt_regs *regs, unsigned long v,
+                             int ra)
+{
+     unsigned long low, high, out;
+     unsigned int i;
+
+     high = 0;
+     low = 0;
+     out = 0;
+
+     for (i = 0; i < 8; i++) {
+             if (v & (1 << (i * 8)))
1UL
quoted
+                     (i < 4) ? (low++) : (high++);
+     }
+
+     if (low % 2)
+             out |= low;
+     if (high % 2)
+             out |= (high << 32);
Only the low bit of each word of the output can be set.  Something
like

  out = ((high & 1) << 32) | (low & 1);
Ah, I wasn't aware. That way is much more concise too :)

Thanks,
Matt
Segher
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help