]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man3/get_phys_pages.3
All pages: Remove the 5th argument to .TH
[thirdparty/man-pages.git] / man3 / get_phys_pages.3
CommitLineData
178f0f6d
WW
1.\" Copyright (c) 2015 William Woodruff (william@tuffbizz.com)
2.\"
5fbde956 3.\" SPDX-License-Identifier: Linux-man-pages-copyleft
178f0f6d 4.\"
45186a5d 5.TH GET_PHYS_PAGES 3 2021-03-22 "Linux man-pages (unreleased)"
178f0f6d 6.SH NAME
551b8ee1
MK
7get_phys_pages, get_avphys_pages \- get total and available physical
8page counts
42009080
AC
9.SH LIBRARY
10Standard C library
11.RI ( libc ", " \-lc )
178f0f6d
WW
12.SH SYNOPSIS
13.nf
14.B "#include <sys/sysinfo.h>"
68e4db0a 15.PP
9a84e338
AC
16.B long get_phys_pages(void);
17.B long get_avphys_pages(void);
3b3b8d5d 18.fi
178f0f6d
WW
19.SH DESCRIPTION
20The function
21.BR get_phys_pages ()
22returns the total number of physical pages of memory available on the system.
847e0d88 23.PP
178f0f6d
WW
24The function
25.BR get_avphys_pages ()
26returns the number of currently available physical pages of memory on the
27system.
28.SH RETURN VALUE
551b8ee1
MK
29On success,
30these functions return a nonnegative value as given in DESCRIPTION.
178f0f6d
WW
31On failure, they return \-1 and set
32.I errno
855d489a 33to indicate the error.
178f0f6d
WW
34.SH ERRORS
35.TP
36.B ENOSYS
37The system could not provide the required information
38(possibly because the
39.I /proc
40filesystem was not mounted).
3113c7f3 41.SH STANDARDS
e878a2de
MK
42These functions are GNU extensions.
43.SH NOTES
a6f73f75
AC
44Before glibc 2.23,
45these functions obtained the required information by scanning the
178f0f6d
WW
46.I MemTotal
47and
48.I MemFree
49fields of
50.IR /proc/meminfo .
a6f73f75
AC
51Since glibc 2.23,
52these functions obtain the required information by calling
53.BR sysinfo (2).
847e0d88 54.PP
178f0f6d
WW
55The following
56.BR sysconf (3)
57calls provide a portable means of obtaining the same information as the
58functions described on this page.
847e0d88 59.PP
207050fa
MK
60.in +4n
61.EX
62total_pages = sysconf(_SC_PHYS_PAGES); /* total pages */
63avl_pages = sysconf(_SC_AVPHYS_PAGES); /* available pages */
64.EE
65.in
a14af333 66.SH EXAMPLES
178f0f6d
WW
67The following example shows how
68.BR get_phys_pages ()
69and
70.BR get_avphys_pages ()
71can be used.
847e0d88 72.PP
207050fa 73.EX
178f0f6d
WW
74#include <stdio.h>
75#include <stdlib.h>
76#include <sys/sysinfo.h>
77
78int
79main(int argc, char *argv[])
80{
81 printf("This system has %ld pages of physical memory and "
d1a71985 82 "%ld pages of physical memory available.\en",
178f0f6d
WW
83 get_phys_pages(), get_avphys_pages());
84 exit(EXIT_SUCCESS);
85}
207050fa 86.EE
178f0f6d
WW
87.SH SEE ALSO
88.BR sysconf (3)