Nicholas Flintham | 1e3d311 | 2013-04-10 10:48:38 +0100 | [diff] [blame^] | 1 | |
| 2 | #ifndef _LINUX_PREFETCH_H |
| 3 | #define _LINUX_PREFETCH_H |
| 4 | |
| 5 | #include <linux/types.h> |
| 6 | #include <asm/processor.h> |
| 7 | #include <asm/cache.h> |
| 8 | |
| 9 | |
| 10 | #ifndef ARCH_HAS_PREFETCH |
| 11 | #define prefetch(x) __builtin_prefetch(x) |
| 12 | #endif |
| 13 | |
| 14 | #ifndef ARCH_HAS_PREFETCHW |
| 15 | #define prefetchw(x) __builtin_prefetch(x,1) |
| 16 | #endif |
| 17 | |
| 18 | #ifndef ARCH_HAS_SPINLOCK_PREFETCH |
| 19 | #define spin_lock_prefetch(x) prefetchw(x) |
| 20 | #endif |
| 21 | |
| 22 | #ifndef PREFETCH_STRIDE |
| 23 | #define PREFETCH_STRIDE (4*L1_CACHE_BYTES) |
| 24 | #endif |
| 25 | |
| 26 | static inline void prefetch_range(void *addr, size_t len) |
| 27 | { |
| 28 | #ifdef ARCH_HAS_PREFETCH |
| 29 | char *cp; |
| 30 | char *end = addr + len; |
| 31 | |
| 32 | for (cp = addr; cp < end; cp += PREFETCH_STRIDE) |
| 33 | prefetch(cp); |
| 34 | #endif |
| 35 | } |
| 36 | |
| 37 | #endif |