System.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. // Copyright (C) 2009-2021, 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. {
  12. /// @addtogroup util_system
  13. /// @{
  14. /// Get the number of CPU cores
  15. U32 getCpuCoresCount();
  16. /// @internal
  17. void backtraceInternal(const Function<void(CString)>& lambda);
  18. /// Get a backtrace.
  19. template<typename TFunc>
  20. void backtrace(GenericMemoryPoolAllocator<U8> alloc, TFunc func)
  21. {
  22. Function<void(CString)> f(alloc, func);
  23. backtraceInternal(f);
  24. f.destroy(alloc);
  25. }
  26. /// Return true if the engine is running from a terminal emulator.
  27. Bool runningFromATerminal();
  28. /// Return the local time in a thread safe way.
  29. std::tm getLocalTime();
  30. #if ANKI_OS_ANDROID
  31. /// This function reads what is passed to "am" and interprets them as command line arguments. Should be called by
  32. /// android_main(). It's not thread safe. Don't call it more than once.
  33. /// Executing an apk using:
  34. /// @code
  35. /// adb shell am start XXX -e cmd "arg0 arg1 arg2"
  36. /// @endcode
  37. /// Whatever follows "cmd" will be a command line argument.
  38. ANKI_USE_RESULT void* getAndroidCommandLineArguments(int& argc, char**& argv);
  39. /// Takes the return value of getAndroidCommandLineArguments() for cleanup.
  40. void cleanupGetAndroidCommandLineArguments(void* ptr);
  41. #endif
  42. /// @}
  43. } // end namespace anki