Why NULL is 0

William E. Davidsen Jr davidsen at steinmetz.steinmetz.ge.com
Thu Apr 7 00:00:23 AEST 1988


In article <432 at goofy.megatest.UUCP> djones at megatest.UUCP (Dave Jones) writes:

| SPARC?  Really?  REALLY??   What have they done?  Please clarify.

  My understanding of SPARC, having read documentation and tried some
programs, is that SPARC requires that int, float, and long be alligned
rather than on an arbitrary boundary. This means that just typing a
pointer to char or short as pointer to {int long float double} will not
produce code which loads consecutive bytes starting at the 1st character
address.

  If you might be doing something like building a raw data buffer, by:
	*((int *)bufptr = intval;	/* char *bufptr */
	bufptr += sizeof(int);
it is portable to any machine which doesn't require allignment, but for
true portability something like the following must be done:
	memncpy(bufptr, &intval, sizeof int);
	bufptr += sizeof int;

  I am not claiming or even implying that this is going to break any
large number of programs, just that SPARC has more restrictions on
addressing than the 68000 series.  I don't have dpANS here, there may be
a better procedure to use than memncpy. 

  It also means that structures are not packed the same way in some
cases, I assume, but was not able to verify.
-- 
	bill davidsen		(wedu at ge-crd.arpa)
  {uunet | philabs | seismo}!steinmetz!crdos1!davidsen
"Stupidity, like virtue, is its own reward" -me



More information about the Comp.lang.c mailing list