mirror of
https://github.com/MariaDB/server.git
synced 2025-02-02 03:51:50 +01:00
13049a9e3a
twice the maximum block size of the buddy system. buf_page_t: Note that state may change from BUF_BLOCK_READY_FOR_USE to BUF_BLOCK_MEMORY without buf_page_get_mutex() protection [only buf_pool->mutex]. buf_buddy_get_slot(): Extend the output to BUF_BUDDY_SIZES. buf_buddy_alloc(), buf_buddy_free(): Allow sizes up to UNIV_PAGE_SIZE. buf_buddy_alloc_low(), buf_buddy_free_low(), buf_buddy_alloc_clean(): Allow i==BUF_BUDDY_SIZES.
72 lines
2 KiB
C
72 lines
2 KiB
C
/******************************************************
|
|
Binary buddy allocator for compressed pages
|
|
|
|
(c) 2006 Innobase Oy
|
|
|
|
Created December 2006 by Marko Makela
|
|
*******************************************************/
|
|
|
|
#ifndef buf0buddy_h
|
|
#define buf0buddy_h
|
|
|
|
#ifdef UNIV_MATERIALIZE
|
|
# undef UNIV_INLINE
|
|
# define UNIV_INLINE
|
|
#endif
|
|
|
|
#include "univ.i"
|
|
#include "buf0types.h"
|
|
|
|
/**************************************************************************
|
|
Get the offset of the buddy of a compressed page frame. */
|
|
UNIV_INLINE
|
|
lint
|
|
buf_buddy_get_offset(
|
|
/*=================*/
|
|
/* out: offset of the buddy relative to page */
|
|
const void* page, /* in: compressed page */
|
|
ulint size) /* in: page size in bytes */
|
|
__attribute__((nonnull));
|
|
|
|
/**************************************************************************
|
|
Get the buddy of a compressed page frame.
|
|
Note: "page" should be a pointer to byte or char. */
|
|
#define buf_buddy_get(page,size) ((page) + buf_buddy_get_offset((page),(size)))
|
|
|
|
/**************************************************************************
|
|
Get the index of buf_pool->zip_free[] for a given block size. */
|
|
UNIV_INLINE
|
|
ulint
|
|
buf_buddy_get_slot(
|
|
/*===============*/
|
|
/* out: index of buf_pool->zip_free[],
|
|
or BUF_BUDDY_SIZES */
|
|
ulint size); /* in: block size */
|
|
|
|
/**************************************************************************
|
|
Allocate a block. */
|
|
UNIV_INLINE
|
|
void*
|
|
buf_buddy_alloc(
|
|
/*============*/
|
|
/* out: pointer to the start of the block */
|
|
ulint size, /* in: block size, up to UNIV_PAGE_SIZE */
|
|
ibool lru) /* in: TRUE=allocate from the LRU list if needed */
|
|
__attribute__((malloc));
|
|
|
|
/**************************************************************************
|
|
Release a block. */
|
|
UNIV_INLINE
|
|
void
|
|
buf_buddy_free(
|
|
/*===========*/
|
|
void* buf, /* in: block to be freed, must not be
|
|
pointed to by the buffer pool */
|
|
ulint size) /* in: block size, up to UNIV_PAGE_SIZE */
|
|
__attribute__((nonnull));
|
|
|
|
#ifndef UNIV_NONINL
|
|
# include "buf0buddy.ic"
|
|
#endif
|
|
|
|
#endif /* buf0buddy_h */
|