1 /***************************************************************************** 2 3 Copyright (c) 1995, 2009, Oracle and/or its affiliates. All Rights Reserved. 4 5 This program is free software; you can redistribute it and/or modify 6 it under the terms of the GNU General Public License, version 2.0, 7 as published by the Free Software Foundation. 8 9 This program is also distributed with certain software (including 10 but not limited to OpenSSL) that is licensed under separate terms, 11 as designated in a particular file or component or in included license 12 documentation. The authors of MySQL hereby grant you an additional 13 permission to link the program and your derivative works with the 14 separately licensed software that they have included with MySQL. 15 16 This program is distributed in the hope that it will be useful, 17 but WITHOUT ANY WARRANTY; without even the implied warranty of 18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 GNU General Public License, version 2.0, for more details. 20 21 You should have received a copy of the GNU General Public License along with 22 this program; if not, write to the Free Software Foundation, Inc., 23 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA 24 25 *****************************************************************************/ 26 27 /******************************************************************//** 28 @file include/fut0lst.h 29 File-based list utilities 30 31 Created 11/28/1995 Heikki Tuuri 32 ***********************************************************************/ 33 34 #ifndef fut0lst_h 35 #define fut0lst_h 36 37 #include "univ.i" 38 39 #include "fil0fil.h" 40 #include "mtr0mtr.h" 41 42 43 /* The C 'types' of base node and list node: these should be used to 44 write self-documenting code. Of course, the sizeof macro cannot be 45 applied to these types! */ 46 47 typedef byte flst_base_node_t; 48 typedef byte flst_node_t; 49 50 /* The physical size of a list base node in bytes */ 51 #define FLST_BASE_NODE_SIZE (4 + 2 * FIL_ADDR_SIZE) 52 53 /* The physical size of a list node in bytes */ 54 #define FLST_NODE_SIZE (2 * FIL_ADDR_SIZE) 55 56 #ifndef UNIV_HOTBACKUP 57 /********************************************************************//** 58 Initializes a list base node. */ 59 UNIV_INLINE 60 void 61 flst_init( 62 /*======*/ 63 flst_base_node_t* base, /*!< in: pointer to base node */ 64 mtr_t* mtr); /*!< in: mini-transaction handle */ 65 /********************************************************************//** 66 Adds a node as the last node in a list. */ 67 UNIV_INTERN 68 void 69 flst_add_last( 70 /*==========*/ 71 flst_base_node_t* base, /*!< in: pointer to base node of list */ 72 flst_node_t* node, /*!< in: node to add */ 73 mtr_t* mtr); /*!< in: mini-transaction handle */ 74 /********************************************************************//** 75 Adds a node as the first node in a list. */ 76 UNIV_INTERN 77 void 78 flst_add_first( 79 /*===========*/ 80 flst_base_node_t* base, /*!< in: pointer to base node of list */ 81 flst_node_t* node, /*!< in: node to add */ 82 mtr_t* mtr); /*!< in: mini-transaction handle */ 83 /********************************************************************//** 84 Inserts a node after another in a list. */ 85 UNIV_INTERN 86 void 87 flst_insert_after( 88 /*==============*/ 89 flst_base_node_t* base, /*!< in: pointer to base node of list */ 90 flst_node_t* node1, /*!< in: node to insert after */ 91 flst_node_t* node2, /*!< in: node to add */ 92 mtr_t* mtr); /*!< in: mini-transaction handle */ 93 /********************************************************************//** 94 Inserts a node before another in a list. */ 95 UNIV_INTERN 96 void 97 flst_insert_before( 98 /*===============*/ 99 flst_base_node_t* base, /*!< in: pointer to base node of list */ 100 flst_node_t* node2, /*!< in: node to insert */ 101 flst_node_t* node3, /*!< in: node to insert before */ 102 mtr_t* mtr); /*!< in: mini-transaction handle */ 103 /********************************************************************//** 104 Removes a node. */ 105 UNIV_INTERN 106 void 107 flst_remove( 108 /*========*/ 109 flst_base_node_t* base, /*!< in: pointer to base node of list */ 110 flst_node_t* node2, /*!< in: node to remove */ 111 mtr_t* mtr); /*!< in: mini-transaction handle */ 112 /********************************************************************//** 113 Cuts off the tail of the list, including the node given. The number of 114 nodes which will be removed must be provided by the caller, as this function 115 does not measure the length of the tail. */ 116 UNIV_INTERN 117 void 118 flst_cut_end( 119 /*=========*/ 120 flst_base_node_t* base, /*!< in: pointer to base node of list */ 121 flst_node_t* node2, /*!< in: first node to remove */ 122 ulint n_nodes,/*!< in: number of nodes to remove, 123 must be >= 1 */ 124 mtr_t* mtr); /*!< in: mini-transaction handle */ 125 /********************************************************************//** 126 Cuts off the tail of the list, not including the given node. The number of 127 nodes which will be removed must be provided by the caller, as this function 128 does not measure the length of the tail. */ 129 UNIV_INTERN 130 void 131 flst_truncate_end( 132 /*==============*/ 133 flst_base_node_t* base, /*!< in: pointer to base node of list */ 134 flst_node_t* node2, /*!< in: first node not to remove */ 135 ulint n_nodes,/*!< in: number of nodes to remove */ 136 mtr_t* mtr); /*!< in: mini-transaction handle */ 137 /********************************************************************//** 138 Gets list length. 139 @return length */ 140 UNIV_INLINE 141 ulint 142 flst_get_len( 143 /*=========*/ 144 const flst_base_node_t* base, /*!< in: pointer to base node */ 145 mtr_t* mtr); /*!< in: mini-transaction handle */ 146 /********************************************************************//** 147 Gets list first node address. 148 @return file address */ 149 UNIV_INLINE 150 fil_addr_t 151 flst_get_first( 152 /*===========*/ 153 const flst_base_node_t* base, /*!< in: pointer to base node */ 154 mtr_t* mtr); /*!< in: mini-transaction handle */ 155 /********************************************************************//** 156 Gets list last node address. 157 @return file address */ 158 UNIV_INLINE 159 fil_addr_t 160 flst_get_last( 161 /*==========*/ 162 const flst_base_node_t* base, /*!< in: pointer to base node */ 163 mtr_t* mtr); /*!< in: mini-transaction handle */ 164 /********************************************************************//** 165 Gets list next node address. 166 @return file address */ 167 UNIV_INLINE 168 fil_addr_t 169 flst_get_next_addr( 170 /*===============*/ 171 const flst_node_t* node, /*!< in: pointer to node */ 172 mtr_t* mtr); /*!< in: mini-transaction handle */ 173 /********************************************************************//** 174 Gets list prev node address. 175 @return file address */ 176 UNIV_INLINE 177 fil_addr_t 178 flst_get_prev_addr( 179 /*===============*/ 180 const flst_node_t* node, /*!< in: pointer to node */ 181 mtr_t* mtr); /*!< in: mini-transaction handle */ 182 /********************************************************************//** 183 Writes a file address. */ 184 UNIV_INLINE 185 void 186 flst_write_addr( 187 /*============*/ 188 fil_faddr_t* faddr, /*!< in: pointer to file faddress */ 189 fil_addr_t addr, /*!< in: file address */ 190 mtr_t* mtr); /*!< in: mini-transaction handle */ 191 /********************************************************************//** 192 Reads a file address. 193 @return file address */ 194 UNIV_INLINE 195 fil_addr_t 196 flst_read_addr( 197 /*===========*/ 198 const fil_faddr_t* faddr, /*!< in: pointer to file faddress */ 199 mtr_t* mtr); /*!< in: mini-transaction handle */ 200 /********************************************************************//** 201 Validates a file-based list. 202 @return TRUE if ok */ 203 UNIV_INTERN 204 ibool 205 flst_validate( 206 /*==========*/ 207 const flst_base_node_t* base, /*!< in: pointer to base node of list */ 208 mtr_t* mtr1); /*!< in: mtr */ 209 /********************************************************************//** 210 Prints info of a file-based list. */ 211 UNIV_INTERN 212 void 213 flst_print( 214 /*=======*/ 215 const flst_base_node_t* base, /*!< in: pointer to base node of list */ 216 mtr_t* mtr); /*!< in: mtr */ 217 218 219 #ifndef UNIV_NONINL 220 #include "fut0lst.ic" 221 #endif 222 223 #endif /* !UNIV_HOTBACKUP */ 224 225 #endif 226