Browse Source

MT#55283 move alignment macros to header file

Change-Id: I266cbefe8351f77399bb6e50b2122f9a45249529
pull/1923/head
Richard Fuchs 9 months ago
parent
commit
5f9e43b3e0
2 changed files with 4 additions and 3 deletions
  1. +1
    -3
      lib/bufferpool.c
  2. +3
    -0
      lib/bufferpool.h

+ 1
- 3
lib/bufferpool.c View File

@ -3,8 +3,6 @@
#include <stdbool.h>
#include "obj.h"
#define ALIGN 8 // bytes
struct bufferpool {
void *(*alloc)(size_t);
void (*dealloc)(void *);
@ -154,7 +152,7 @@ void *bufferpool_alloc(struct bufferpool *bp, size_t len) {
void *ret = shard->head;
shard->refs++;
shard->head += ((len + ALIGN - 1) / ALIGN) * ALIGN;
shard->head += BUFFERPOOL_ALIGN(len);
return ret;
}


+ 3
- 0
lib/bufferpool.h View File

@ -3,6 +3,9 @@
#include "obj.h"
#define BUFFERPOOL_ALIGNMENT (sizeof(void *)) // bytes
#define BUFFERPOOL_ALIGN(x) (((x + BUFFERPOOL_ALIGNMENT - 1) / BUFFERPOOL_ALIGNMENT) * BUFFERPOOL_ALIGNMENT)
struct bufferpool;
struct bpool_shard;


Loading…
Cancel
Save