[xbuild] Pick the correct base path for target frameworks.
[mono.git] / mono / utils / hazard-pointer.h
1 /*
2  * hazard-pointer.h: Hazard pointer related code.
3  *
4  * (C) Copyright 2011 Novell, Inc
5  */
6 #ifndef __MONO_HAZARD_POINTER_H__
7 #define __MONO_HAZARD_POINTER_H__
8
9 #include <glib.h>
10 #include <mono/utils/mono-compiler.h>
11 #include <mono/utils/mono-membar.h>
12
13 #define HAZARD_POINTER_COUNT 3
14
15 typedef struct {
16         gpointer hazard_pointers [HAZARD_POINTER_COUNT];
17 } MonoThreadHazardPointers;
18
19 typedef void (*MonoHazardousFreeFunc) (gpointer p);
20
21 void mono_thread_hazardous_free_or_queue (gpointer p, MonoHazardousFreeFunc free_func) MONO_INTERNAL;
22 void mono_thread_hazardous_try_free_all (void) MONO_INTERNAL;
23 MonoThreadHazardPointers* mono_hazard_pointer_get (void) MONO_INTERNAL;
24 gpointer get_hazardous_pointer (gpointer volatile *pp, MonoThreadHazardPointers *hp, int hazard_index) MONO_INTERNAL;
25
26 #define mono_hazard_pointer_set(hp,i,v) \
27         do { g_assert ((i) >= 0 && (i) < HAZARD_POINTER_COUNT); \
28                 (hp)->hazard_pointers [(i)] = (v); \
29                 mono_memory_write_barrier (); \
30         } while (0)
31
32 #define mono_hazard_pointer_get_val(hp,i)       \
33         ((hp)->hazard_pointers [(i)])
34
35 #define mono_hazard_pointer_clear(hp,i) \
36         do { g_assert ((i) >= 0 && (i) < HAZARD_POINTER_COUNT); \
37                 (hp)->hazard_pointers [(i)] = NULL; \
38         } while (0)
39
40
41 void mono_thread_small_id_free (int id) MONO_INTERNAL;
42 int mono_thread_small_id_alloc (void) MONO_INTERNAL;
43
44 void mono_thread_smr_init (void) MONO_INTERNAL;
45 void mono_thread_smr_cleanup (void) MONO_INTERNAL;
46 #endif /*__MONO_HAZARD_POINTER_H__*/