aboutsummaryrefslogtreecommitdiffstats
path: root/libtest/libtest_get_pagesize.c
blob: 52adbdcb6566cdf27e16374c9de3bfe36ed345c3 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/* See LICENSE file for copyright and license details. */
#include "common.h"
#ifndef TEST


size_t
libtest_get_pagesize(void)
{
	long int r;
	int saved_errno = errno;
	if ((r = sysconf(_SC_PAGESIZE)) <= 0)
		if ((r = sysconf(_SC_PAGE_SIZE)) <= 0)
			r = 4096L;
	errno = saved_errno;
	return (size_t)r;
}


#else


int
main(void)
{
	SET_UP_ALARM();

#ifdef __linux__
	errno = 0;
	EXPECT(libtest_get_pagesize() == 4096u);
	EXPECT(!errno);
#endif

	return 0;
}


#endif