From owner-freebsd-hackers Thu Oct 26 02:51:23 1995 Return-Path: owner-hackers Received: (from root@localhost) by freefall.freebsd.org (8.6.12/8.6.6) id CAA29136 for hackers-outgoing; Thu, 26 Oct 1995 02:51:23 -0700 Received: from ref.tfs.com (ref.tfs.com [140.145.254.251]) by freefall.freebsd.org (8.6.12/8.6.6) with ESMTP id CAA29131 for ; Thu, 26 Oct 1995 02:51:18 -0700 Received: (from julian@localhost) by ref.tfs.com (8.6.12/8.6.12) id CAA27831; Thu, 26 Oct 1995 02:50:55 -0700 From: Julian Elischer Message-Id: <199510260950.CAA27831@ref.tfs.com> Subject: Re: _SC_PAGESIZE patch to sysconf(3) To: vcapuano@esoc.esa.de (Vincenzo Capuano) Date: Thu, 26 Oct 1995 02:50:55 -0700 (PDT) Cc: freebsd-hackers@freebsd.org In-Reply-To: <9510260906.AA17142@dpd16.dpd.esoc.esa.de> from "Vincenzo Capuano" at Oct 26, 95 10:06:28 am X-Mailer: ELM [version 2.4 PL24] Content-Type: text Content-Length: 2701 Sender: owner-hackers@freebsd.org Precedence: bulk It's not a bad addition, but it's not in the POSIX definitions that I can see, though I only have the XPG4 definitions which allign this call to posix-1 despite having some posix 2 definitions in it (the posix 2 standard was still not approved when XPG4 went to print I think) if this is not POSIX standard it should be hidden behind a #ifndef _POSIX_SOURCE > > I was porting a program I developed on Solaris to FreeBSD when I got into a > missing call: sysconf(_SC_PAGESIZE). I know I could use getpagesize(3), but > I then had to ifdef my code. > So, if you like it here is a patch to sysconf that will recognise _SC_PAGESIZE. > > Here are the diffs: > ------------------------------------------------------------------------------- > *** /usr/src/lib/libc/gen/sysconf.c.orig Wed Oct 25 20:57:03 1995 > --- /usr/src/lib/libc/gen/sysconf.c Wed Oct 25 21:15:33 1995 > *************** > *** 179,184 **** > --- 179,188 ---- > return (-1); > return (value); > break; > + case _SC_PAGESIZE: > + mib[0] = CTL_HW; > + mib[1] = HW_PAGESIZE; > + break; > default: > errno = EINVAL; > return (-1); > *** /usr/src/lib/libc/gen/sysconf.3.orig Thu Oct 26 00:13:26 1995 > --- /usr/src/lib/libc/gen/sysconf.3 Thu Oct 26 00:20:38 1995 > *************** > *** 142,147 **** > --- 142,150 ---- > .It Li _SC_2_UPE > Return 1 if the system supports the User Portability Utilities Option, > otherwise \-1. > + .It Li _SC_PAGESIZE > + Number of bytes in a system memory page. Page granularity is the granularity > + of many of the memory management calls. See also getpagesize(3). > .El > .Sh RETURN VALUES > If the call to > *** /usr/include/sys/unistd.h.orig Wed Oct 25 21:00:56 1995 > --- /usr/include/sys/unistd.h Thu Oct 26 00:27:55 1995 > *************** > *** 115,120 **** > --- 115,121 ---- > #define _SC_2_UPE 25 > #define _SC_STREAM_MAX 26 > #define _SC_TZNAME_MAX 27 > + #define _SC_PAGESIZE 28 > > /* configurable system strings */ > #define _CS_PATH 1 > > ------------------------------------------------------------------------------- > > They apply to -current. > > > Vincenzo > ======================================================================== > Vincenzo Capuano, Vitrociset /\_/\ Tel: +49 (0)6151 90-3159 > European Space Agency - ESOC ( o.o ) Fax: +49 (0)6151 90-3414 > Robert Bosch Strasse 5 > - < Email: vcapuano@vmprofs.esoc.esa.de > D-64293 Darmstadt, Germany >