?RCS: $Id: d_getpagsz.U 167 2013-05-08 17:58:00Z rmanfredi $ ?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 ?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 < #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 < #$i_unistd I_UNISTD #ifdef I_UNISTD #include #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 < #include 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 .)" 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