1 /*****************************************************************************
2 
3 Copyright (c) 2006, 2016, 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/buf0buddy.h
29 Binary buddy allocator for compressed pages
30 
31 Created December 2006 by Marko Makela
32 *******************************************************/
33 
34 #ifndef buf0buddy_h
35 #define buf0buddy_h
36 
37 #ifdef UNIV_MATERIALIZE
38 # undef UNIV_INLINE
39 # define UNIV_INLINE
40 #endif
41 
42 #include "univ.i"
43 #include "buf0types.h"
44 
45 /**********************************************************************//**
46 Allocate a block.  The thread calling this function must hold
47 buf_pool->LRU_list_mutex and must not hold buf_pool->zip_mutex or any
48 block->mutex.  The buf_pool->LRU_list_mutex may be released and reacquired.
49 This function should only be used for allocating compressed page frames.
50 @return	allocated block, never NULL */
51 UNIV_INLINE
52 byte*
53 buf_buddy_alloc(
54 /*============*/
55 	buf_pool_t*	buf_pool,	/*!< in/out: buffer pool in which
56 					the page resides */
57 	ulint		size,		/*!< in: compressed page size
58 					(between UNIV_ZIP_SIZE_MIN and
59 					UNIV_PAGE_SIZE) */
60 	ibool*		lru)		/*!< in: pointer to a variable
61 					that will be assigned TRUE if
62 				       	storage was allocated from the
63 					LRU list and buf_pool->LRU_list_mutex
64 					was temporarily released */
65 	MY_ATTRIBUTE((malloc, nonnull));
66 
67 /**********************************************************************//**
68 Deallocate a block. */
69 UNIV_INLINE
70 void
71 buf_buddy_free(
72 /*===========*/
73 	buf_pool_t*	buf_pool,	/*!< in/out: buffer pool in which
74 					the block resides */
75 	void*		buf,		/*!< in: block to be freed, must not
76 					be pointed to by the buffer pool */
77 	ulint		size)		/*!< in: block size,
78 					up to UNIV_PAGE_SIZE */
79 	MY_ATTRIBUTE((nonnull));
80 
81 #ifndef UNIV_NONINL
82 # include "buf0buddy.ic"
83 #endif
84 
85 #endif /* buf0buddy_h */
86