Zero  0.1.0
w_defines.h
Go to the documentation of this file.
1 /* -*- mode:C++; c-basic-offset:4 -*-
2  Shore-MT -- Multi-threaded port of the SHORE storage manager
3 
4  Copyright (c) 2007-2009
5  Data Intensive Applications and Systems Labaratory (DIAS)
6  Ecole Polytechnique Federale de Lausanne
7 
8  All Rights Reserved.
9 
10  Permission to use, copy, modify and distribute this software and
11  its documentation is hereby granted, provided that both the
12  copyright notice and this permission notice appear in all copies of
13  the software, derivative works or modified versions, and any
14  portions thereof, and that both notices appear in supporting
15  documentation.
16 
17  This code is distributed in the hope that it will be useful, but
18  WITHOUT ANY WARRANTY; without even the implied warranty of
19  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. THE AUTHORS
20  DISCLAIM ANY LIABILITY OF ANY KIND FOR ANY DAMAGES WHATSOEVER
21  RESULTING FROM THE USE OF THIS SOFTWARE.
22 */
23 
24 /*<std-header orig-src='shore' incl-file-exclusion='W_DEFINES_H' no-defines='true'>
25 
26  $Id: w_defines.h,v 1.8 2010/12/08 17:37:37 nhall Exp $
27 
28 SHORE -- Scalable Heterogeneous Object REpository
29 
30 Copyright (c) 1994-99 Computer Sciences Department, University of
31  Wisconsin -- Madison
32 All Rights Reserved.
33 
34 Permission to use, copy, modify and distribute this software and its
35 documentation is hereby granted, provided that both the copyright
36 notice and this permission notice appear in all copies of the
37 software, derivative works or modified versions, and any portions
38 thereof, and that both notices appear in supporting documentation.
39 
40 THE AUTHORS AND THE COMPUTER SCIENCES DEPARTMENT OF THE UNIVERSITY
41 OF WISCONSIN - MADISON ALLOW FREE USE OF THIS SOFTWARE IN ITS
42 "AS IS" CONDITION, AND THEY DISCLAIM ANY LIABILITY OF ANY KIND
43 FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
44 
45 This software was developed with support by the Advanced Research
46 Project Agency, ARPA order number 018 (formerly 8230), monitored by
47 the U.S. Army Research Laboratory under contract DAAB07-91-C-Q518.
48 Further funding for this work was provided by DARPA through
49 Rome Research Laboratory Contract No. F30602-97-2-0247.
50 
51 */
52 
53 #ifndef __W_DEFINES_H
54 #define __W_DEFINES_H
55 
56 /* -- do not edit anything above this line -- </std-header>*/
57 
58 /* shore-config.h does not have duplicate-include protection, but
59  this file does, and we don't include shore-config.h anywhere else
60 
61  Before including it, erase the existing autoconf #defines (if any)
62  to avoid warnings about redefining macros.
63 */
64 #ifdef PACKAGE
65 #undef PACKAGE
66 #endif
67 #ifdef PACKAGE_NAME
68 #undef PACKAGE_NAME
69 #endif
70 #ifdef PACKAGE_STRING
71 #undef PACKAGE_STRING
72 #endif
73 #ifdef PACKAGE_BUGREPORT
74 #undef PACKAGE_BUGREPORT
75 #endif
76 #ifdef PACKAGE_TARNAME
77 #undef PACKAGE_TARNAME
78 #endif
79 #ifdef PACKAGE_VERSION
80 #undef PACKAGE_VERSION
81 #endif
82 #ifdef VERSION
83 #undef VERSION
84 #endif
85 
86 #include "shore-config.h"
87 #include "shore.def"
88 
89 // #ifdef HAVE_VALGRIND_H
90 // #define USING_VALGRIND 1
91 // #include <valgrind.h>
92 // #elif defined(HAVE_VALGRIND_VALGRIND_H)
93 // #define USING_VALGRIND 1
94 // #include <valgrind/valgrind.h>
95 // #endif
96 
97 // #ifdef USING_VALGRIND
98 // #include "valgrind_help.h"
99 // #endif
100 
101 // now ZERO_INIT is set according to W_DEBUG_LEVEL.
102 #if W_DEBUG_LEVEL > 0
103 #define ZERO_INIT 1 /* for valgrind/purify */
104 #endif
105 
106 #include <cerrno>
107 #include <cstddef>
108 #include <cstdlib>
109 #include <climits>
110 
111 #include <cstdint>
112 
113 #include <unistd.h>
114 
115 /* the following cannot be "verbatim" included in shore-config.def,
116  * unfortunately. The #undef ARCH_LP64 gets mangled
117  * by autoconf.
118  */
119 #ifdef ARCH_LP64
120 /* enabled LP64 - let's make sure the environment can handle it */
121 #if defined(_SC_V6_LP64_OFF64) || _XBS5_LP64_OFF64 || _SC_V6_LPBIG_OFFBIG || _XBS5_LPBIG_OFFBIG
122 #else
123 #warning Turning off ARCH_LP64
124 #undef ARCH_LP64
125 #endif
126 /* ARCH_LP64 was defined (might no longer be) */
127 #endif
128 
129 /* Issue warning if we don't have large file offsets with ILP32 */
130 #ifndef ARCH_LP64
131 
132 #if _SC_V6_ILP32_OFFBIG || _XBS5_ILP32_OFFBIG
133 #else
134 #warning large file off_t support seems to be missing accoring to sysconf !
135 #endif
136 
137 /* ARCH_LP64 not defined */
138 #endif
139 
140 #if SM_PAGESIZE > 32768 * 8
141 #error SM does not support pages this large.
142 #endif
143 
144 #include <sys/types.h>
145 
146 using namespace std;
147 
148 // avoid nasty bus errors...
149 template<class T>
150 static inline T* aligned_cast(char const* ptr) {
151  // bump the pointer up to the next proper alignment (always a power of 2)
152  size_t val = (size_t)ptr;
153  val += __alignof__(T) - 1;
154  val &= -__alignof__(T);
155  return (T*)val;
156 }
157 
164 template<int N>
165 class allocaN {
166  char _buf[N + __alignof__(double)];
167 
168 public:
169  operator void*() {
170  return aligned_cast<double>(_buf);
171  }
172  // no destructor because we don't know what's going on...
173 };
174 
183 const size_t CACHELINE_SIZE = 64;
184 
185 /*<std-footer incl-file-exclusion='W_DEFINES_H'> -- do not edit anything below this line -- */
186 
187 #endif // __W_DEFINES_H /*</std-footer>*/
STL namespace.
constructs a blob of N bytes.
Definition: w_defines.h:165
static T * aligned_cast(char const *ptr)
Definition: w_defines.h:150
#define T
Definition: w_okvl_inl.h:45
const size_t CACHELINE_SIZE
CPU Cache line size in bytes.
Definition: w_defines.h:183