PipeWire  0.3.27
mem.c File Reference

Data Structures

struct  mempool
 
struct  memblock
 
struct  mapping
 
struct  memmap
 

Macros

#define NAME   "mempool"
 
#define HAVE_MEMFD_CREATE   1
 
#define MFD_CLOEXEC   0x0001U
 
#define MFD_ALLOW_SEALING   0x0002U
 
#define F_LINUX_SPECIFIC_BASE   1024
 
#define F_ADD_SEALS   (F_LINUX_SPECIFIC_BASE + 9)
 
#define F_GET_SEALS   (F_LINUX_SPECIFIC_BASE + 10)
 
#define F_SEAL_SEAL   0x0001 /* prevent further seals from being set */
 
#define F_SEAL_SHRINK   0x0002 /* prevent file from shrinking */
 
#define F_SEAL_GROW   0x0004 /* prevent file from growing */
 
#define F_SEAL_WRITE   0x0008 /* prevent writes */
 
#define pw_mempool_emit(p, m, v, ...)   spa_hook_list_call(&p->listener_list, struct pw_mempool_events, m, v, ##__VA_ARGS__)
 
#define pw_mempool_emit_destroy(p)   pw_mempool_emit(p, destroy, 0)
 
#define pw_mempool_emit_added(p, b)   pw_mempool_emit(p, added, 0, b)
 
#define pw_mempool_emit_removed(p, b)   pw_mempool_emit(p, removed, 0, b)
 

Functions

struct pw_mempoolpw_mempool_new (struct pw_properties *props)
 Create a new memory pool. More...
 
void pw_mempool_clear (struct pw_mempool *pool)
 Clear a pool. More...
 
void pw_mempool_destroy (struct pw_mempool *pool)
 Clear and destroy a pool. More...
 
void pw_mempool_add_listener (struct pw_mempool *pool, struct spa_hook *listener, const struct pw_mempool_events *events, void *data)
 Listen for events. More...
 
SPA_EXPORT struct pw_memmappw_memblock_map (struct pw_memblock *block, enum pw_memmap_flags flags, uint32_t offset, uint32_t size, uint32_t tag[5])
 Map a region of a memory block. More...
 
SPA_EXPORT struct pw_memmappw_mempool_map_id (struct pw_mempool *pool, uint32_t id, enum pw_memmap_flags flags, uint32_t offset, uint32_t size, uint32_t tag[5])
 Map a region of a memory block with id. More...
 
SPA_EXPORT int pw_memmap_free (struct pw_memmap *map)
 Unmap a region. More...
 
SPA_EXPORT struct pw_memblockpw_mempool_import (struct pw_mempool *pool, enum pw_memblock_flags flags, uint32_t type, int fd)
 Import an fd into the pool. More...
 
SPA_EXPORT struct pw_memblockpw_mempool_import_block (struct pw_mempool *pool, struct pw_memblock *mem)
 Import a block from another pool. More...
 
SPA_EXPORT struct pw_memmappw_mempool_import_map (struct pw_mempool *pool, struct pw_mempool *other, void *data, uint32_t size, uint32_t tag[5])
 
int pw_mempool_remove_id (struct pw_mempool *pool, uint32_t id)
 Remove a memblock for given id. More...
 
SPA_EXPORT struct pw_memblockpw_mempool_find_ptr (struct pw_mempool *pool, const void *ptr)
 Find memblock for given ptr. More...
 
SPA_EXPORT struct pw_memblockpw_mempool_find_id (struct pw_mempool *pool, uint32_t id)
 Find memblock for given id. More...
 
SPA_EXPORT struct pw_memblockpw_mempool_find_fd (struct pw_mempool *pool, int fd)
 Find memblock for given fd. More...
 
SPA_EXPORT struct pw_memmappw_mempool_find_tag (struct pw_mempool *pool, uint32_t tag[5], size_t size)
 find a map with the given tag More...
 

Macro Definition Documentation

◆ F_ADD_SEALS

#define F_ADD_SEALS   (F_LINUX_SPECIFIC_BASE + 9)

◆ F_GET_SEALS

#define F_GET_SEALS   (F_LINUX_SPECIFIC_BASE + 10)

◆ F_LINUX_SPECIFIC_BASE

#define F_LINUX_SPECIFIC_BASE   1024

◆ F_SEAL_GROW

#define F_SEAL_GROW   0x0004 /* prevent file from growing */

◆ F_SEAL_SEAL

#define F_SEAL_SEAL   0x0001 /* prevent further seals from being set */

