| 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 prot, int flags, int fd, off_t offset); |
| 19 | int rseq_percpu_pool_destroy(struct rseq_percpu_pool *pool); |
| 20 | |
| 21 | void *rseq_percpu_malloc(struct rseq_percpu_pool *pool); |
| 22 | void *rseq_percpu_zmalloc(struct rseq_percpu_pool *pool); |
| 23 | void rseq_percpu_free(void *ptr); |
| 24 | |
| 25 | void *__rseq_percpu_ptr(void *ptr, int cpu); |
| 26 | |
| 27 | #define rseq_percpu_ptr(ptr, cpu) ((__typeof__(ptr)) __rseq_percpu_ptr(ptr, cpu)) |
| 28 | |
| 29 | struct rseq_percpu_pool_set *rseq_percpu_pool_set_create(void); |
| 30 | int rseq_percpu_pool_set_destroy(struct rseq_percpu_pool_set *pool_set); |
| 31 | int rseq_percpu_pool_set_add_pool(struct rseq_percpu_pool_set *pool_set, |
| 32 | struct rseq_percpu_pool *pool); |
| 33 | |
| 34 | void *rseq_percpu_pool_set_malloc(struct rseq_percpu_pool_set *pool_set, size_t len); |
| 35 | void *rseq_percpu_pool_set_zmalloc(struct rseq_percpu_pool_set *pool_set, size_t len); |
| 36 | |
| 37 | #endif /* _RSEQ_PERCPU_ALLOC_H */ |