winProcessControl.cpp
Engine/source/platformWin32/winProcessControl.cpp
Detailed Description
1 2//----------------------------------------------------------------------------- 3// Copyright (c) 2012 GarageGames, LLC 4// 5// Permission is hereby granted, free of charge, to any person obtaining a copy 6// of this software and associated documentation files (the "Software"), to 7// deal in the Software without restriction, including without limitation the 8// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 9// sell copies of the Software, and to permit persons to whom the Software is 10// furnished to do so, subject to the following conditions: 11// 12// The above copyright notice and this permission notice shall be included in 13// all copies or substantial portions of the Software. 14// 15// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 21// IN THE SOFTWARE. 22//----------------------------------------------------------------------------- 23 24#include "platformWin32/platformWin32.h" 25#include "core/strings/stringFunctions.h" 26#include "core/util/journal/process.h" 27 28void Platform::postQuitMessage(const S32 in_quitVal) 29{ 30 if (!Platform::getWebDeployment()) 31 Process::requestShutdown(); 32} 33 34void Platform::debugBreak() 35{ 36 DebugBreak(); 37} 38 39void Platform::forceShutdown(S32 returnValue) 40{ 41 // Don't do an ExitProcess here or you'll wreak havoc in a multithreaded 42 // environment. 43 44 exit( returnValue ); 45} 46 47void Platform::outputDebugString( const char *string, ... ) 48{ 49 // Expand string. 50 51 char buffer[ 2048 ]; 52 53 va_list args; 54 va_start( args, string ); 55 56 dVsprintf( buffer, sizeof( buffer ), string, args ); 57 va_end( args ); 58 59 // Append a newline to buffer. This is better than calling OutputDebugStringA 60 // twice as in a multi-threaded environment, some other thread may output some 61 // stuff in between the two calls. 62 63 U32 length = strlen( buffer ); 64 if( length == ( sizeof( buffer ) - 1 ) ) 65 length --; 66 67 buffer[ length ] = '\n'; 68 buffer[ length + 1 ] = '\0'; 69 70 OutputDebugStringA( buffer ); 71} 72 73