RTEMS 6.1-rc5
Loading...
Searching...
No Matches
Macros | Functions
rtl-bit-alloc.c File Reference

RTEMS Run-Time Link Editor Bit Allocator. More...

#include <errno.h>
#include <inttypes.h>
#include <stdio.h>
#include <string.h>
#include <rtems/rtl/rtl-allocator.h>
#include "rtl-bit-alloc.h"
#include "rtl-error.h"
#include <rtems/rtl/rtl-trace.h>

Macros

#define BITS_PER_WORD   (sizeof (uint32_t) * 8)
 

Functions

rtems_rtl_bit_allocrtems_rtl_bit_alloc_open (void *base, size_t size, size_t block_size, size_t used)
 
void rtems_rtl_bit_alloc_close (rtems_rtl_bit_alloc *balloc)
 
void * rtems_rtl_bit_alloc_balloc (rtems_rtl_bit_alloc *balloc, size_t size)
 
void rtems_rtl_bit_alloc_bfree (rtems_rtl_bit_alloc *balloc, void *addr, size_t size)
 

Detailed Description

RTEMS Run-Time Link Editor Bit Allocator.

A configurable allocator for small peices of memory where embedding control blocks into the memory are not viable. The amount of memory should be small and the minimum allocator a 32bit work or higher.

Function Documentation

◆ rtems_rtl_bit_alloc_balloc()

void * rtems_rtl_bit_alloc_balloc ( rtems_rtl_bit_alloc balloc,
size_t  size 
)

Allocate a piece of memory being managed. The size is in bytes are is rounded up the next block size.

Parameters
ballocThe allocator.
sizeNumber of bytes to allocate.
Returns
void* The memory if the allocation is successful else NULL if there is no more memory.

◆ rtems_rtl_bit_alloc_bfree()

void rtems_rtl_bit_alloc_bfree ( rtems_rtl_bit_alloc balloc,
void *  addr,
size_t  size 
)

Free an allocated memory block. The size is required because the allocator does not contain any state information.

◆ rtems_rtl_bit_alloc_close()

void rtems_rtl_bit_alloc_close ( rtems_rtl_bit_alloc balloc)

Close the bit allocator.

Parameters
ballocThe allocator to close.

◆ rtems_rtl_bit_alloc_open()

rtems_rtl_bit_alloc * rtems_rtl_bit_alloc_open ( void *  base,
size_t  size,
size_t  block_size,
size_t  used 
)

Open a bit allocator. The allocator allocates block_size pieces of the memory being managed.

Parameters
baseThe memory to managem NULL to allocate a piece of memory.
sizeThe size of the memory being managed in bytes.
block_sizeThe minimum allocation unit in bytes.
usedThe amount of memory already in use in bytes.
Return values
rtems_rtl_bit_allocThe bit allocator structure.