1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116
|
/* -*- Mode: C ; c-basic-offset: 2 -*- */
/*****************************************************************************
*
* Non-sleeping memory allocation
*
* Copyright (C) 2006,2007,2008,2009 Nedko Arnaudov <nedko@arnaudov.name>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 2 of the License
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
*****************************************************************************/
#ifndef MEMORY_ATOMIC_H__7B572547_304D_4597_8808_990BE4476CC3__INCLUDED
#define MEMORY_ATOMIC_H__7B572547_304D_4597_8808_990BE4476CC3__INCLUDED
typedef void * rtsafe_memory_pool_handle;
#if defined(LV2_RTSAFE_MEMORY_POOL_NAME_MAX)
/* will sleep */
bool
rtsafe_memory_pool_create(
struct lv2_rtsafe_memory_pool_provider * provider_ptr,
const char * pool_name,
size_t data_size,
size_t min_preallocated,
size_t max_preallocated,
rtsafe_memory_pool_handle * pool_ptr);
#endif
/* will sleep */
void
rtsafe_memory_pool_destroy(
rtsafe_memory_pool_handle pool);
/* will not sleep, returns NULL if no memory is available */
void *
rtsafe_memory_pool_allocate_atomic(
rtsafe_memory_pool_handle pool);
/* may sleep, will not fail under normal conditions */
void *
rtsafe_memory_pool_allocate_sleepy(
rtsafe_memory_pool_handle pool);
/* may or may not sleep, depending of whether atomic mode is enabled */
void *
rtsafe_memory_pool_allocate(
rtsafe_memory_pool_handle pool);
/* switch to atomic mode */
void
rtsafe_memory_pool_atomic(
rtsafe_memory_pool_handle pool);
/* will not sleep */
void
rtsafe_memory_pool_deallocate(
rtsafe_memory_pool_handle pool,
void * data);
typedef void * rtsafe_memory_handle;
#if defined(LV2_RTSAFE_MEMORY_POOL_NAME_MAX)
/* will sleep */
bool
rtsafe_memory_init(
struct lv2_rtsafe_memory_pool_provider * provider_ptr,
size_t max_size,
size_t prealloc_min,
size_t prealloc_max,
rtsafe_memory_handle * handle_ptr);
#endif
/* will not sleep, returns NULL if no memory is available */
void *
rtsafe_memory_allocate_atomic(
rtsafe_memory_handle memory_handle,
size_t size);
/* may sleep, will not fail under normal conditions */
void *
rtsafe_memory_allocate_sleepy(
rtsafe_memory_handle memory_handle,
size_t size);
/* may or may not sleep, depending of whether atomic mode is enabled */
void *
rtsafe_memory_allocate(
rtsafe_memory_handle memory_handle,
size_t size);
/* switch to atomic mode */
void
rtsafe_memory_atomic(
rtsafe_memory_handle memory_handle);
/* will not sleep */
void
rtsafe_memory_deallocate(
void * data);
void
rtsafe_memory_uninit(
rtsafe_memory_handle memory_handle);
#endif /* #ifndef MEMORY_ATOMIC_H__7B572547_304D_4597_8808_990BE4476CC3__INCLUDED */
|