| 1 |
// Copyright (c) Microsoft. All rights reserved. |
| 2 |
// Licensed under the MIT license. See LICENSE file in the project root for full license information. |
| 3 |
|
| 4 |
// This file gets included into refcount.h as a means of extending the behavior of |
| 5 |
// atomic increment, decrement, and test. |
| 6 |
|
| 7 |
// The first phase defines COUNT_TYPE |
| 8 |
#ifndef REFCOUNT_OS_H__WINDOWS |
| 9 |
#define REFCOUNT_OS_H__WINDOWS |
| 10 |
|
| 11 |
#include "windows.h" |
| 12 |
// The Windows atomic operations work on LONG |
| 13 |
#define COUNT_TYPE LONG |
| 14 |
|
| 15 |
/*if macro DEC_REF returns DEC_RETURN_ZERO that means the ref count has reached zero.*/ |
| 16 |
#define DEC_RETURN_ZERO (0) |
| 17 |
#define INC_REF_VAR(count) InterlockedIncrement(&(count)) |
| 18 |
#define DEC_REF_VAR(count) InterlockedDecrement(&(count)) |
| 19 |
#define INIT_REF_VAR(count) InterlockedExchange(&(count), 1) |
| 20 |
|
| 21 |
#endif // REFCOUNT_OS_H__WINDOWS |