os.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /*
  2. * Copyright 2010-2025 Branimir Karadzic. All rights reserved.
  3. * License: https://github.com/bkaradzic/bx/blob/master/LICENSE
  4. */
  5. #ifndef BX_OS_H_HEADER_GUARD
  6. #define BX_OS_H_HEADER_GUARD
  7. #include "filepath.h"
  8. #if BX_PLATFORM_OSX
  9. # define BX_DL_EXT "dylib"
  10. #elif BX_PLATFORM_WINDOWS
  11. # define BX_DL_EXT "dll"
  12. #else
  13. # define BX_DL_EXT "so"
  14. #endif //
  15. BX_ERROR_RESULT(kErrorMemoryMapFailed, BX_MAKEFOURCC('b', 'x', '8', '0') );
  16. BX_ERROR_RESULT(kErrorMemoryUnmapFailed, BX_MAKEFOURCC('b', 'x', '8', '1') );
  17. namespace bx
  18. {
  19. ///
  20. void sleep(uint32_t _ms);
  21. ///
  22. void yield();
  23. ///
  24. uint32_t getTid();
  25. ///
  26. size_t getProcessMemoryUsed();
  27. ///
  28. void* dlopen(const FilePath& _filePath);
  29. ///
  30. void dlclose(void* _handle);
  31. ///
  32. void* dlsym(void* _handle, const StringView& _symbol);
  33. ///
  34. template<typename ProtoT>
  35. ProtoT dlsym(void* _handle, const StringView& _symbol);
  36. ///
  37. bool getEnv(char* _out, uint32_t* _inOutSize, const StringView& _name);
  38. ///
  39. void setEnv(const StringView& _name, const StringView& _value);
  40. ///
  41. int chdir(const char* _path);
  42. ///
  43. void* exec(const char* const* _argv);
  44. ///
  45. [[noreturn]] void exit(int32_t _exitCode);
  46. ///
  47. void* memoryMap(void* _address, size_t _size, Error* _err);
  48. ///
  49. void memoryUnmap(void* _address, size_t _size, Error* _err);
  50. ///
  51. size_t memoryPageSize();
  52. } // namespace bx
  53. #include "inline/os.inl"
  54. #endif // BX_OS_H_HEADER_GUARD