Zero  0.1.0
basics.h
Go to the documentation of this file.
1 /*<std-header orig-src='shore' incl-file-exclusion='BASICS_H'>
2 
3  $Id: basics.h,v 1.73 2010/07/26 23:37:06 nhall Exp $
4 
5 SHORE -- Scalable Heterogeneous Object REpository
6 
7 Copyright (c) 1994-99 Computer Sciences Department, University of
8  Wisconsin -- Madison
9 All Rights Reserved.
10 
11 Permission to use, copy, modify and distribute this software and its
12 documentation is hereby granted, provided that both the copyright
13 notice and this permission notice appear in all copies of the
14 software, derivative works or modified versions, and any portions
15 thereof, and that both notices appear in supporting documentation.
16 
17 THE AUTHORS AND THE COMPUTER SCIENCES DEPARTMENT OF THE UNIVERSITY
18 OF WISCONSIN - MADISON ALLOW FREE USE OF THIS SOFTWARE IN ITS
19 "AS IS" CONDITION, AND THEY DISCLAIM ANY LIABILITY OF ANY KIND
20 FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
21 
22 This software was developed with support by the Advanced Research
23 Project Agency, ARPA order number 018 (formerly 8230), monitored by
24 the U.S. Army Research Laboratory under contract DAAB07-91-C-Q518.
25 Further funding for this work was provided by DARPA through
26 Rome Research Laboratory Contract No. F30602-97-2-0247.
27 
28 */
29 
30 #ifndef __BASICS_H
31 #define __BASICS_H
32 
33 #include "w_defines.h"
34 
35 /* -- do not edit anything above this line -- </std-header>*/
36 
37 #include "w_base.h"
38 #include <atomic>
39 
40 /* sizes-in-bytes for all persistent data in the SM. */
41 typedef uint32_t smsize_t;
42 
43 /* For types of store, volumes, see stid_t.h and vid_t.h */
44 
45 typedef uint32_t PageID;
46 
47 typedef uint32_t StoreID;
48 
49 // Used in log archive
50 typedef int32_t run_number_t;
51 
52 /* Type of a record# on a page in SM (sans page,store,volume info) */
53 typedef int16_t slotid_t;
54 
55 /* Type of a buffer index in the bufferpool */
56 typedef uint32_t bf_idx;
57 
58 typedef std::atomic<uint32_t> atomic_bf_idx;
59 
60 /* Pair of buffer indexes where the parent page of the first index can be found at the second one */
61 typedef std::pair<bf_idx, bf_idx> bf_idx_pair;
62 
63 typedef std::pair<std::atomic<bf_idx>, std::atomic<bf_idx>> atomic_bf_idx_pair;
64 
71 typedef int16_t general_recordid_t;
72 
79  INVALID = -2,
83  PID0 = 0,
86  };
87 
89  return general - 1;
90  }
91 
93  return slot + 1;
94  }
95 };
96 
97 /* XXX duplicates w_base types. */
98 const int32_t max_int4 = 0x7fffffff; /* (1 << 31) - 1; */
99 const int32_t max_int4_minus1 = max_int4 - 1;
100 
101 const int32_t min_int4 = 0x80000000; /* -(1 << 31); */
102 
103 const uint16_t max_uint2 = 0xffff;
104 
105 const uint16_t min_uint2 = 0;
106 
107 const uint32_t max_uint4 = 0xffffffff;
108 
109 const uint32_t min_uint4 = 0;
110 
111 /*
112  * Safe Integer conversion (ie. casting) function
113  */
114 inline int u4i(uint32_t x) {
115  w_assert1(x <= (unsigned)max_int4);
116  return int(x);
117 }
118 
119 // inline unsigned int uToi(int32_t x) {assert(x>=0); return (uint) x; }
120 
121 
122 
123 inline bool is_aligned(smsize_t sz) {
124  return w_base_t::is_aligned(sz);
125 }
126 
127 inline bool is_aligned(const void* p) {
128  return w_base_t::is_aligned(p);
129 }
130 
131 /*<std-footer incl-file-exclusion='BASICS_H'> -- do not edit anything below this line -- */
132 
133 #endif // __BASICS_H /*</std-footer>*/
Definition: basics.h:79
const uint32_t min_uint4
Definition: basics.h:109
Definition: basics.h:81
#define w_assert1(x)
Level 1 should not add significant extra time.
Definition: w_base.h:198
uint32_t smsize_t
Definition: basics.h:41
static general_recordid_t from_slot_to_general(slotid_t slot)
Definition: basics.h:92
int16_t general_recordid_t
An integer to point to any record in B-tree pages.
Definition: basics.h:71
static bool is_aligned(size_t sz)
Definition: w_base.h:434
uint32_t StoreID
Definition: basics.h:47
Defines constant values/methods for general_recordid_t.
Definition: basics.h:76
std::pair< std::atomic< bf_idx >, std::atomic< bf_idx > > atomic_bf_idx_pair
Definition: basics.h:63
const uint32_t max_uint4
Definition: basics.h:107
uint32_t bf_idx
Definition: basics.h:56
const int32_t max_int4
Definition: basics.h:98
int32_t run_number_t
Definition: basics.h:50
uint32_t PageID
Definition: basics.h:45
const uint16_t max_uint2
Definition: basics.h:103
const int32_t max_int4_minus1
Definition: basics.h:99
ConstantValues
Definition: basics.h:77
static slotid_t from_general_to_slot(general_recordid_t general)
Definition: basics.h:88
int16_t slotid_t
Definition: basics.h:53
Definition: basics.h:85
std::pair< bf_idx, bf_idx > bf_idx_pair
Definition: basics.h:61
const uint16_t min_uint2
Definition: basics.h:105
bool is_aligned(smsize_t sz)
Definition: basics.h:123
std::atomic< uint32_t > atomic_bf_idx
Definition: basics.h:58
const int32_t min_int4
Definition: basics.h:101
int u4i(uint32_t x)
Definition: basics.h:114
Definition: basics.h:83