96396203672e73b59dfb17a8931e22e8e298e64d
[openafs.git] / src / mcas / osi_mcas_obj_cache.c
1 #include "osi_mcas_obj_cache.h"
2 #include <afs/afsutil.h>
3
4 void
5 osi_mcas_obj_cache_create(osi_mcas_obj_cache_t * gc_id, size_t size)
6 {
7     ViceLog(7,
8             ("osi_mcas_obj_cache_create: size, adjsize %d\n", size,
9              size + sizeof(int *)));
10
11     *(int *)gc_id = gc_add_allocator(size + sizeof(int *));
12 }
13
14 void gc_trace(int alloc_id);
15 int gc_get_blocksize(int alloc_id);
16
17 void *
18 osi_mcas_obj_cache_alloc(osi_mcas_obj_cache_t gc_id)
19 {
20     ptst_t *ptst;
21     void *obj;
22
23 #if MCAS_ALLOC_DISABLED
24 #warning XXXXX mcas allocator cache is DISABLED for debugging!!
25     obj = malloc(gc_get_blocksize(gc_id));
26 #else
27     ptst = critical_enter();
28     obj = (void *)gc_alloc(ptst, gc_id);
29     critical_exit(ptst);
30 #endif
31     return (obj);
32 }
33
34 void
35 osi_mcas_obj_cache_free(osi_mcas_obj_cache_t gc_id, void *obj)
36 {
37     ptst_t *ptst;
38
39 #if MCAS_ALLOC_DISABLED
40 #warning XXXXX mcas allocator cache is DISABLED for debugging!!
41 #else
42     ptst = critical_enter();
43     gc_free(ptst, (void *)obj, gc_id);
44     critical_exit(ptst);
45 #endif
46 }
47
48 void
49 osi_mcas_obj_cache_destroy(osi_mcas_obj_cache_t gc_id)
50 {
51     /* TODO:  implement, will need to implement gc_remove_allocator and related
52      * modifications in gc.c */
53     return;
54 }