| 1 | /***************************************************************************** |
| 2 | |
| 3 | Copyright (c) 1995, 2014, Oracle and/or its affiliates. All Rights Reserved. |
| 4 | |
| 5 | This program is free software; you can redistribute it and/or modify it under |
| 6 | the terms of the GNU General Public License as published by the Free Software |
| 7 | Foundation; version 2 of the License. |
| 8 | |
| 9 | This program is distributed in the hope that it will be useful, but WITHOUT |
| 10 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| 11 | FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. |
| 12 | |
| 13 | You should have received a copy of the GNU General Public License along with |
| 14 | this program; if not, write to the Free Software Foundation, Inc., |
| 15 | 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA |
| 16 | |
| 17 | *****************************************************************************/ |
| 18 | |
| 19 | /******************************************************************//** |
| 20 | @file include/fut0lst.h |
| 21 | File-based list utilities |
| 22 | |
| 23 | Created 11/28/1995 Heikki Tuuri |
| 24 | ***********************************************************************/ |
| 25 | |
| 26 | #ifndef fut0lst_h |
| 27 | #define fut0lst_h |
| 28 | |
| 29 | #ifndef UNIV_INNOCHECKSUM |
| 30 | |
| 31 | #include "univ.i" |
| 32 | |
| 33 | #include "fil0fil.h" |
| 34 | #include "mtr0mtr.h" |
| 35 | |
| 36 | |
| 37 | /* The C 'types' of base node and list node: these should be used to |
| 38 | write self-documenting code. Of course, the sizeof macro cannot be |
| 39 | applied to these types! */ |
| 40 | |
| 41 | typedef byte flst_base_node_t; |
| 42 | typedef byte flst_node_t; |
| 43 | |
| 44 | /* The physical size of a list base node in bytes */ |
| 45 | #define FLST_BASE_NODE_SIZE (4 + 2 * FIL_ADDR_SIZE) |
| 46 | #endif /* !UNIV_INNOCHECKSUM */ |
| 47 | |
| 48 | /* The physical size of a list node in bytes */ |
| 49 | #define FLST_NODE_SIZE (2 * FIL_ADDR_SIZE) |
| 50 | |
| 51 | #ifndef UNIV_INNOCHECKSUM |
| 52 | /********************************************************************//** |
| 53 | Initializes a list base node. */ |
| 54 | UNIV_INLINE |
| 55 | void |
| 56 | flst_init( |
| 57 | /*======*/ |
| 58 | flst_base_node_t* base, /*!< in: pointer to base node */ |
| 59 | mtr_t* mtr); /*!< in: mini-transaction handle */ |
| 60 | /********************************************************************//** |
| 61 | Adds a node as the last node in a list. */ |
| 62 | void |
| 63 | flst_add_last( |
| 64 | /*==========*/ |
| 65 | flst_base_node_t* base, /*!< in: pointer to base node of list */ |
| 66 | flst_node_t* node, /*!< in: node to add */ |
| 67 | mtr_t* mtr); /*!< in: mini-transaction handle */ |
| 68 | /********************************************************************//** |
| 69 | Adds a node as the first node in a list. */ |
| 70 | void |
| 71 | flst_add_first( |
| 72 | /*===========*/ |
| 73 | flst_base_node_t* base, /*!< in: pointer to base node of list */ |
| 74 | flst_node_t* node, /*!< in: node to add */ |
| 75 | mtr_t* mtr); /*!< in: mini-transaction handle */ |
| 76 | /********************************************************************//** |
| 77 | Removes a node. */ |
| 78 | void |
| 79 | flst_remove( |
| 80 | /*========*/ |
| 81 | flst_base_node_t* base, /*!< in: pointer to base node of list */ |
| 82 | flst_node_t* node2, /*!< in: node to remove */ |
| 83 | mtr_t* mtr); /*!< in: mini-transaction handle */ |
| 84 | /** Get the length of a list. |
| 85 | @param[in] base base node |
| 86 | @return length */ |
| 87 | UNIV_INLINE |
| 88 | ulint |
| 89 | flst_get_len( |
| 90 | const flst_base_node_t* base); |
| 91 | /********************************************************************//** |
| 92 | Gets list first node address. |
| 93 | @return file address */ |
| 94 | UNIV_INLINE |
| 95 | fil_addr_t |
| 96 | flst_get_first( |
| 97 | /*===========*/ |
| 98 | const flst_base_node_t* base, /*!< in: pointer to base node */ |
| 99 | mtr_t* mtr); /*!< in: mini-transaction handle */ |
| 100 | /********************************************************************//** |
| 101 | Gets list last node address. |
| 102 | @return file address */ |
| 103 | UNIV_INLINE |
| 104 | fil_addr_t |
| 105 | flst_get_last( |
| 106 | /*==========*/ |
| 107 | const flst_base_node_t* base, /*!< in: pointer to base node */ |
| 108 | mtr_t* mtr); /*!< in: mini-transaction handle */ |
| 109 | /********************************************************************//** |
| 110 | Gets list next node address. |
| 111 | @return file address */ |
| 112 | UNIV_INLINE |
| 113 | fil_addr_t |
| 114 | flst_get_next_addr( |
| 115 | /*===============*/ |
| 116 | const flst_node_t* node, /*!< in: pointer to node */ |
| 117 | mtr_t* mtr); /*!< in: mini-transaction handle */ |
| 118 | /********************************************************************//** |
| 119 | Gets list prev node address. |
| 120 | @return file address */ |
| 121 | UNIV_INLINE |
| 122 | fil_addr_t |
| 123 | flst_get_prev_addr( |
| 124 | /*===============*/ |
| 125 | const flst_node_t* node, /*!< in: pointer to node */ |
| 126 | mtr_t* mtr); /*!< in: mini-transaction handle */ |
| 127 | /********************************************************************//** |
| 128 | Writes a file address. */ |
| 129 | UNIV_INLINE |
| 130 | void |
| 131 | flst_write_addr( |
| 132 | /*============*/ |
| 133 | fil_faddr_t* faddr, /*!< in: pointer to file faddress */ |
| 134 | fil_addr_t addr, /*!< in: file address */ |
| 135 | mtr_t* mtr); /*!< in: mini-transaction handle */ |
| 136 | /********************************************************************//** |
| 137 | Reads a file address. |
| 138 | @return file address */ |
| 139 | UNIV_INLINE |
| 140 | fil_addr_t |
| 141 | flst_read_addr( |
| 142 | /*===========*/ |
| 143 | const fil_faddr_t* faddr, /*!< in: pointer to file faddress */ |
| 144 | mtr_t* mtr); /*!< in: mini-transaction handle */ |
| 145 | /********************************************************************//** |
| 146 | Validates a file-based list. |
| 147 | @return TRUE if ok */ |
| 148 | ibool |
| 149 | flst_validate( |
| 150 | /*==========*/ |
| 151 | const flst_base_node_t* base, /*!< in: pointer to base node of list */ |
| 152 | mtr_t* mtr1); /*!< in: mtr */ |
| 153 | |
| 154 | #include "fut0lst.ic" |
| 155 | |
| 156 | #endif /* !UNIV_INNOCHECKSUM */ |
| 157 | |
| 158 | #endif |
| 159 | |