Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/freebsd-src
Path: blob/main/tools/test/auxinfo/auxinfo.c
39536 views
1
/*
2
* This file is in public domain.
3
* Written by Konstantin Belousov <[email protected]>
4
*/
5
6
#include <sys/mman.h>
7
#include <err.h>
8
#include <stdlib.h>
9
#include <stdint.h>
10
#include <stdio.h>
11
#include <unistd.h>
12
13
static void
14
test_pagesizes(void)
15
{
16
size_t *ps;
17
int i, nelem;
18
19
nelem = getpagesizes(NULL, 0);
20
if (nelem == -1)
21
err(1, "getpagesizes(NULL, 0)");
22
ps = malloc(nelem * sizeof(size_t));
23
if (ps == NULL)
24
err(1, "malloc");
25
nelem = getpagesizes(ps, nelem);
26
if (nelem == -1)
27
err(1, "getpagesizes");
28
printf("Supported page sizes:");
29
for (i = 0; i < nelem; i++)
30
printf(" %jd", (intmax_t)ps[i]);
31
printf("\n");
32
}
33
34
static void
35
test_pagesize(void)
36
{
37
38
printf("Pagesize: %d\n", getpagesize());
39
}
40
41
static void
42
test_osreldate(void)
43
{
44
45
printf("OSRELDATE: %d\n", getosreldate());
46
}
47
48
static void
49
test_ncpus(void)
50
{
51
52
printf("NCPUs: %ld\n", sysconf(_SC_NPROCESSORS_CONF));
53
}
54
55
int
56
main(int argc __unused, char *argv[] __unused)
57
{
58
59
test_pagesizes();
60
test_pagesize();
61
test_osreldate();
62
test_ncpus();
63
return (0);
64
}
65
66