MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ndb_prefetch.h
1 /*
2  Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
3 
4  This program is free software; you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation; version 2 of the License.
7 
8  This program is distributed in the hope that it will be useful,
9  but WITHOUT ANY WARRANTY; without even the implied warranty of
10  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  GNU General Public License for more details.
12 
13  You should have received a copy of the GNU General Public License
14  along with this program; if not, write to the Free Software
15  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
16 */
17 
18 #ifndef NDB_PREFETCH_H
19 #define NDB_PREFETCH_H
20 
21 #ifdef HAVE_SUN_PREFETCH_H
22 #include <sun_prefetch.h>
23 #if (defined(__SUNPRO_C) && __SUNPRO_C >= 0x590) \
24  || (defined(__SUNPRO_CC) && __SUNPRO_CC >= 0x590)
25 /* Universal sun_prefetch* macros available with Sun Studio 5.9 */
26 #define USE_SUN_PREFETCH
27 #elif defined(__sparc)
28 /* Use sparc_prefetch* macros with older Sun Studio on sparc */
29 #define USE_SPARC_PREFETCH
30 #endif
31 #endif
32 
33 #ifdef HAVE_SUN_PREFETCH_H
34 #pragma optimize("", off)
35 #endif
36 
37 static inline
38 void NDB_PREFETCH_READ(void* addr)
39 {
40 #if (__GNUC__ > 3) || (__GNUC__ == 3 && __GNUC_MINOR > 10)
41  __builtin_prefetch(addr, 0, 3);
42 #elif defined(USE_SUN_PREFETCH)
43  sun_prefetch_read_once(addr);
44 #elif defined(USE_SPARC_PREFETCH)
45  sparc_prefetch_read_once(addr);
46 #else
47  (void)addr;
48 #endif
49 }
50 
51 static inline
52 void NDB_PREFETCH_WRITE(void* addr)
53 {
54 #if (__GNUC__ > 3) || (__GNUC__ == 3 && __GNUC_MINOR > 10)
55  __builtin_prefetch(addr, 1, 3);
56 #elif defined(USE_SUN_PREFETCH)
57  sun_prefetch_write_once(addr);
58 #elif defined(USE_SPARC_PREFETCH)
59  sparc_prefetch_write_once(addr);
60 #else
61  (void)addr;
62 #endif
63 }
64 
65 #ifdef HAVE_SUN_PREFETCH_H
66 #pragma optimize("", on)
67 #endif
68 
69 #endif
70