public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* Re: [PATCH 1/12] random pt4: Create new rol32/ror32 bitops
@ 2005-01-23  7:44 Chuck Ebbert
  2005-01-24 22:16 ` H. Peter Anvin
  0 siblings, 1 reply; 8+ messages in thread
From: Chuck Ebbert @ 2005-01-23  7:44 UTC (permalink / raw)
  To: Matt Mackall; +Cc: linux-kernel, Andrew Morton, Theodore Ts'o

On Sat, 22 Jan 2005 at 20:13:24 -0800 Matt Mackall wrote:

> So I think tweaks for x86 at least are unnecessary. 

 So the compiler looks for that specific sequence of instructions:

        (a << b) | (a >> (sizeof(a) * 8 - b)

and recognizes that it means rotation?  Wow.


Chuck

^ permalink raw reply	[flat|nested] 8+ messages in thread
* Re: [PATCH 1/12] random pt4: Create new rol32/ror32 bitops
@ 2005-01-23  2:10 Chuck Ebbert
  2005-01-23  2:45 ` Matt Mackall
  2005-01-23  3:19 ` Andi Kleen
  0 siblings, 2 replies; 8+ messages in thread
From: Chuck Ebbert @ 2005-01-23  2:10 UTC (permalink / raw)
  To: Matt Mackall; +Cc: Theodore Ts'o, Andrew Morton, linux-kernel, Andi Kleen

On Fri, 21 Jan 2005 at 15:41:06 -0600 Matt Mackall wrote:

> Add rol32 and ror32 bitops to bitops.h

Can you test this patch on top of yours?  I did it on 2.6.10-ac10 but it
should apply OK.  Compile tested and booted, but only random.c is using it
in my kernel.

x86-64 could use this too...

Add i386 bitops for rol32/ror32:
Signed-off-by: Chuck Ebbert <76306.1226@compuserve.com>

--- 2.6.10-ac10/include/linux/bitops.h~orig     2005-01-22 11:31:20.130239000 -0500
+++ 2.6.10-ac10/include/linux/bitops.h  2005-01-22 11:34:55.740239000 -0500
@@ -129,6 +129,7 @@
        return sizeof(w) == 4 ? generic_hweight32(w) : generic_hweight64(w);
 }
 
+#ifndef __HAVE_ARCH_ROTATE_32
 /*
  * rol32 - rotate a 32-bit value left
  *
@@ -150,5 +151,6 @@
 {
        return (word >> shift) | (word << (32 - shift));
 }
+#endif /* ndef __HAVE_ARCH_ROTATE_32 */
 
 #endif
--- 2.6.10-ac10/include/asm-i386/bitops.h~orig  2004-08-24 05:08:39.000000000 -0400
+++ 2.6.10-ac10/include/asm-i386/bitops.h       2005-01-22 11:42:12.010239000 -0500
@@ -431,6 +431,41 @@
 #define hweight16(x) generic_hweight16(x)
 #define hweight8(x) generic_hweight8(x)
 
+#define __HAVE_ARCH_ROTATE_32
+/*
+ * rol32 - rotate a 32-bit value left
+ *
+ * @word: value to rotate
+ * @shift: bits to roll
+ */
+static inline __u32 rol32(__u32 word, int shift)
+{
+       __u32 res;
+
+       asm("roll %%cl,%0"
+           : "=r" (res)
+           : "0" (word), "c" (shift)
+           : "cc");
+       return res;
+}
+
+/*
+ * ror32 - rotate a 32-bit value right
+ *
+ * @word: value to rotate
+ * @shift: bits to roll
+ */
+static inline __u32 ror32(__u32 word, int shift)
+{
+       __u32 res;
+
+       asm("rorl %%cl,%0"
+           : "=r" (res)
+           : "0" (word), "c" (shift)
+           : "cc");
+       return res;
+}
+
 #endif /* __KERNEL__ */
 
 #ifdef __KERNEL__

Chuck

^ permalink raw reply	[flat|nested] 8+ messages in thread
* [PATCH 0/12] random pt4: Moving and sharing code
@ 2005-01-21 21:41 Matt Mackall
  2005-01-21 21:41 ` [PATCH 1/12] random pt4: Create new rol32/ror32 bitops Matt Mackall
  0 siblings, 1 reply; 8+ messages in thread
From: Matt Mackall @ 2005-01-21 21:41 UTC (permalink / raw)
  To: Andrew Morton, Theodore Ts'o; +Cc: linux-kernel

This series focuses on moving and sharing code in
/drivers/char/random.c. It applies on top of -mm2 which contains my
earlier patches.

New bitop:
1  Create new rol32/ror32 bitops
2  Use them throughout the tree

Share SHA code in lib:
3  Kill the SHA1 variants
4  Cleanup SHA1 interface
5  Move SHA1 code to lib/
6  Replace SHA1 with faster version
7  Update cryptolib to use SHA1 from lib

Share halfmd4 hash:
8  Move halfMD4 to lib
9  Kill duplicate halfMD4 in ext3 htree

Move network random bits:
10 Simplify and shrink syncookie code
11 Move syncookies to net/
12 Move other tcp/ip bits to net/

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

end of thread, other threads:[~2005-01-25 21:15 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-01-23  7:44 [PATCH 1/12] random pt4: Create new rol32/ror32 bitops Chuck Ebbert
2005-01-24 22:16 ` H. Peter Anvin
  -- strict thread matches above, loose matches on Subject: below --
2005-01-23  2:10 Chuck Ebbert
2005-01-23  2:45 ` Matt Mackall
2005-01-23  3:19 ` Andi Kleen
2005-01-23  4:13   ` Matt Mackall
2005-01-21 21:41 [PATCH 0/12] random pt4: Moving and sharing code Matt Mackall
2005-01-21 21:41 ` [PATCH 1/12] random pt4: Create new rol32/ror32 bitops Matt Mackall
2005-01-25 21:02   ` Denis Vlasenko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox