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