Re: ANSI C clarifications, with citations

From: Michael Meissner (meissner@munchkin.spectacle-pond.org)
Date: Mon Jul 03 2000 - 21:23:15 EST


On Thu, Jun 29, 2000 at 11:34:28AM +0200, lars brinkhoff wrote:
> Michael Meissner wrote:
> > On Wed, Jun 28, 2000 at 03:28:17AM -0400, Albert D. Cahalan wrote:
> > > > Sandy said:
> > > >> Cast a char * to int * on any architecture with strong alignmenmt
> > > >> restrictions and watch your code commit messy suicide.
> > >
> > > Oh no, the cast works perfectly well. The derereference is another
> > > matter of course, and you'd better make sure you satisfy alignment
> > > needs. Cast to long and mask off bits or cast to smaller types.
> >
> > Wrong. There have been machines in the past with just those
> > restrictions.
> >
> > The one I'm most familar with is the Data General MV/Eclipse machine
> > that I wrote a C compiler for. The original 16-bit machine of the
> > series had no byte pointers, and the word pointer format had an
> > indirection bit as the top bit. When they finally added byte pointers,
> > the byte pointer was the word pointer shifted left one bit position
> > (losing the indirection bit), and the bottom bit was then a byte
> > selector.
> >
> > Other machines included PR1ME computers which used a 32-bit word
> > pointer, and a 48-bit byte pointer.
>
> How did C on those machines implement a void *?

ISO C mandates void * being bit identical to char *. Void * in fact started
out in life as a proposal for two concepts, one of which was the general
pointer type that could point to anything (IIRC including functions), and the
other for the return type of malloc and friends, which says that the pointer is
guaranteed to be sufficiently aligned to hold any data type. Along the way,
the requirement that the generic pointer hold function addresses was dropped,
and the explicit type for the aligned pointer was dropped.

-- 
Michael Meissner, Red Hat, Inc.
PMB 198, 174 Littleton Road #3, Westford, Massachusetts 01886, USA
Work:	  meissner@redhat.com		phone: +1 978-486-9304
Non-work: meissner@spectacle-pond.org	fax:   +1 978-692-4482

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Fri Jul 07 2000 - 21:00:14 EST