FreeRTOS-Kernel/portable/Heap/cluster_group.h
Sven Bieg 0a61cf54e7 Implemented heap_6 for C++ real-time applications
I tried to adjust my heap to FreeRTOS. This is my very first commit to FreeRTOS, i don't even know how to compile the kernel.
Maybe You get it running and let me know what You think about it.

https://forums.freertos.org/t/real-time-memory-manager/19685
2024-04-13 21:35:03 +02:00

120 lines
2.1 KiB
C

//=================
// cluster_group.h
//=================
// Header of groups used for sorting.
// Memory-access needs to be 32 bit in IRAM.
// Copyright 2024, Sven Bieg (svenbieg@web.de)
// http://github.com/svenbieg/Heap
#ifndef _CLUSTER_GROUP_H
#define _CLUSTER_GROUP_H
//=======
// Using
//=======
#include "heap_internal.h"
//=======
// Group
//=======
typedef struct
{
union
{
struct
{
uint32_t dirty: 1;
uint32_t locked: 1;
uint32_t level: 14;
uint32_t child_count: 16;
};
uint32_t value;
};
}cluster_group_t;
//==================
// Con-/Destructors
//==================
static inline void cluster_group_init(cluster_group_t* group, uint16_t level, uint16_t child_count)
{
cluster_group_t set={ 0 };
set.level=level;
set.child_count=child_count;
group->value=set.value;
}
//========
// Access
//========
static inline uint16_t cluster_group_get_child_count(cluster_group_t* group)
{
cluster_group_t get;
get.value=group->value;
return get.child_count;
}
size_t cluster_group_get_item_count(cluster_group_t* group);
static inline uint16_t cluster_group_get_level(cluster_group_t* group)
{
cluster_group_t get;
get.value=group->value;
return get.level;
}
static inline bool cluster_group_is_dirty(cluster_group_t* group)
{
cluster_group_t get;
get.value=group->value;
return get.dirty;
}
static inline bool cluster_group_is_locked(cluster_group_t* group)
{
cluster_group_t get;
get.value=group->value;
return get.locked;
}
//==============
// Modification
//==============
static inline void cluster_group_set_child_count(cluster_group_t* group, uint16_t child_count)
{
cluster_group_t set;
set.value=group->value;
set.child_count=child_count;
group->value=set.value;
}
static inline void cluster_group_set_dirty(cluster_group_t* group, bool dirty)
{
cluster_group_t set;
set.value=group->value;
set.dirty=dirty;
group->value=set.value;
}
static inline void cluster_group_set_locked(cluster_group_t* group, bool lock)
{
cluster_group_t set;
set.value=group->value;
assert(set.locked!=lock);
set.locked=lock;
group->value=set.value;
}
#endif // _CLUSTER_GROUP_H