xref: /freebsd/contrib/xz/src/liblzma/api/lzma/hardware.h (revision 7ffc4ec4860d01414b493cdf43738878a9ede538)
1 /* SPDX-License-Identifier: 0BSD */
2 
3 /**
4  * \file        lzma/hardware.h
5  * \brief       Hardware information
6  * \note        Never include this file directly. Use <lzma.h> instead.
7  *
8  * Since liblzma can consume a lot of system resources, it also provides
9  * ways to limit the resource usage. Applications linking against liblzma
10  * need to do the actual decisions how much resources to let liblzma to use.
11  * To ease making these decisions, liblzma provides functions to find out
12  * the relevant capabilities of the underlying hardware.
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 /*
24  * Author: Lasse Collin
25  */
26 
27 #ifndef LZMA_H_INTERNAL
28 #	error Never include this file directly. Use <lzma.h> instead.
29 #endif
30 
31 
32 /**
33  * \brief       Get the total amount of physical memory (RAM) in bytes
34  *
35  * This function may be useful when determining a reasonable memory
36  * usage limit for decompressing or how much memory it is OK to use
37  * for compressing.
38  *
39  * \return      On success, the total amount of physical memory in bytes
40  *              is returned. If the amount of RAM cannot be determined,
41  *              zero is returned. This can happen if an error occurs
42  *              or if there is no code in liblzma to detect the amount
43  *              of RAM on the specific operating system.
44  */
45 extern LZMA_API(uint64_t) lzma_physmem(void) lzma_nothrow;
46 
47 
48 /**
49  * \brief       Get the number of processor cores or threads
50  *
51  * This function may be useful when determining how many threads to use.
52  * If the hardware supports more than one thread per CPU core, the number
53  * of hardware threads is returned if that information is available.
54  *
55  * \return      On success, the number of available CPU threads or cores is
56  *              returned. If this information isn't available or an error
57  *              occurs, zero is returned.
58  */
59 extern LZMA_API(uint32_t) lzma_cputhreads(void) lzma_nothrow;
60