jpayne@69: /* SPDX-License-Identifier: 0BSD */ jpayne@69: jpayne@69: /** jpayne@69: * \file lzma/hardware.h jpayne@69: * \brief Hardware information jpayne@69: * \note Never include this file directly. Use instead. jpayne@69: * jpayne@69: * Since liblzma can consume a lot of system resources, it also provides jpayne@69: * ways to limit the resource usage. Applications linking against liblzma jpayne@69: * need to do the actual decisions how much resources to let liblzma to use. jpayne@69: * To ease making these decisions, liblzma provides functions to find out jpayne@69: * the relevant capabilities of the underlying hardware. Currently there jpayne@69: * is only a function to find out the amount of RAM, but in the future there jpayne@69: * will be also a function to detect how many concurrent threads the system jpayne@69: * can run. jpayne@69: * jpayne@69: * \note On some operating systems, these function may temporarily jpayne@69: * load a shared library or open file descriptor(s) to find out jpayne@69: * the requested hardware information. Unless the application jpayne@69: * assumes that specific file descriptors are not touched by jpayne@69: * other threads, this should have no effect on thread safety. jpayne@69: * Possible operations involving file descriptors will restart jpayne@69: * the syscalls if they return EINTR. jpayne@69: */ jpayne@69: jpayne@69: /* jpayne@69: * Author: Lasse Collin jpayne@69: */ jpayne@69: jpayne@69: #ifndef LZMA_H_INTERNAL jpayne@69: # error Never include this file directly. Use instead. jpayne@69: #endif jpayne@69: jpayne@69: jpayne@69: /** jpayne@69: * \brief Get the total amount of physical memory (RAM) in bytes jpayne@69: * jpayne@69: * This function may be useful when determining a reasonable memory jpayne@69: * usage limit for decompressing or how much memory it is OK to use jpayne@69: * for compressing. jpayne@69: * jpayne@69: * \return On success, the total amount of physical memory in bytes jpayne@69: * is returned. If the amount of RAM cannot be determined, jpayne@69: * zero is returned. This can happen if an error occurs jpayne@69: * or if there is no code in liblzma to detect the amount jpayne@69: * of RAM on the specific operating system. jpayne@69: */ jpayne@69: extern LZMA_API(uint64_t) lzma_physmem(void) lzma_nothrow; jpayne@69: jpayne@69: jpayne@69: /** jpayne@69: * \brief Get the number of processor cores or threads jpayne@69: * jpayne@69: * This function may be useful when determining how many threads to use. jpayne@69: * If the hardware supports more than one thread per CPU core, the number jpayne@69: * of hardware threads is returned if that information is available. jpayne@69: * jpayne@69: * \return On success, the number of available CPU threads or cores is jpayne@69: * returned. If this information isn't available or an error jpayne@69: * occurs, zero is returned. jpayne@69: */ jpayne@69: extern LZMA_API(uint32_t) lzma_cputhreads(void) lzma_nothrow;