dupuy@douglass.columbia.edu (Alexander Dupuy) (05/20/88)
I'm shocked I never noticed this before, but lots of programs (like the csh) report erroneous memory sizes. At any rate, the Sun-2 and Sun-2 have different page sizes (2K for the Sun-2, 8K for the Sun-3). The header file sps.h assumed that all Suns would have a page size of 2K. Here are the diffs: *** sps.h.dist Tue Feb 24 18:44:50 1987 --- sps.h Thu May 19 20:20:49 1988 *************** *** 22,31 **** # endif /* Convert clicks to kbytes ... */ ! # ifdef SUN # define KBYTES( size ) ((size) << 1) # else # define KBYTES( size ) ((size) >> (10 - PGSHIFT)) # endif /* Standard files to be examined ... */ --- 22,35 ---- # endif /* Convert clicks to kbytes ... */ ! # ifndef PGSHIFT # define KBYTES( size ) ((size) << 1) # else + # if PGSHIFT > 10 + # define KBYTES( size ) ((size) << (PGSHIFT - 10)) + # else # define KBYTES( size ) ((size) >> (10 - PGSHIFT)) + # endif # endif /* Standard files to be examined ... */ @alex inet: dupuy@columbia.edu uucp: ...!rutgers!columbia!dupuy
chris@mimsy.UUCP (Chris Torek) (06/01/88)
In article <5654@columbia.edu> dupuy@douglass.columbia.edu (Alexander Dupuy) writes: >... The header file sps.h assumed that all Suns would have a page size of 2K. [some diffs deleted; then:] > /* Convert clicks to kbytes ... */ >! # ifndef PGSHIFT > # define KBYTES( size ) ((size) << 1) > # else >+ # if PGSHIFT > 10 >+ # define KBYTES( size ) ((size) << (PGSHIFT - 10)) >+ # else > # define KBYTES( size ) ((size) >> (10 - PGSHIFT)) >+ # endif Why not simply use the macro that is provided for this purpose? #include <sys/param.h> #define KBYTES(size) (ctob(size) >> 10) /* or ctob(size) / 1024 */ (PCC tends not to merge the shifts, but that probably will make little real difference.) -- In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163) Domain: chris@mimsy.umd.edu Path: uunet!mimsy!chris
bitbug@vsi1.UUCP (James Buster) (06/02/88)
In article <11753@mimsy.UUCP> chris@mimsy.UUCP (Chris Torek) writes: >In article <5654@columbia.edu> dupuy@douglass.columbia.edu >(Alexander Dupuy) writes: >>... The header file sps.h assumed that all Suns would have a page size of 2K. > >[some diffs deleted; then:] >> /* Convert clicks to kbytes ... */ >>! # ifndef PGSHIFT >> # define KBYTES( size ) ((size) << 1) >> # else >>+ # if PGSHIFT > 10 >>+ # define KBYTES( size ) ((size) << (PGSHIFT - 10)) >>+ # else >> # define KBYTES( size ) ((size) >> (10 - PGSHIFT)) >>+ # endif > >Why not simply use the macro that is provided for this purpose? > > #include <sys/param.h> > > #define KBYTES(size) (ctob(size) >> 10) /* or ctob(size) / 1024 */ The KBYTES() macro doesn't exist on Suns (our machines are Sun 3s running SunOs 3.5), at least, not anywhere in /usr/include/sys, /usr/include, /sys/h, and /sys/ufs. Do you refer to SunOs 4.0, or 4.3 BSD? -------------------------------------------- James Buster Mad Hacker Extraordinaire ...!{sun,decwrl}!pyramid!vsi1!bitbug -------------------------------------------- ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
ok@quintus.UUCP (Richard A. O'Keefe) (06/02/88)
In article <618@vsi1.UUCP>, bitbug@vsi1.UUCP (James Buster) writes: > In article <11753@mimsy.UUCP> chris@mimsy.UUCP (Chris Torek) writes: > >Why not simply use the macro that is provided for this purpose? > > #include <sys/param.h> > > #define KBYTES(size) (ctob(size) >> 10) /* or ctob(size) / 1024 */ > > The KBYTES() macro doesn't exist on Suns (our machines are Sun 3s running > SunOs 3.5), at least, not anywhere in /usr/include/sys, /usr/include, > /sys/h, and /sys/ufs. Do you refer to SunOs 4.0, or 4.3 BSD? Since Chris Torek was suggesting that YOU should #define KBYTES it is hardly surprising that the macro doesn't already exist. If the only thing you want is ctob() (or PGSHIFT or NBPG) it suffices to get it from <machine/param.h> (which <sys/param.h> includes). That's where they are in SunOS 3.2 and on a Sequent. So the two lines YOU have to write to define KBYTES are #include <machine/param.h> And ( #define KBYTES(size) (ctob(size) >> 10) Or #define KBYTES(size) ((size)*NBPG/1024) )
chris@mimsy.UUCP (Chris Torek) (06/03/88)
In article <1050@cresswell.quintus.UUCP> ok@quintus.UUCP (Richard A. O'Keefe) writes: >Since Chris Torek was suggesting that YOU should #define KBYTES >it is hardly surprising that the macro doesn't already exist. Right. >If the only thing you want is ctob() (or PGSHIFT or NBPG) it suffices >to get it from <machine/param.h> (which <sys/param.h> includes). It is in <machine/machparam.h> in 4.3BSD (or 4.3++ anyway). That was why I suggested <sys/param.h>. <sys/param.h> also gets <sys/types.h> which sps needs anyway. >And ( > #define KBYTES(size) (ctob(size) >> 10) >Or > #define KBYTES(size) ((size)*NBPG/1024) >) Core clicks (what ctob() converts) and NBPG are not necessarily the same (I think...). (There is a profusion of abstractions [clicks, bytes, pages, segments, clusters, disk blocks, and file system blocks: did I forget any? :-) ] in the 4BSD VM code; I think some are likely to get clobbered in the future.) -- In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163) Domain: chris@mimsy.umd.edu Path: uunet!mimsy!chris