basics.h

00001 /*<std-header orig-src='shore' incl-file-exclusion='BASICS_H'>
00002 
00003  $Id: basics.h,v 1.72 2010/07/07 21:43:43 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 // This is for servers. SM_SOURCE is defined in the SM sources.
00061 namespace locking {
00062     typedef w_base_t::lock_duration_t  lock_duration_t; 
00063     typedef w_base_t::lock_mode_t  lock_mode_t; 
00064     static const lock_mode_t NL = w_base_t::NL;
00065     static const lock_mode_t IS = w_base_t::IS;
00066     static const lock_mode_t IX = w_base_t::IX;
00067     static const lock_mode_t SH = w_base_t::SH;
00068     static const lock_mode_t SIX = w_base_t::SIX;
00069     static const lock_mode_t UD = w_base_t::UD;
00070     static const lock_mode_t EX = w_base_t::EX;
00071 };
00072 using namespace locking;
00073 
00074 /**\brief Types for API used for 2PC */
00075 namespace two_phase_commit {
00076     typedef w_base_t::vote_t  vote_t; 
00077 };
00078 using namespace two_phase_commit;
00079 #endif
00080 
00081 
00082 /* Type of a record# on a page  in SM (sans page,store,volume info) */
00083 typedef w_base_t::int2_t slotid_t;  
00084 
00085 /* XXX duplicates w_base types. */
00086 const int2_t    max_int2 = 0x7fff;         /*  (1 << 15) - 1;     */
00087 const int2_t    min_int2 = (short)0x8000;     /* -(1 << 15);        */
00088 const int4_t    max_int4 = 0x7fffffff;         /*  (1 << 31) - 1;  */
00089 const int4_t    max_int4_minus1 = max_int4 -1;
00090 const int4_t    min_int4 = 0x80000000;         /* -(1 << 31);        */
00091 
00092 const uint2_t    max_uint2 = 0xffff;
00093 const uint2_t    min_uint2 = 0;
00094 const uint4_t    max_uint4 = 0xffffffff;
00095 const uint4_t    min_uint4 = 0;
00096 
00097 
00098 
00099 /*
00100  * Safe Integer conversion (ie. casting) function
00101  */
00102 inline int u4i(uint4_t x) {w_assert1(x<=(unsigned)max_int4); return int(x); }
00103 
00104 // inline unsigned int  uToi(int4_t x) {assert(x>=0); return (uint) x; }
00105 
00106 
00107 
00108 inline bool is_aligned(smsize_t sz)
00109 {
00110     return w_base_t::is_aligned(sz);
00111 }
00112 
00113 inline bool is_aligned(const void* p)
00114 {
00115     return w_base_t::is_aligned(p);
00116 }
00117 
00118 /*<std-footer incl-file-exclusion='BASICS_H'>  -- do not edit anything below this line -- */
00119 
00120 #endif          /*</std-footer>*/

Generated on Wed Jul 7 17:22:31 2010 for Shore Storage Manager by  doxygen 1.4.7