◆ F_SEAL_SHRINK

#define F_SEAL_SHRINK   0x0002 /* prevent file from shrinking */

◆ F_SEAL_WRITE

#define F_SEAL_WRITE   0x0008 /* prevent writes */

◆ HAVE_MEMFD_CREATE

#define HAVE_MEMFD_CREATE   1

◆ MFD_ALLOW_SEALING

#define MFD_ALLOW_SEALING   0x0002U

◆ MFD_CLOEXEC

#define MFD_CLOEXEC   0x0001U

◆ NAME

#define NAME   "mempool"

◆ pw_mempool_emit

#define pw_mempool_emit (   p,
  m,
  v,
  ... 
)    spa_hook_list_call(&p->listener_list, struct pw_mempool_events, m, v, ##__VA_ARGS__)

◆ pw_mempool_emit_added

#define pw_mempool_emit_added (   p,
 
)    pw_mempool_emit(p, added, 0, b)

◆ pw_mempool_emit_destroy

#define pw_mempool_emit_destroy (   p)    pw_mempool_emit(p, destroy, 0)

◆ pw_mempool_emit_removed

#define pw_mempool_emit_removed (   p,
 
)    pw_mempool_emit(p, removed, 0, b)

Function Documentation

◆ pw_memblock_map()

SPA_EXPORT struct pw_memmap* pw_memblock_map ( struct pw_memblock block,
enum pw_memmap_flags  flags,
uint32_t  offset,
uint32_t  size,
uint32_t  tag[5] 
)

Map a region of a memory block.

References pw_memblock::pool.

Referenced by pw_mempool_map_id().

◆ pw_memmap_free()

◆ pw_mempool_add_listener()

void pw_mempool_add_listener ( struct pw_mempool pool,
struct spa_hook *  listener,
const struct pw_mempool_events events,
void *  data 
)

Listen for events.

Referenced by pw_impl_client::pw_context_create_client().

◆ pw_mempool_clear()

void pw_mempool_clear ( struct pw_mempool pool)

◆ pw_mempool_destroy()

void pw_mempool_destroy ( struct pw_mempool pool)

◆ pw_mempool_find_fd()

SPA_EXPORT struct pw_memblock* pw_mempool_find_fd ( struct pw_mempool pool,
int  fd 
)

Find memblock for given fd.

◆ pw_mempool_find_id()

SPA_EXPORT struct pw_memblock* pw_mempool_find_id ( struct pw_mempool pool,
uint32_t  id 
)

Find memblock for given id.

References NAME, pw_log::pw_log_debug, pw_map::pw_map_lookup(), and memblock::this.

◆ pw_mempool_find_ptr()

SPA_EXPORT struct pw_memblock* pw_mempool_find_ptr ( struct pw_mempool pool,
const void *  ptr 
)

◆ pw_mempool_find_tag()

SPA_EXPORT struct pw_memmap* pw_mempool_find_tag ( struct pw_mempool pool,
uint32_t  tag[5],
size_t  size 
)

find a map with the given tag

References memmap::link, memblock::memmaps, NAME, pw_log::pw_log_debug, pw_memmap::tag, and memmap::this.

◆ pw_mempool_import()

SPA_EXPORT struct pw_memblock* pw_mempool_import ( struct pw_mempool pool,
enum pw_memblock_flags  flags,
uint32_t  type,
int  fd 
)

Import an fd into the pool.

Referenced by pw_mempool_import_block().

◆ pw_mempool_import_block()

SPA_EXPORT struct pw_memblock* pw_mempool_import_block ( struct pw_mempool pool,
struct pw_memblock mem 
)

◆ pw_mempool_import_map()

SPA_EXPORT struct pw_memmap* pw_mempool_import_map ( struct pw_mempool pool,
struct pw_mempool other,
void *  data,
uint32_t  size,
uint32_t  tag[5] 
)

◆ pw_mempool_map_id()

SPA_EXPORT struct pw_memmap* pw_mempool_map_id ( struct pw_mempool pool,
uint32_t  id,
enum pw_memmap_flags  flags,
uint32_t  offset,
uint32_t  size,
uint32_t  tag[5] 
)

Map a region of a memory block with id.

References pw_map::pw_map_lookup(), pw_memblock_map(), and memblock::this.

◆ pw_mempool_new()

struct pw_mempool* pw_mempool_new ( struct pw_properties props)

◆ pw_mempool_remove_id()

int pw_mempool_remove_id ( struct pw_mempool pool,
uint32_t  id 
)