ALSA: hda - Adding one more ALC255 pin definition for headset problem
[linux/fpc-iii.git] / tools / testing / radix-tree / linux.c
blob154823737b20d35f90d0b2e8e4b60f99795d81e0
1 #include <stdlib.h>
2 #include <string.h>
3 #include <malloc.h>
4 #include <unistd.h>
5 #include <assert.h>
7 #include <linux/mempool.h>
8 #include <linux/slab.h>
9 #include <urcu/uatomic.h>
11 int nr_allocated;
13 void *mempool_alloc(mempool_t *pool, int gfp_mask)
15 return pool->alloc(gfp_mask, pool->data);
18 void mempool_free(void *element, mempool_t *pool)
20 pool->free(element, pool->data);
23 mempool_t *mempool_create(int min_nr, mempool_alloc_t *alloc_fn,
24 mempool_free_t *free_fn, void *pool_data)
26 mempool_t *ret = malloc(sizeof(*ret));
28 ret->alloc = alloc_fn;
29 ret->free = free_fn;
30 ret->data = pool_data;
31 return ret;
34 void *kmem_cache_alloc(struct kmem_cache *cachep, int flags)
36 void *ret = malloc(cachep->size);
37 if (cachep->ctor)
38 cachep->ctor(ret);
39 uatomic_inc(&nr_allocated);
40 return ret;
43 void kmem_cache_free(struct kmem_cache *cachep, void *objp)
45 assert(objp);
46 uatomic_dec(&nr_allocated);
47 memset(objp, 0, cachep->size);
48 free(objp);
51 struct kmem_cache *
52 kmem_cache_create(const char *name, size_t size, size_t offset,
53 unsigned long flags, void (*ctor)(void *))
55 struct kmem_cache *ret = malloc(sizeof(*ret));
57 ret->size = size;
58 ret->ctor = ctor;
59 return ret;