15a645f22SBen Gras /** 25a645f22SBen Gras * \file lzma/hardware.h 35a645f22SBen Gras * \brief Hardware information 45a645f22SBen Gras * 55a645f22SBen Gras * Since liblzma can consume a lot of system resources, it also provides 65a645f22SBen Gras * ways to limit the resource usage. Applications linking against liblzma 75a645f22SBen Gras * need to do the actual decisions how much resources to let liblzma to use. 85a645f22SBen Gras * To ease making these decisions, liblzma provides functions to find out 95a645f22SBen Gras * the relevant capabilities of the underlaying hardware. Currently there 105a645f22SBen Gras * is only a function to find out the amount of RAM, but in the future there 115a645f22SBen Gras * will be also a function to detect how many concurrent threads the system 125a645f22SBen Gras * can run. 135a645f22SBen Gras * 145a645f22SBen Gras * \note On some operating systems, these function may temporarily 155a645f22SBen Gras * load a shared library or open file descriptor(s) to find out 165a645f22SBen Gras * the requested hardware information. Unless the application 175a645f22SBen Gras * assumes that specific file descriptors are not touched by 185a645f22SBen Gras * other threads, this should have no effect on thread safety. 195a645f22SBen Gras * Possible operations involving file descriptors will restart 205a645f22SBen Gras * the syscalls if they return EINTR. 215a645f22SBen Gras */ 225a645f22SBen Gras 235a645f22SBen Gras /* 245a645f22SBen Gras * Author: Lasse Collin 255a645f22SBen Gras * 265a645f22SBen Gras * This file has been put into the public domain. 275a645f22SBen Gras * You can do whatever you want with this file. 285a645f22SBen Gras * 295a645f22SBen Gras * See ../lzma.h for information about liblzma as a whole. 305a645f22SBen Gras */ 315a645f22SBen Gras 325a645f22SBen Gras #ifndef LZMA_H_INTERNAL 335a645f22SBen Gras # error Never include this file directly. Use <lzma.h> instead. 345a645f22SBen Gras #endif 355a645f22SBen Gras 365a645f22SBen Gras 375a645f22SBen Gras /** 385a645f22SBen Gras * \brief Get the total amount of physical memory (RAM) in bytes 395a645f22SBen Gras * 405a645f22SBen Gras * This function may be useful when determining a reasonable memory 415a645f22SBen Gras * usage limit for decompressing or how much memory it is OK to use 425a645f22SBen Gras * for compressing. 435a645f22SBen Gras * 445a645f22SBen Gras * \return On success, the total amount of physical memory in bytes 455a645f22SBen Gras * is returned. If the amount of RAM cannot be determined, 465a645f22SBen Gras * zero is returned. This can happen if an error occurs 475a645f22SBen Gras * or if there is no code in liblzma to detect the amount 485a645f22SBen Gras * of RAM on the specific operating system. 495a645f22SBen Gras */ 505a645f22SBen Gras extern LZMA_API(uint64_t) lzma_physmem(void) lzma_nothrow; 51*0a6a1f1dSLionel Sambuc 52*0a6a1f1dSLionel Sambuc 53*0a6a1f1dSLionel Sambuc /** 54*0a6a1f1dSLionel Sambuc * \brief Get the number of processor cores or threads 55*0a6a1f1dSLionel Sambuc * 56*0a6a1f1dSLionel Sambuc * This function may be useful when determining how many threads to use. 57*0a6a1f1dSLionel Sambuc * If the hardware supports more than one thread per CPU core, the number 58*0a6a1f1dSLionel Sambuc * of hardware threads is returned if that information is available. 59*0a6a1f1dSLionel Sambuc * 60*0a6a1f1dSLionel Sambuc * \brief On success, the number of available CPU threads or cores is 61*0a6a1f1dSLionel Sambuc * returned. If this information isn't available or an error 62*0a6a1f1dSLionel Sambuc * occurs, zero is returned. 63*0a6a1f1dSLionel Sambuc */ 64*0a6a1f1dSLionel Sambuc extern LZMA_API(uint32_t) lzma_cputhreads(void) lzma_nothrow; 65