From: Jarkko Hietaniemi Date: Sat, 11 Nov 2000 16:45:15 +0000 (+0000) Subject: Use sysconf() or getpagesize() to find out the pagesize. X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=68d873c6705870e19566e8337d808952cc8ec13e;p=p5sagit%2Fp5-mst-13.2.git Use sysconf() or getpagesize() to find out the pagesize. p4raw-id: //depot/perl@7645 --- diff --git a/perlio.c b/perlio.c index 0da8813..73e463a 100644 --- a/perlio.c +++ b/perlio.c @@ -1823,6 +1823,7 @@ static size_t page_size = 0; IV PerlIOMmap_map(PerlIO *f) { + dTHX; PerlIOMmap *m = PerlIOSelf(f,PerlIOMmap); PerlIOBuf *b = &m->base; IV flags = PerlIOBase(f)->flags; @@ -1841,8 +1842,40 @@ PerlIOMmap_map(PerlIO *f) if (len > 0) { Off_t posn; - if (!page_size) + if (!page_size) { +#if defined(HAS_SYSCONF) && (defined(_SC_PAGESIZE) || defined(_SC_PAGE_SIZE)) + { + SETERRNO(0,SS$_NORMAL); +# ifdef _SC_PAGESIZE + page_size = sysconf(_SC_PAGESIZE); +# else + page_size = sysconf(_SC_PAGE_SIZE); +# endif + if ((long)page_size < 0) { + if (errno) { + SV *error = ERRSV; + char *msg; + STRLEN n_a; + (void)SvUPGRADE(error, SVt_PV); + msg = SvPVx(error, n_a); + Perl_croak("panic: sysconf: %s", msg); + } + else + Perl_croak("panic: sysconf: pagesize unknown"); + } + } +#else +# ifdef HAS_GETPAGESIZE page_size = getpagesize(); +# else +# if defined(I_SYS_PARAM) && defined(PAGESIZE) + page_size = PAGESIZE; /* compiletime, bad */ +# endif +# endif +#endif + if ((IV)page_size <= 0) + Perl_croak("panic: bad pagesize %"IVdf, (IV)page_size); + } if (b->posn < 0) { /* This is a hack - should never happen - open should have set it ! */