Path: blob/master/Utilities/cmliblzma/liblzma/api/lzma/hardware.h
3158 views
/* SPDX-License-Identifier: 0BSD */12/**3* \file lzma/hardware.h4* \brief Hardware information5* \note Never include this file directly. Use <lzma.h> instead.6*7* Since liblzma can consume a lot of system resources, it also provides8* ways to limit the resource usage. Applications linking against liblzma9* need to do the actual decisions how much resources to let liblzma to use.10* To ease making these decisions, liblzma provides functions to find out11* the relevant capabilities of the underlying hardware. Currently there12* is only a function to find out the amount of RAM, but in the future there13* will be also a function to detect how many concurrent threads the system14* can run.15*16* \note On some operating systems, these function may temporarily17* load a shared library or open file descriptor(s) to find out18* the requested hardware information. Unless the application19* assumes that specific file descriptors are not touched by20* other threads, this should have no effect on thread safety.21* Possible operations involving file descriptors will restart22* the syscalls if they return EINTR.23*/2425/*26* Author: Lasse Collin27*/2829#ifndef LZMA_H_INTERNAL30# error Never include this file directly. Use <lzma.h> instead.31#endif323334/**35* \brief Get the total amount of physical memory (RAM) in bytes36*37* This function may be useful when determining a reasonable memory38* usage limit for decompressing or how much memory it is OK to use39* for compressing.40*41* \return On success, the total amount of physical memory in bytes42* is returned. If the amount of RAM cannot be determined,43* zero is returned. This can happen if an error occurs44* or if there is no code in liblzma to detect the amount45* of RAM on the specific operating system.46*/47extern LZMA_API(uint64_t) lzma_physmem(void) lzma_nothrow;484950/**51* \brief Get the number of processor cores or threads52*53* This function may be useful when determining how many threads to use.54* If the hardware supports more than one thread per CPU core, the number55* of hardware threads is returned if that information is available.56*57* \return On success, the number of available CPU threads or cores is58* returned. If this information isn't available or an error59* occurs, zero is returned.60*/61extern LZMA_API(uint32_t) lzma_cputhreads(void) lzma_nothrow;626364