🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #95

Re: Aligning an arbitrary pointer?

#95
From: Michael Meissner
Date: Fri, 07 Aug 1992 16:34
67 lines
3902 bytes
In article <PDS.92Jul21153918@lemming.webo.dg.com>
pds@lemming.webo.dg.com (Paul D. Smith) writes:

| [] Regarding Re: Aligning an arbitrary pointer?;
| [] barmar@think.com (Barry Margolin) writes:
| 
|     bm> In article <PDS.92Jul18154500@lemming.webo.dg.com>
|     bm> pds@lemming.webo.dg.com (Paul D. Smith) writes:
| 
|     >I'm modifying an existing piece of code which allocates a huge
|     >chunk of memory then segments it into various parts, one of which
|     >is an array of structs (it's a page table).
| 
|     bm> On some systems, casting a pointer to a more restrictive type
|     bm> may have the effect of realigning it. [...]
| 
| Bleah :).  Maybe true, but certainly not Standard practice.  I would
| expect that on at least some systems the compiler will happily allow
| you to assign 0x01381 (or some other non-aligned value) to an int*,
| say, and then just core with a bus error (or otherwise die) when you
| tried to dereference the pointer (that's pretty much what happens on
| my RISC system :-)

Sigh, what's the world coming to.  Somebody from Data General not
knowing about byte pointers and word pointers.  Anyway, the Data
General MV/Eclipse is one of those machines that drop a bit when you
convert from byte pointer (ie, char * or void *) to word pointer (just
about any other pointer).  That's because the hardware represent
pointers as follows:

		+-+------+------------------------------+
word pointer	|@| ring | address of 16 bit 'word'	+
		+-+------+------------------------------+

		+------+------------------------------+-+
byte pointer	| ring | address of 16 bit 'word'     |B|
		+------+------------------------------+-+

The '@' field on word pointers is an indirect bit, that if the
instruction has the indirect bit set, it will chase through the
pointers until it finds a pointer without an indirect bit set, and use
that as the address of the operand.

The 'ring' field indicates which segment to use in terms of addressing
(outer rings cannot address inner rings except through a call vector
that the inner ring controls).  User programs started out in ring 7
(and in AOS/VS, could load rings 4-6).  The kernel is in ring 0, and
the equivalent of the uarea is typically in ring 1.  As long as user
programs did not use more than 256 megabytes out of the 512 megabytes
available in the ring, you would get a trap if you used a byte pointer
in a word pointer context, and vicea versa.  The C compiler could be
configured via the /POINTERCHECK switch to check automatically at
either function call points, or at every single access whether or not
a pointer was valid for it's mode.  The runtimes would also turn on
checking if any module was compiled with /POINTERCHECK, through some
devious linker magic.

The 'B' field addresses which byte within a 16-bit 'word' is addressed.

Typically the only programs to run the first time without core
dumping, were those whose authors belived in linting the code, and
paying attention to lint's warnings.
--
Michael Meissner	email: meissner@osf.org		phone: 617-621-8861
Open Software Foundation, 11 Cambridge Center, Cambridge, MA, 02142

You are in a twisty little passage of standards, all conflicting.
Technical Details
Message-ID: <MEISSNER.92Aug7163449@tiktok.osf.org>
Path: arc1-ca.pugleaf.net!sparky!uunet!usc!sdd.hp.com!think.com!paperboy.osf.org!meissner
References: <PDS.92Jul16111642@lemming.webo.dg.com> <1473f4INNq24@early-bird.think.com> <PDS.92Jul18154500@lemming.webo.dg.com> <14f6u9INNon7@early-bird.think.com> <PDS.92Jul21153918@lemming.webo.dg.com>

Show Full Headers
Complete Article Headers
Newsgroups: comp.std.c
Path: arc1-ca.pugleaf.net!sparky!uunet!usc!sdd.hp.com!think.com!paperboy.osf.org!meissner
From: meissner@osf.org (Michael Meissner)
Subject: Re: Aligning an arbitrary pointer?
In-Reply-To: pds@lemming.webo.dg.com's message of 21 Jul 92 19:39:18 GMT
Message-ID: <MEISSNER.92Aug7163449@tiktok.osf.org>
Sender: news@osf.org (USENET News System)
Organization: Open Software Foundation
References: <PDS.92Jul16111642@lemming.webo.dg.com> <1473f4INNq24@early-bird.think.com>
 <PDS.92Jul18154500@lemming.webo.dg.com>
 <14f6u9INNon7@early-bird.think.com>
 <PDS.92Jul21153918@lemming.webo.dg.com>
Date: 7 Aug 92 16:34:49
Lines: 67