Skip to content

Commit 16d0ac8

Browse files
committed
Use AM_POOL_BLOCK_SIZEOF and AM_POOL_BLOCK_ALIGNMENT
1 parent 4642600 commit 16d0ac8

File tree

5 files changed

+14
-15
lines changed

5 files changed

+14
-15
lines changed

libs/event/event.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
#include <stdbool.h>
3535

3636
#include "queue/queue.h"
37-
#include "onesize/onesize.h"
3837

3938
#define AM_EVT_INVALID 0
4039
#define AM_EVT_RANGE_HSM_BEGIN 1
@@ -71,9 +70,6 @@
7170
#define AM_EVENT_POOL_INDEX_BITS 5
7271
#define AM_EVENT_POOL_INDEX_MASK ((1U << AM_EVENT_POOL_INDEX_BITS) - 1U)
7372

74-
#define AM_EVENT_BLOCK_SIZE(t) AM_ONESIZE_BLOCK_SIZE(t)
75-
#define AM_EVENT_BLOCK_ALIGNMENT(a) AM_ONESIZE_BLOCK_ALIGNMENT(a)
76-
7773
extern const int am_alignof_event;
7874
extern const int am_alignof_event_ptr;
7975

libs/fsm/tests/event_queue.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
#include "blk/blk.h"
4141
#include "event/event.h"
4242
#include "queue/queue.h"
43+
#include "onesize/onesize.h"
4344
#include "strlib/strlib.h"
4445
#include "pal/pal.h"
4546
#include "fsm/fsm.h"
@@ -142,14 +143,14 @@ int main(void) {
142143
am_event_state_ctor(&cfg);
143144

144145
{
145-
static char pool[1 * AM_EVENT_BLOCK_SIZE(struct am_event)] AM_ALIGNED(
146+
static char pool[1 * AM_POOL_BLOCK_SIZEOF(struct am_event)] AM_ALIGNED(
146147
AM_ALIGN_MAX
147148
);
148149
am_event_add_pool(
149150
pool,
150151
(int)sizeof(pool),
151-
AM_EVENT_BLOCK_SIZE(struct am_event),
152-
AM_EVENT_BLOCK_ALIGNMENT(AM_ALIGNOF_EVENT)
152+
AM_POOL_BLOCK_SIZEOF(struct am_event),
153+
AM_POOL_BLOCK_ALIGNMENT(AM_ALIGNOF_EVENT)
153154
);
154155
AM_ASSERT(1 == am_event_get_pool_nblocks(/*index=*/0));
155156
}

libs/hsm/tests/defer.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#include "common/compiler.h"
3131
#include "common/macros.h"
3232
#include "event/event.h"
33+
#include "onesize/onesize.h"
3334
#include "strlib/strlib.h"
3435
#include "hsm/hsm.h"
3536
#include "common.h"
@@ -154,14 +155,14 @@ static void test_defer(void) {
154155
am_event_state_ctor(&cfg);
155156

156157
{
157-
static char pool[2 * AM_EVENT_BLOCK_SIZE(struct am_event)] AM_ALIGNED(
158+
static char pool[2 * AM_POOL_BLOCK_SIZEOF(struct am_event)] AM_ALIGNED(
158159
AM_ALIGN_MAX
159160
);
160161
am_event_add_pool(
161162
pool,
162163
(int)sizeof(pool),
163-
AM_EVENT_BLOCK_SIZE(struct am_event),
164-
AM_EVENT_BLOCK_ALIGNMENT(AM_ALIGNOF_EVENT)
164+
AM_POOL_BLOCK_SIZEOF(struct am_event),
165+
AM_POOL_BLOCK_ALIGNMENT(AM_ALIGNOF_EVENT)
165166
);
166167
AM_ASSERT(2 == am_event_get_pool_nblocks(/*index=*/0));
167168
}

libs/hsm/tests/event_queue.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
#include "blk/blk.h"
4141
#include "event/event.h"
4242
#include "queue/queue.h"
43+
#include "onesize/onesize.h"
4344
#include "strlib/strlib.h"
4445
#include "pal/pal.h"
4546
#include "hsm/hsm.h"
@@ -141,14 +142,14 @@ int main(void) {
141142
am_event_state_ctor(&cfg);
142143

143144
{
144-
static char pool[1 * AM_EVENT_BLOCK_SIZE(struct am_event)] AM_ALIGNED(
145+
static char pool[1 * AM_POOL_BLOCK_SIZEOF(struct am_event)] AM_ALIGNED(
145146
AM_ALIGN_MAX
146147
);
147148
am_event_add_pool(
148149
pool,
149150
(int)sizeof(pool),
150-
AM_EVENT_BLOCK_SIZE(struct am_event),
151-
AM_EVENT_BLOCK_ALIGNMENT(AM_ALIGNOF_EVENT)
151+
AM_POOL_BLOCK_SIZEOF(struct am_event),
152+
AM_POOL_BLOCK_ALIGNMENT(AM_ALIGNOF_EVENT)
152153
);
153154
AM_ASSERT(1 == am_event_get_pool_nblocks(/*index=*/0));
154155
}

libs/onesize/onesize.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@
3434
#include "blk/blk.h"
3535
#include "slist/slist.h"
3636

37-
#define AM_ONESIZE_BLOCK_SIZE(t) AM_MAX(sizeof(struct am_slist), sizeof(t))
38-
#define AM_ONESIZE_BLOCK_ALIGNMENT(a) AM_MAX(AM_ALIGNOF_SLIST, a)
37+
#define AM_POOL_BLOCK_SIZEOF(t) AM_MAX(sizeof(struct am_slist), sizeof(t))
38+
#define AM_POOL_BLOCK_ALIGNMENT(a) AM_MAX(AM_ALIGNOF_SLIST, a)
3939

4040
#ifdef __cplusplus
4141
extern "C" {

0 commit comments

Comments
 (0)