Reactos
at master 31 lines 846 B view raw
1// 2// new_mode.cpp 3// 4// Copyright (c) Microsoft Corporation. All rights reserved. 5// 6// Definition of _set_new_mode and _query_new_mode, which provide access to the 7// _newmode global flag. 8// 9#include <corecrt_internal.h> 10#include <new.h> 11 12 13 14static __crt_state_management::dual_state_global<long> __acrt_global_new_mode; 15 16 17 18// Sets the _newmode flag to the new value 'mode' and return the old mode. 19extern "C" int __cdecl _set_new_mode(int const mode) 20{ 21 // The only valid values of _newmode are 0 and 1: 22 _VALIDATE_RETURN(mode == 0 || mode == 1, EINVAL, -1); 23 24 return static_cast<int>(_InterlockedExchange(&__acrt_global_new_mode.value(), mode)); 25} 26 27// Gets the current value of the _newmode flag. 28extern "C" int __cdecl _query_new_mode() 29{ 30 return static_cast<int>(__crt_interlocked_read(&__acrt_global_new_mode.value())); 31}