lkml.org 
[lkml]   [2002]   [Aug]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[PATCH] Add some convenient L1_CACHE related macros.

Attached is a patch against 2.5.30 to add a few convenient L1_CACHE
related macros.

I am not sure of the exact process, but I was wondering if these could get
included in some future version of cache.h. I am currently using them in
some drivers I am writing and feel they add to the readability of the
code.

Thanks,
Robin Holt
diff -Naur linux-2.5.30-clean/include/linux/cache.h linux-2.5.30/include/linux/cache.h
--- linux-2.5.30-clean/include/linux/cache.h Thu Aug 1 16:17:32 2002
+++ linux-2.5.30/include/linux/cache.h Sat Aug 10 06:02:07 2002
@@ -4,12 +4,26 @@
#include <linux/config.h>
#include <asm/cache.h>

+#ifndef L1_CACHE_MASK
+#define L1_CACHE_MASK (L1_CACHE_BYTES - 1UL)
+#endif
+
#define ALIGN(x,a) (((x)+(a)-1)&~((a)-1))

#ifndef L1_CACHE_ALIGN
#define L1_CACHE_ALIGN(x) ALIGN(x, L1_CACHE_BYTES)
#endif

+/* Return the start of the cache line for address _p */
+#ifndef L1_CACHE_LINE
+#define L1_CACHE_LINE(_p) ((unsigned long)(_p) & ~L1_CACHE_MASK)
+#endif
+
+/* Is address _p aligned on a cache boundary? */
+#ifndef L1_CACHE_ALIGNED
+#define L1_CACHE_ALIGNED(_p) (((unsigned long)(_p) & L1_CACHE_MASK) == 0)
+#endif
+
#ifndef SMP_CACHE_BYTES
#define SMP_CACHE_BYTES L1_CACHE_BYTES
#endif
\
 
 \ /
  Last update: 2005-03-22 13:27    [W:0.034 / U:1.420 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site