~ubuntu-branches/ubuntu/precise/mysql-5.1/precise

« back to all changes in this revision

Viewing changes to storage/ndb/include/kernel/signaldata/TcKeyConf.hpp

  • Committer: Bazaar Package Importer
  • Author(s): Norbert Tretkowski
  • Date: 2010-03-17 14:56:02 UTC
  • Revision ID: james.westby@ubuntu.com-20100317145602-x7e30l1b2sb5s6w6
Tags: upstream-5.1.45
ImportĀ upstreamĀ versionĀ 5.1.45

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* Copyright (C) 2003 MySQL AB
 
2
 
 
3
   This program is free software; you can redistribute it and/or modify
 
4
   it under the terms of the GNU General Public License as published by
 
5
   the Free Software Foundation; version 2 of the License.
 
6
 
 
7
   This program is distributed in the hope that it will be useful,
 
8
   but WITHOUT ANY WARRANTY; without even the implied warranty of
 
9
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
10
   GNU General Public License for more details.
 
11
 
 
12
   You should have received a copy of the GNU General Public License
 
13
   along with this program; if not, write to the Free Software
 
14
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
 
15
 
 
16
#ifndef TC_KEY_CONF_H
 
17
#define TC_KEY_CONF_H
 
18
 
 
19
#include "SignalData.hpp"
 
20
 
 
21
/**
 
22
 * 
 
23
 */
 
24
class TcKeyConf {
 
25
  /**
 
26
   * Reciver(s)
 
27
   */
 
28
  friend class Ndb;
 
29
  friend class NdbTransaction;
 
30
  friend class Ndbcntr;
 
31
  friend class DbUtil;
 
32
 
 
33
  /**
 
34
   * Sender(s)
 
35
   */
 
36
  friend class Dbtc;
 
37
 
 
38
  /**
 
39
   * For printing
 
40
   */
 
41
  friend bool printTCKEYCONF(FILE *, const Uint32 *, Uint32, Uint16);
 
42
 
 
43
public:
 
44
  /**
 
45
   * Length of signal
 
46
   */
 
47
  STATIC_CONST( StaticLength = 5 );
 
48
  STATIC_CONST( OperationLength = 2 );
 
49
  STATIC_CONST( DirtyReadBit = (((Uint32)1) << 31) );
 
50
  
 
51
private:
 
52
 
 
53
  /**
 
54
   * DATA VARIABLES
 
55
   */
 
56
  //-------------------------------------------------------------
 
57
  // Unconditional part. First 5 words
 
58
  //-------------------------------------------------------------
 
59
 
 
60
  Uint32 apiConnectPtr;
 
61
  Uint32 gci;
 
62
  Uint32 confInfo;
 
63
  Uint32 transId1;
 
64
  Uint32 transId2;
 
65
 
 
66
  struct OperationConf {
 
67
    Uint32 apiOperationPtr;
 
68
    Uint32 attrInfoLen;
 
69
  };
 
70
  //-------------------------------------------------------------
 
71
  // Operations confirmations,
 
72
  // No of actually sent = getNoOfOperations(confInfo)
 
73
  //-------------------------------------------------------------
 
74
  OperationConf operations[10];
 
75
  
 
76
  /**
 
77
   * Get:ers for confInfo
 
78
   */
 
79
  static Uint32 getNoOfOperations(const Uint32 & confInfo);
 
80
  static Uint32 getCommitFlag(const Uint32 & confInfo);
 
81
  static bool getMarkerFlag(const Uint32 & confInfo);
 
82
  
 
83
  /**
 
84
   * Set:ers for confInfo
 
85
   */
 
86
  static void setCommitFlag(Uint32 & confInfo, Uint8 flag);
 
87
  static void setNoOfOperations(Uint32 & confInfo, Uint32 noOfOps);
 
88
  static void setMarkerFlag(Uint32 & confInfo, Uint32 flag);
 
89
};
 
90
 
 
91
inline
 
92
Uint32
 
93
TcKeyConf::getNoOfOperations(const Uint32 & confInfo){
 
94
  return confInfo & 65535;
 
95
}
 
96
 
 
97
inline
 
98
Uint32
 
99
TcKeyConf::getCommitFlag(const Uint32 & confInfo){
 
100
  return ((confInfo >> 16) & 1);
 
101
}
 
102
 
 
103
inline
 
104
bool
 
105
TcKeyConf::getMarkerFlag(const Uint32 & confInfo){
 
106
  const Uint32 bits = 3 << 16; // Marker only valid when doing commit
 
107
  return (confInfo & bits) == bits;
 
108
}
 
109
 
 
110
inline
 
111
void 
 
112
TcKeyConf::setNoOfOperations(Uint32 & confInfo, Uint32 noOfOps){
 
113
  ASSERT_MAX(noOfOps, 65535, "TcKeyConf::setNoOfOperations");
 
114
  confInfo = (confInfo & 0xFFFF0000) | noOfOps;
 
115
}
 
116
 
 
117
inline
 
118
void 
 
119
TcKeyConf::setCommitFlag(Uint32 & confInfo, Uint8 flag){
 
120
  ASSERT_BOOL(flag, "TcKeyConf::setCommitFlag");
 
121
  confInfo |= (flag << 16);
 
122
}
 
123
 
 
124
inline
 
125
void
 
126
TcKeyConf::setMarkerFlag(Uint32 & confInfo, Uint32 flag){
 
127
  ASSERT_BOOL(flag, "TcKeyConf::setMarkerFlag");
 
128
  confInfo |= (flag << 17);
 
129
}
 
130
 
 
131
#endif