hardware.h 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /**
  2. * \file lzma/hardware.h
  3. * \brief Hardware information
  4. *
  5. * Since liblzma can consume a lot of system resources, it also provides
  6. * ways to limit the resource usage. Applications linking against liblzma
  7. * need to do the actual decisions how much resources to let liblzma to use.
  8. * To ease making these decisions, liblzma provides functions to find out
  9. * the relevant capabilities of the underlaying hardware. Currently there
  10. * is only a function to find out the amount of RAM, but in the future there
  11. * will be also a function to detect how many concurrent threads the system
  12. * can run.
  13. *
  14. * \note On some operating systems, these function may temporarily
  15. * load a shared library or open file descriptor(s) to find out
  16. * the requested hardware information. Unless the application
  17. * assumes that specific file descriptors are not touched by
  18. * other threads, this should have no effect on thread safety.
  19. * Possible operations involving file descriptors will restart
  20. * the syscalls if they return EINTR.
  21. */
  22. /*
  23. * Author: Lasse Collin
  24. *
  25. * This file has been put into the public domain.
  26. * You can do whatever you want with this file.
  27. *
  28. * See ../lzma.h for information about liblzma as a whole.
  29. */
  30. #ifndef LZMA_H_INTERNAL
  31. # error Never include this file directly. Use <lzma.h> instead.
  32. #endif
  33. /**
  34. * \brief Get the total amount of physical memory (RAM) in bytes
  35. *
  36. * This function may be useful when determining a reasonable memory
  37. * usage limit for decompressing or how much memory it is OK to use
  38. * for compressing.
  39. *
  40. * \return On success, the total amount of physical memory in bytes
  41. * is returned. If the amount of RAM cannot be determined,
  42. * zero is returned. This can happen if an error occurs
  43. * or if there is no code in liblzma to detect the amount
  44. * of RAM on the specific operating system.
  45. */
  46. extern LZMA_API(uint64_t) lzma_physmem(void) lzma_nothrow;
  47. /**
  48. * \brief Get the number of processor cores or threads
  49. *
  50. * This function may be useful when determining how many threads to use.
  51. * If the hardware supports more than one thread per CPU core, the number
  52. * of hardware threads is returned if that information is available.
  53. *
  54. * \brief On success, the number of available CPU threads or cores is
  55. * returned. If this information isn't available or an error
  56. * occurs, zero is returned.
  57. */
  58. extern LZMA_API(uint32_t) lzma_cputhreads(void) lzma_nothrow;