| 1 | /* SPDX-License-Identifier: MIT */ |
| 2 | /* SPDX-FileCopyrightText: 2024 Mathieu Desnoyers <mathieu.desnoyers@efficios.com> */ |
| 3 | |
| 4 | #ifndef _RSEQ_PERCPU_ALLOC_H |
| 5 | #define _RSEQ_PERCPU_ALLOC_H |
| 6 | |
| 7 | #include <stddef.h> |
| 8 | #include <sys/types.h> |
| 9 | |
| 10 | /* |
| 11 | * rseq/percpu-alloc.h |
| 12 | */ |
| 13 | |
| 14 | struct rseq_percpu_pool; |
| 15 | |
| 16 | struct rseq_percpu_pool *rseq_percpu_pool_create(size_t item_len, |
| 17 | size_t percpu_len, int max_nr_cpus, |
| 18 | int mmap_prot, int mmap_flags, int mmap_fd, off_t mmap_offset, |
| 19 | int numa_flags); |
| 20 | int rseq_percpu_pool_destroy(struct rseq_percpu_pool *pool); |
| 21 | |
| 22 | void *rseq_percpu_malloc(struct rseq_percpu_pool *pool); |
| 23 | void *rseq_percpu_zmalloc(struct rseq_percpu_pool *pool); |
| 24 | void rseq_percpu_free(void *ptr); |
| 25 | |
| 26 | void *__rseq_percpu_ptr(void *ptr, int cpu); |
| 27 | |
| 28 | #define rseq_percpu_ptr(ptr, cpu) ((__typeof__(ptr)) __rseq_percpu_ptr(ptr, cpu)) |
| 29 | |
| 30 | struct rseq_percpu_pool_set *rseq_percpu_pool_set_create(void); |
| 31 | int rseq_percpu_pool_set_destroy(struct rseq_percpu_pool_set *pool_set); |
| 32 | int rseq_percpu_pool_set_add_pool(struct rseq_percpu_pool_set *pool_set, |
| 33 | struct rseq_percpu_pool *pool); |
| 34 | |
| 35 | void *rseq_percpu_pool_set_malloc(struct rseq_percpu_pool_set *pool_set, size_t len); |
| 36 | void *rseq_percpu_pool_set_zmalloc(struct rseq_percpu_pool_set *pool_set, size_t len); |
| 37 | |
| 38 | #endif /* _RSEQ_PERCPU_ALLOC_H */ |