]> mj.ucw.cz Git - libucw.git/blob - lib/prefetch.h
a0b045fbde0838f4e7088ac51848b1e4e64c43f1
[libucw.git] / lib / prefetch.h
1 /*
2  *      UCW Library -- Prefetch
3  *
4  *      (c) 1997--2005 Martin Mares <mj@ucw.cz>
5  *
6  *      This software may be freely distributed and used according to the terms
7  *      of the GNU Lesser General Public License.
8  */
9
10 #ifndef _UCW_PREFETCH_H
11 #define _UCW_PREFETCH_H
12
13 #if defined(__pentium4)
14   /* Default prefetches are good enough */
15
16 #elif defined(__k6)
17   /* K6 doesn't have prefetches */
18
19 #elif defined(__athlon) || defined(__i686)
20
21 #define HAVE_PREFETCH
22 static inline void prefetch(void *addr)
23 {
24   asm volatile ("prefetcht0 %0" : : "m" (*(byte*)addr));
25 }
26
27 #else
28 #warning "Don't know how to prefetch on your CPU. Please fix lib/prefetch.h."
29 #endif
30
31 #ifndef HAVE_PREFETCH
32 static inline void prefetch(void *addr UNUSED)
33 {
34 }
35 #endif
36
37 #endif