basics.h

00001 /*<std-header orig-src='shore' incl-file-exclusion='BASICS_H'>
00002 
00003  $Id: basics.h,v 1.74 2012/01/02 17:02:10 nhall Exp $
00004 
00005 SHORE -- Scalable Heterogeneous Object REpository
00006 
00007 Copyright (c) 1994-99 Computer Sciences Department, University of
00008                       Wisconsin -- Madison
00009 All Rights Reserved.
00010 
00011 Permission to use, copy, modify and distribute this software and its
00012 documentation is hereby granted, provided that both the copyright
00013 notice and this permission notice appear in all copies of the
00014 software, derivative works or modified versions, and any portions
00015 thereof, and that both notices appear in supporting documentation.
00016 
00017 THE AUTHORS AND THE COMPUTER SCIENCES DEPARTMENT OF THE UNIVERSITY
00018 OF WISCONSIN - MADISON ALLOW FREE USE OF THIS SOFTWARE IN ITS
00019 "AS IS" CONDITION, AND THEY DISCLAIM ANY LIABILITY OF ANY KIND
00020 FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
00021 
00022 This software was developed with support by the Advanced Research
00023 Project Agency, ARPA order number 018 (formerly 8230), monitored by
00024 the U.S. Army Research Laboratory under contract DAAB07-91-C-Q518.
00025 Further funding for this work was provided by DARPA through
00026 Rome Research Laboratory Contract No. F30602-97-2-0247.
00027 
00028 */
00029 
00030 #ifndef BASICS_H
00031 #define BASICS_H
00032 
00033 #include "w_defines.h"
00034 
00035 /*  -- do not edit anything above this line --   </std-header>*/
00036 
00037 #ifdef __GNUG__
00038 #pragma interface
00039 #endif
00040 
00041 #ifndef W_BASE_H
00042 #include <w_base.h>
00043 #endif
00044 
00045 typedef w_base_t::int1_t      int1_t;
00046 typedef w_base_t::int2_t      int2_t;
00047 typedef w_base_t::int4_t      int4_t;
00048 typedef w_base_t::uint1_t     uint1_t;
00049 typedef w_base_t::uint2_t     uint2_t;
00050 typedef w_base_t::uint4_t     uint4_t;
00051 
00052 /* sizes-in-bytes for all persistent data in the SM. */
00053 typedef uint4_t               smsize_t;
00054 
00055 /* For types of store, volumes, see stid_t.h and vid_t.h */
00056 
00057 typedef w_base_t::uint4_t    shpid_t; 
00058 
00059 #ifndef SM_SOURCE
00060 /**\brief lock modes and duration type.
00061  * Exported to API for use by servers to simplify the names.
00062  */
00063 namespace locking {
00064  typedef w_base_t::lock_duration_t  lock_duration_t; 
00065  typedef w_base_t::lock_mode_t  lock_mode_t; 
00066  static const lock_mode_t NL = w_base_t::NL;
00067  static const lock_mode_t IS = w_base_t::IS;
00068  static const lock_mode_t IX = w_base_t::IX;
00069  static const lock_mode_t SH = w_base_t::SH;
00070  static const lock_mode_t SIX = w_base_t::SIX;
00071  static const lock_mode_t UD = w_base_t::UD;
00072  static const lock_mode_t EX = w_base_t::EX;
00073 }
00074 using namespace locking;
00075 
00076 /**\brief Types for API used for 2PC */
00077 namespace two_phase_commit {
00078  typedef w_base_t::vote_t  vote_t; 
00079 }
00080 using namespace two_phase_commit;
00081 #endif
00082 
00083 
00084 /* Type of a record# on a page  in SM (sans page,store,volume info) */
00085 typedef w_base_t::int2_t slotid_t;  
00086 
00087 /* XXX duplicates w_base types. */
00088 const int2_t    max_int2 = 0x7fff;         /*  (1 << 15) - 1;     */
00089 const int2_t    min_int2 = (short)0x8000;     /* -(1 << 15);        */
00090 const int4_t    max_int4 = 0x7fffffff;         /*  (1 << 31) - 1;  */
00091 const int4_t    max_int4_minus1 = max_int4 -1;
00092 const int4_t    min_int4 = 0x80000000;         /* -(1 << 31);        */
00093 
00094 const uint2_t    max_uint2 = 0xffff;
00095 const uint2_t    min_uint2 = 0;
00096 const uint4_t    max_uint4 = 0xffffffff;
00097 const uint4_t    min_uint4 = 0;
00098 
00099 
00100 
00101 /*
00102  * Safe Integer conversion (ie. casting) function
00103  */
00104 inline int u4i(uint4_t x) {w_assert1(x<=(unsigned)max_int4); return int(x); }
00105 
00106 // inline unsigned int  uToi(int4_t x) {assert(x>=0); return (uint) x; }
00107 
00108 
00109 
00110 inline bool is_aligned(smsize_t sz)
00111 {
00112     return w_base_t::is_aligned(sz);
00113 }
00114 
00115 inline bool is_aligned(const void* p)
00116 {
00117     return w_base_t::is_aligned(p);
00118 }
00119 
00120 /*<std-footer incl-file-exclusion='BASICS_H'>  -- do not edit anything below this line -- */
00121 
00122 #endif          /*</std-footer>*/

Generated on Mon Jan 2 15:13:56 2012 for Shore Storage Manager by  doxygen 1.4.7