2 * Copyright (c) 2008, Your File System, Inc.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
8 * 1. Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. Neither the name of the company nor the names of its contributors may
14 * be used to endorse or promote products derived from this software
15 * without specific prior written permission.
17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 #ifndef _RX_INTERNAL_H_
31 #define _RX_INTERNAL_H_
37 #pragma intrinsic(_InterlockedOr)
38 #pragma intrinsic(_InterlockedAnd)
39 #define rx_MutexOr(object, operand, mutex) _InterlockedOr(&object, operand)
40 #define rx_MutexAnd(object, operand, mutex) _InterlockedAnd(&object, operand)
43 #define rx_MutexOr(object, operand, mutex) InterlockedOr(&object, operand)
44 #define rx_MutexAnd(object, operand, mutex) InterlockedAnd(&object, operand)
46 #define rx_MutexIncrement(object, mutex) InterlockedIncrement(&object)
47 #define rx_MutexXor(object, operand, mutex) InterlockedXor(&object, operand)
48 #define rx_MutexAdd(object, addend, mutex) InterlockedExchangeAdd(&object, addend)
49 #define rx_MutexDecrement(object, mutex) InterlockedDecrement(&object)
50 #define rx_MutexAdd1Increment2(object1, addend, object2, mutex) \
52 MUTEX_ENTER(&mutex); \
54 InterlockedIncrement(&object2); \
57 #define rx_MutexAdd1Decrement2(object1, addend, object2, mutex) \
59 MUTEX_ENTER(&mutex); \
61 InterlockedDecrement(&object2); \
65 #define rx_MutexIncrement(object, mutex) \
67 MUTEX_ENTER(&mutex); \
71 #define rx_MutexOr(object, operand, mutex) \
73 MUTEX_ENTER(&mutex); \
77 #define rx_MutexAnd(object, operand, mutex) \
79 MUTEX_ENTER(&mutex); \
83 #define rx_MutexXor(object, operand, mutex) \
85 MUTEX_ENTER(&mutex); \
89 #define rx_MutexAdd(object, addend, mutex) \
91 MUTEX_ENTER(&mutex); \
95 #define rx_MutexAdd1Increment2(object1, addend, object2, mutex) \
97 MUTEX_ENTER(&mutex); \
100 MUTEX_EXIT(&mutex); \
102 #define rx_MutexAdd1Decrement2(object1, addend, object2, mutex) \
104 MUTEX_ENTER(&mutex); \
107 MUTEX_EXIT(&mutex); \
109 #define rx_MutexDecrement(object, mutex) \
111 MUTEX_ENTER(&mutex); \
113 MUTEX_EXIT(&mutex); \
117 #endif /* _RX_INTERNAL_H */