-
-
Notifications
You must be signed in to change notification settings - Fork 182
Expand file tree
/
Copy pathBitwise.h
More file actions
70 lines (52 loc) · 1.47 KB
/
Copy pathBitwise.h
File metadata and controls
70 lines (52 loc) · 1.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
/*
* Copyright (c) scott.cgi All Rights Reserved.
*
* This source code belongs to project Mojoc, which is a pure C Game Engine hosted on GitHub.
* The Mojoc Game Engine is licensed under the MIT License, and will continue to be iterated with coding passion.
*
* License : https://github.com/scottcgi/Mojoc/blob/master/LICENSE
* GitHub : https://github.com/scottcgi/Mojoc
* CodeStyle: https://github.com/scottcgi/Mojoc/blob/master/Docs/CodeStyle.md
*
* Since : 2013-3-14
* Update : 2019-1-8
* Author : scott.cgi
*/
#ifndef BITWISE_H
#define BITWISE_H
/*
The biteState is usually an expression,
but the inline function cannot use expression for bitState,
so if not use macro we need pass the third parameter that is the bitState owner.
*/
/**
* Add bits into biteState.
*/
#define ABitwise_Add(bitState, bits) \
((bitState) |= (bits))
/**
* Set biteState bits.
*/
#define ABitwise_Set(bitState, bits) \
((bitState) = (bits))
/**
* Clear bits from bitState.
*/
#define ABitwise_Clear(bitState, bits) \
((bitState) &= ~(bits))
/**
* Check biteState whether has bites.
*/
#define ABitwise_Check(bitState, bits) \
(((bitState) & (bits)) != 0)
/**
* Clear clearBits from bitState, and add addBits into biteState.
*/
#define ABitwise_ClearAndAdd(bitState, clearBits, addBits) \
((bitState) = ((bitState) & ~(clearBits)) | (addBits))
/**
* Reset bitState to 0.
*/
#define ABitwise_ClearAll(bitState) \
((bitState) = 0)
#endif