~drizzle-pbxt/drizzle/drizzle-pbxt-2

« back to all changes in this revision

Viewing changes to plugin/innobase/include/buf0buddy.ic

  • Committer: Paul McCullagh
  • Date: 2009-11-10 14:18:39 UTC
  • mfrom: (1038.1.7 drizzle-pbxt-pre-merge)
  • Revision ID: paul.mccullagh@primebase.org-20091110141839-2j3k43b17ag6f605
Merged Drizzle trunk and PBXT 1.0.09

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 
17
17
*****************************************************************************/
18
18
 
19
 
/******************************************************
 
19
/**************************************************//**
 
20
@file include/buf0buddy.ic
20
21
Binary buddy allocator for compressed pages
21
22
 
22
23
Created December 2006 by Marko Makela
32
33
#include "ut0ut.h"
33
34
#include "sync0sync.h"
34
35
 
35
 
/**************************************************************************
 
36
/**********************************************************************//**
36
37
Allocate a block.  The thread calling this function must hold
37
38
buf_pool_mutex and must not hold buf_pool_zip_mutex or any block->mutex.
38
 
The buf_pool_mutex may only be released and reacquired if lru != NULL. */
 
39
The buf_pool_mutex may only be released and reacquired if lru != NULL.
 
40
@return allocated block, possibly NULL if lru==NULL */
39
41
UNIV_INTERN
40
42
void*
41
43
buf_buddy_alloc_low(
42
44
/*================*/
43
 
                        /* out: allocated block,
44
 
                        possibly NULL if lru==NULL */
45
 
        ulint   i,      /* in: index of buf_pool->zip_free[],
 
45
        ulint   i,      /*!< in: index of buf_pool->zip_free[],
46
46
                        or BUF_BUDDY_SIZES */
47
 
        ibool*  lru)    /* in: pointer to a variable that will be assigned
 
47
        ibool*  lru)    /*!< in: pointer to a variable that will be assigned
48
48
                        TRUE if storage was allocated from the LRU list
49
49
                        and buf_pool_mutex was temporarily released,
50
50
                        or NULL if the LRU list should not be used */
51
51
        __attribute__((malloc));
52
52
 
53
 
/**************************************************************************
 
53
/**********************************************************************//**
54
54
Deallocate a block. */
55
55
UNIV_INTERN
56
56
void
57
57
buf_buddy_free_low(
58
58
/*===============*/
59
 
        void*   buf,    /* in: block to be freed, must not be
 
59
        void*   buf,    /*!< in: block to be freed, must not be
60
60
                        pointed to by the buffer pool */
61
 
        ulint   i)      /* in: index of buf_pool->zip_free[],
 
61
        ulint   i)      /*!< in: index of buf_pool->zip_free[],
62
62
                        or BUF_BUDDY_SIZES */
63
63
        __attribute__((nonnull));
64
64
 
65
 
/**************************************************************************
66
 
Get the index of buf_pool->zip_free[] for a given block size. */
 
65
/**********************************************************************//**
 
66
Get the index of buf_pool->zip_free[] for a given block size.
 
67
@return index of buf_pool->zip_free[], or BUF_BUDDY_SIZES */
67
68
UNIV_INLINE
68
69
ulint
69
70
buf_buddy_get_slot(
70
71
/*===============*/
71
 
                        /* out: index of buf_pool->zip_free[],
72
 
                        or BUF_BUDDY_SIZES */
73
 
        ulint   size)   /* in: block size */
 
72
        ulint   size)   /*!< in: block size */
74
73
{
75
74
        ulint   i;
76
75
        ulint   s;
82
81
        return(i);
83
82
}
84
83
 
85
 
/**************************************************************************
 
84
/**********************************************************************//**
86
85
Allocate a block.  The thread calling this function must hold
87
86
buf_pool_mutex and must not hold buf_pool_zip_mutex or any
88
87
block->mutex.  The buf_pool_mutex may only be released and reacquired
90
89
compressed page frames or control blocks (buf_page_t).  Allocated
91
90
control blocks must be properly initialized immediately after
92
91
buf_buddy_alloc() has returned the memory, before releasing
93
 
buf_pool_mutex. */
 
92
buf_pool_mutex.
 
93
@return allocated block, possibly NULL if lru == NULL */
94
94
UNIV_INLINE
95
95
void*
96
96
buf_buddy_alloc(
97
97
/*============*/
98
 
                        /* out: allocated block,
99
 
                        possibly NULL if lru == NULL */
100
 
        ulint   size,   /* in: block size, up to UNIV_PAGE_SIZE */
101
 
        ibool*  lru)    /* in: pointer to a variable that will be assigned
 
98
        ulint   size,   /*!< in: block size, up to UNIV_PAGE_SIZE */
 
99
        ibool*  lru)    /*!< in: pointer to a variable that will be assigned
102
100
                        TRUE if storage was allocated from the LRU list
103
101
                        and buf_pool_mutex was temporarily released,
104
102
                        or NULL if the LRU list should not be used */
108
106
        return(buf_buddy_alloc_low(buf_buddy_get_slot(size), lru));
109
107
}
110
108
 
111
 
/**************************************************************************
 
109
/**********************************************************************//**
112
110
Deallocate a block. */
113
111
UNIV_INLINE
114
112
void
115
113
buf_buddy_free(
116
114
/*===========*/
117
 
        void*   buf,    /* in: block to be freed, must not be
 
115
        void*   buf,    /*!< in: block to be freed, must not be
118
116
                        pointed to by the buffer pool */
119
 
        ulint   size)   /* in: block size, up to UNIV_PAGE_SIZE */
 
117
        ulint   size)   /*!< in: block size, up to UNIV_PAGE_SIZE */
120
118
{
121
119
        ut_ad(buf_pool_mutex_own());
122
120