winProcessControl.cpp 2.3 KB

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