/*---------------------------------------------------------------------------* Project: Horizon File: os_WaitableCounter.cpp Copyright (C)2009 Nintendo Co., Ltd. All rights reserved. These coded instructions, statements, and computer programs contain proprietary information of Nintendo of America Inc. and/or Nintendo Company Ltd., and are protected by Federal copyright law. They may not be disclosed to third parties or copied or duplicated in any form, in whole or in part, without the prior written consent of Nintendo. $Rev: 12372 $ *---------------------------------------------------------------------------*/ #include #include namespace nn { namespace os { // 明示的に INVALID_HANDLE_VALUE で初期化すると // static_initializer での初期化になるので bss クリアに頼る nnHandle WaitableCounter::s_Handle = {0}; void WaitableCounter::Initialize() { if( s_Handle.value == INVALID_HANDLE_VALUE.value ) { Handle h; Result ret = nn::svc::CreateAddressArbiter(&h); NN_TASSERT_( ret.IsSuccess() ); if( ret.IsSuccess() ) { s_Handle = h; } } } void WaitableCounter::Finalize() { if( s_Handle.value != INVALID_HANDLE_VALUE.value ) { Result ret = nn::svc::CloseHandle(s_Handle); NN_TASSERT_( ret.IsSuccess() ); if( ret.IsSuccess() ) { s_Handle.value = INVALID_HANDLE_VALUE.value; } } } }}