]>
Commit | Line | Data |
---|---|---|
178f0f6d WW |
1 | .\" Copyright (c) 2015 William Woodruff (william@tuffbizz.com) |
2 | .\" | |
3 | .\" %%%LICENSE_START(VERBATIM) | |
4 | .\" Permission is granted to make and distribute verbatim copies of this | |
5 | .\" manual provided the copyright notice and this permission notice are | |
6 | .\" preserved on all copies. | |
7 | .\" | |
8 | .\" Permission is granted to copy and distribute modified versions of this | |
9 | .\" manual under the conditions for verbatim copying, provided that the | |
10 | .\" entire resulting derived work is distributed under the terms of a | |
11 | .\" permission notice identical to this one. | |
12 | .\" | |
13 | .\" Since the Linux kernel and libraries are constantly changing, this | |
14 | .\" manual page may be incorrect or out-of-date. The author(s) assume no | |
15 | .\" responsibility for errors or omissions, or for damages resulting from | |
16 | .\" the use of the information contained herein. The author(s) may not | |
17 | .\" have taken the same level of care in the production of this manual, | |
18 | .\" which is licensed free of charge, as they might when working | |
19 | .\" professionally. | |
20 | .\" | |
21 | .\" Formatted or processed versions of this manual, if unaccompanied by | |
22 | .\" the source, must acknowledge the copyright and authors of this work. | |
23 | .\" %%%LICENSE_END | |
24 | .\" | |
4b8c67d9 | 25 | .TH GET_PHYS_PAGES 3 2017-09-15 "GNU" "Linux Programmer's Manual" |
178f0f6d | 26 | .SH NAME |
551b8ee1 MK |
27 | get_phys_pages, get_avphys_pages \- get total and available physical |
28 | page counts | |
178f0f6d WW |
29 | .SH SYNOPSIS |
30 | .nf | |
31 | .B "#include <sys/sysinfo.h>" | |
68e4db0a | 32 | .PP |
178f0f6d | 33 | .B long int get_phys_pages(void); |
1f11ec0b | 34 | .B long int get_avphys_pages(void); |
3b3b8d5d | 35 | .fi |
178f0f6d WW |
36 | .SH DESCRIPTION |
37 | The function | |
38 | .BR get_phys_pages () | |
39 | returns the total number of physical pages of memory available on the system. | |
847e0d88 | 40 | .PP |
178f0f6d WW |
41 | The function |
42 | .BR get_avphys_pages () | |
43 | returns the number of currently available physical pages of memory on the | |
44 | system. | |
45 | .SH RETURN VALUE | |
551b8ee1 MK |
46 | On success, |
47 | these functions return a nonnegative value as given in DESCRIPTION. | |
178f0f6d WW |
48 | On failure, they return \-1 and set |
49 | .I errno | |
50 | to indicate the cause of the error. | |
51 | .SH ERRORS | |
52 | .TP | |
53 | .B ENOSYS | |
54 | The system could not provide the required information | |
55 | (possibly because the | |
56 | .I /proc | |
57 | filesystem was not mounted). | |
58 | .SH CONFORMING TO | |
59 | These functions are GNU extensions. | |
60 | .SH NOTES | |
61 | These functions obtain the required information by scanning the | |
62 | .I MemTotal | |
63 | and | |
64 | .I MemFree | |
65 | fields of | |
66 | .IR /proc/meminfo . | |
847e0d88 | 67 | .PP |
178f0f6d WW |
68 | The following |
69 | .BR sysconf (3) | |
70 | calls provide a portable means of obtaining the same information as the | |
71 | functions described on this page. | |
847e0d88 | 72 | .PP |
207050fa MK |
73 | .in +4n |
74 | .EX | |
75 | total_pages = sysconf(_SC_PHYS_PAGES); /* total pages */ | |
76 | avl_pages = sysconf(_SC_AVPHYS_PAGES); /* available pages */ | |
77 | .EE | |
78 | .in | |
178f0f6d WW |
79 | .SH EXAMPLE |
80 | The following example shows how | |
81 | .BR get_phys_pages () | |
82 | and | |
83 | .BR get_avphys_pages () | |
84 | can be used. | |
847e0d88 | 85 | .PP |
207050fa | 86 | .EX |
178f0f6d WW |
87 | #include <stdio.h> |
88 | #include <stdlib.h> | |
89 | #include <sys/sysinfo.h> | |
90 | ||
91 | int | |
92 | main(int argc, char *argv[]) | |
93 | { | |
94 | printf("This system has %ld pages of physical memory and " | |
95 | "%ld pages of physical memory available.\\n", | |
96 | get_phys_pages(), get_avphys_pages()); | |
97 | exit(EXIT_SUCCESS); | |
98 | } | |
207050fa | 99 | .EE |
178f0f6d WW |
100 | .SH SEE ALSO |
101 | .BR sysconf (3) |