Merge pull request #5714 from alexischr/update_bockbuild
[mono.git] / mono / sgen / sgen-tagged-pointer.h
1 /**
2  * \file
3  * Macros for tagging and untagging pointers.
4  *
5  * Copyright (C) 2014 Xamarin Inc
6  *
7  * Licensed under the MIT license. See LICENSE file in the project root for full license information.
8  */
9
10 #ifndef __MONO_SGEN_TAGGED_POINTER_H__
11 #define __MONO_SGEN_TAGGED_POINTER_H__
12
13 #define SGEN_TAGGED_POINTER_MASK        7
14
15 #define SGEN_POINTER_IS_TAGGED_1(p)     ((mword)(p) & 1)
16 #define SGEN_POINTER_TAG_1(p)           ((void*)((mword)(p) | 1))
17 #define SGEN_POINTER_UNTAG_1(p)         ((void*)((mword)(p) & ~1))
18
19 #define SGEN_POINTER_IS_TAGGED_2(p)     ((mword)(p) & 2)
20 #define SGEN_POINTER_TAG_2(p)           ((void*)((mword)(p) | 2))
21 #define SGEN_POINTER_UNTAG_2(p)         ((void*)((mword)(p) & ~2))
22
23 #define SGEN_POINTER_TAG_12(p)          ((mword)(p) & 3)
24 #define SGEN_POINTER_SET_TAG_12(p,t)    ((void*)(((mword)(p) & ~3) | (t)))
25
26 #define SGEN_POINTER_IS_TAGGED_4(p)     ((mword)(p) & 4)
27 #define SGEN_POINTER_TAG_4(p)           ((void*)((mword)(p) | 4))
28 #define SGEN_POINTER_UNTAG_4(p)         ((void*)((mword)(p) & ~4))
29
30 #define SGEN_POINTER_UNTAG_12(p)        ((void*)((mword)(p) & ~3))
31 #define SGEN_POINTER_UNTAG_24(p)        ((void*)((mword)(p) & ~6))
32
33 #define SGEN_POINTER_IS_TAGGED_ANY(p)   ((mword)(p) & SGEN_TAGGED_POINTER_MASK)
34 #define SGEN_POINTER_UNTAG_ALL(p)       ((void*)((mword)(p) & ~SGEN_TAGGED_POINTER_MASK))
35
36 #endif