summaryrefslogtreecommitdiff
path: root/mcon/U/d_getpagsz.U
blob: 2499ebe5e6ae098a9f0de39c51035d25f59246bb (plain)
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
?RCS: $Id$
?RCS:
?RCS: Copyright (c) 1991-1997, 2004-2006, Raphael Manfredi
?RCS:
?RCS: You may redistribute only under the terms of the Artistic License,
?RCS: as specified in the README file that comes with the distribution.
?RCS: You may reuse parts of this distribution only within the terms of
?RCS: that same Artistic License; a copy of which may be found at the root
?RCS: of the source tree for dist 4.0.
?RCS:
?RCS: $Log: d_getpagsz.U,v $
?RCS: Revision 3.0.1.1  1994/10/29  16:13:10  ram
?RCS: patch36: added ?F: line for metalint file checking
?RCS:
?RCS: Revision 3.0  1993/08/18  12:06:14  ram
?RCS: Baseline for dist 3.0 netwide release.
?RCS:
?MAKE:d_getpagsz pagesize: Oldconfig Myread Trylink cat contains +cc +ccflags \
	libs rm Findhdr i_unistd
?MAKE:	-pick add $@ %<
?S:d_getpagsz:
?S:	This variable conditionally defines HAS_GETPAGESIZE if getpagesize()
?S:	is available to get the system page size.
?S:.
?S:pagesize (pagsize):
?S:	This variable holds the size in bytes of a system page.
?S:.
?C:HAS_GETPAGESIZE (GETPAGESIZE):
?C:	This symbol, if defined, indicates that the getpagesize system call
?C:	is available to get system page size, which is the granularity of
?C:	many memory management calls.
?C:.
?X: Don't name it PAGESIZE, this is sometimes used by <sys/param.h>
?C:PAGESIZE_VALUE (PAGSIZE):
?C:	This symbol holds the size in bytes of a system page (obtained via
?C:	the getpagesize() system call at configuration time or asked to the
?C:	user if the system call is not available).
?C:.
?H:#$d_getpagsz HAS_GETPAGESIZE		/**/
?H:#define PAGESIZE_VALUE $pagesize	/* System page size, in bytes */
?H:.
?F:!page
?T:guess
?LINT:set d_getpagsz
: see if getpagesize exists
$cat >try.c <<EOC
#$i_unistd I_UNISTD
#ifdef I_UNISTD
#include <unistd.h>
#endif
int main(void)
{
	static int ret;
	ret |= getpagesize();
	return ret ? 0 : 1;
}
EOC
cyn=getpagesize
set d_getpagsz
eval $trylink

@if pagesize || PAGESIZE_VALUE
: determine the system page size
echo " "
guess=' (OK to guess)'
case "$pagesize" in
'')
	$cat >page.c <<EOP
#include <stdio.h>
#$i_unistd I_UNISTD
#ifdef I_UNISTD
#include <unistd.h>
#endif
int main(void)
{
	printf("%d\n", getpagesize());
}
EOP
	echo "Computing the granularity of memory management calls..." >&4
	dflt='4096'
	case "$d_getpagsz" in
	"$define")
		if $cc $ccflags -o page page.c $libs >/dev/null 2>&1; then
			dflt=`./page`
			guess=''
		else
			echo "(I can't seem to compile the test program--guessing)"
		fi
		;;
	*)
		if $cc $ccflags -o page page.c $libs -lPW >/dev/null 2>&1; then
			dflt=`./page`
			guess=''
			echo "(For your eyes only: I used the getpagesize() from -lPW.)"
		else
			if $contains PAGESIZE `./findhdr sys/param.h` >/dev/null 2>&1; then
				$cat >page.c <<EOP
#include <sys/param.h>
#include <stdio.h>
int main(void)
{
	printf("%d\n", (int) PAGESIZE);
}
EOP
				if $cc $ccflags -o page page.c $libs >/dev/null 2>&1; then
					dflt=`./page`
					guess=''
					echo "(Using value of PAGESIZE found in <sys/param.h>.)"
				fi
			fi
		fi
		;;
	esac
	;;
*) dflt="$pagesize"; guess='';;
esac
rp="What is the system page size, in bytes$guess?"
. ./myread
pagesize=$ans
$rm -f page.c page

@end