System.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. // Copyright (C) 2009-present, Panagiotis Christopoulos Charitos and contributors.
  2. // All rights reserved.
  3. // Code licensed under the BSD License.
  4. // http://www.anki3d.org/LICENSE
  5. #pragma once
  6. #include <AnKi/Util/StdTypes.h>
  7. #include <AnKi/Util/Function.h>
  8. #include <AnKi/Util/String.h>
  9. #include <ctime>
  10. namespace anki {
  11. /// @addtogroup util_system
  12. /// @{
  13. /// Get the number of CPU cores
  14. ANKI_PURE U32 getCpuCoresCount();
  15. /// @internal
  16. void backtraceInternal(const Function<void(CString)>& lambda);
  17. /// Get a backtrace.
  18. template<typename TFunc>
  19. void backtrace(TFunc func)
  20. {
  21. Function<void(CString)> f(func);
  22. backtraceInternal(f);
  23. }
  24. /// Return true if the engine is running from a terminal emulator.
  25. Bool runningFromATerminal();
  26. /// Return the local time in a thread safe way.
  27. std::tm getLocalTime();
  28. #if ANKI_OS_ANDROID
  29. /// This function reads what is passed to "am" and interprets them as command line arguments. Should be called by
  30. /// android_main(). It's not thread safe. Don't call it more than once.
  31. /// Executing an apk using:
  32. /// @code
  33. /// adb shell am start XXX -e cmd "arg0 arg1 arg2"
  34. /// @endcode
  35. /// Whatever follows "cmd" will be a command line argument.
  36. [[nodiscard]] void* getAndroidCommandLineArguments(int& argc, char**& argv);
  37. /// Takes the return value of getAndroidCommandLineArguments() for cleanup.
  38. void cleanupGetAndroidCommandLineArguments(void* ptr);
  39. #endif
  40. /// Some common code to be called before main.
  41. void preMainInit();
  42. #if ANKI_OS_WINDOWS
  43. /// Convert windows errors (from GetLastError) to strings.
  44. String errorMessageToString(DWORD errorMessageID);
  45. #endif
  46. /// @}
  47. } // end namespace anki