quick_exit.hpp 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. #ifndef BOOST_CORE_QUICK_EXIT_HPP_INCLUDED
  2. #define BOOST_CORE_QUICK_EXIT_HPP_INCLUDED
  3. // MS compatible compilers support #pragma once
  4. #if defined(_MSC_VER) && (_MSC_VER >= 1020)
  5. # pragma once
  6. #endif
  7. // boost/core/quick_exit.hpp
  8. //
  9. // Copyright 2018 Peter Dimov
  10. //
  11. // Distributed under the Boost Software License, Version 1.0.
  12. // See accompanying file LICENSE_1_0.txt or copy at
  13. // http://www.boost.org/LICENSE_1_0.txt)
  14. #include <boost/config.hpp>
  15. #include <stdlib.h>
  16. #if defined(__MINGW32__) && !defined(__MINGW64_VERSION_MAJOR)
  17. extern "C" _CRTIMP __cdecl __MINGW_NOTHROW void _exit (int) __MINGW_ATTRIB_NORETURN;
  18. #endif
  19. #if defined(__CYGWIN__) && __cplusplus < 201103L
  20. extern "C" _Noreturn void quick_exit(int);
  21. #endif
  22. namespace boost
  23. {
  24. BOOST_NORETURN inline void quick_exit( int code ) BOOST_NOEXCEPT
  25. {
  26. #if defined(_MSC_VER) && _MSC_VER < 1900
  27. ::_exit( code );
  28. #elif defined(__MINGW32__)
  29. ::_exit( code );
  30. #elif defined(__APPLE__)
  31. ::_Exit( code );
  32. #else
  33. ::quick_exit( code );
  34. #endif
  35. }
  36. } // namespace boost
  37. #endif // #ifndef BOOST_CORE_QUICK_EXIT_HPP_INCLUDED