Xin Zhang / azure-iot-c-sdk-f767zi

Dependents:   samplemqtt

c-utility/pal/generic/refcount_os.h

Committer:
XinZhangMS
Date:
2018-08-23
Revision:
0:f7f1f0d76dd6

File content as of revision 0:f7f1f0d76dd6:

// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

// This file gets included into refcount.h as a means of extending the behavior of
// atomic increment, decrement, and test. 
//
// The Azure IoT C SDK does not require thread-safe refcount operations, so 
// this file is appropriate for any device when using the Azure IoT C SDK.

#ifndef REFCOUNT_OS_H__GENERIC
#define REFCOUNT_OS_H__GENERIC

#define COUNT_TYPE uint32_t

#define DEC_RETURN_ZERO (0)
#define INC_REF(type, var) ++((((REFCOUNT_TYPE(type)*)var)->count))
#define DEC_REF(type, var) --((((REFCOUNT_TYPE(type)*)var)->count))
#define INIT_REF(type, var) do { ((REFCOUNT_TYPE(type)*)var)->count = 1; } while((void)0,0)

#endif // REFCOUNT_OS_H__GENERIC