]> mj.ucw.cz Git - libucw.git/blob - ucw/prefetch.h
Logging: Implemented log_switch().
[libucw.git] / ucw / prefetch.h
1 /*
2  *      UCW Library -- Prefetch
3  *
4  *      (c) 1997--2006 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(__k6)
14   /* K6 doesn't have prefetches */
15
16 #elif defined(__athlon) || defined(__k8) || \
17       defined(__i686) || \
18       defined(__pentium4) || defined(__prescott) || defined(__nocona)
19
20 #define HAVE_PREFETCH
21 static inline void prefetch(void *addr)
22 {
23   asm volatile ("prefetcht0 %0" : : "m" (*(byte*)addr));
24 }
25
26 #else
27 #warning "Don't know how to prefetch on your CPU. Please fix ucw/prefetch.h."
28 #endif
29
30 #ifndef HAVE_PREFETCH
31 static inline void prefetch(void *addr UNUSED)
32 {
33 }
34 #endif
35
36 #endif