System.h 1.4 KB

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