]> pd.if.org Git - nbds/blob - include/hazard.h
add hazard pointer implementation. buggy
[nbds] / include / hazard.h
1 /* 
2  * Written by Josh Dybnis and released to the public domain, as explained at
3  * http://creativecommons.org/licenses/publicdomain
4  *
5  * hazard pointers
6  *
7  * www.research.ibm.com/people/m/michael/ieeetpds-2004.pdf
8  *
9  */
10 #ifndef HAZARD_H
11 #define HAZARD_H
12
13 #define STATIC_HAZ_PER_THREAD 2
14
15 typedef void (*free_t) (void *);
16 typedef void *haz_t;
17
18 static inline void haz_set (haz_t *haz, void *x) { *haz = x; __asm__ __volatile__("mfence"); }
19
20 haz_t *haz_get_static         (int n);
21 void   haz_register_dynamic   (haz_t *haz);
22 void   haz_unregister_dynamic (haz_t *haz);
23 void   haz_defer_free         (void *p, free_t f);
24
25 #endif