This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: PATCH: `__norestrict' type qualifier


> > > I don't think that's relevant to alignment as we meant it: there are
> > > no unaligned pointers on those machines!
> > 
> > That's my point.  A char* can be incorrectly aligned to extract a
> > word, if the byte index is nonzero.  But a word* can't be.  Therefore
> > if you define __norestrict pointers in terms of char* copying, then
> > you must allow for nonaligned words, and therefore you must make all
> > __norestrict pointers "fat".  This would be a Bad Thing.
> 
> :-)  Just as you must make __norestrict pointers fat on machines with
> different types in different memory spaces.
> 
> Still doesn't get us a definition of alignment.  It's hard: you might
> access a short array using __norestrict long *, and you can't even talk
> in terms of the offset into the short array, as the array might only
> have short alignment.

Could we drop this __nonrestrict / __typealias thing and instead just say
that gcc will implement pointer to unions so that they just work as
desired?  E.g. to do your copy-aligned-block-as-ints thing:

typedef union { char c; int i; } *ipnt;

copy (ipnt dest, ipnt src, words)
{
  while (--words >= 0)
    dest->i = src->i;
}

    double d1[20], d2[20];
f()
{
  copy ((ipnt)(char *)d1, (ipnt)(char *)d2, sizeof d1 / sizeof (int));
}


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]