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 wrote:
> [A long hypothetical definition of __restrict behaviour]

Ok folks, that one's too restrictive.  In cases with unusual object size,
where sizeof (B) % sizeof (A) != 0, it accesses too much.  In cases where
copying objects of type A changes the representation (as the x86 float
example), it implies behaviour which is very difficult to implement (and
extremely inefficient).

This one is small, succint, and fixes everything.  Comments?

    For copying, and conversion to other pointer types, pointers of type
    `__norestrict B *', for all B, behave exactly like `void *'.

    Reading through a pointer of type `__norestrict B *' has the same,
    implementation-defined behaviour as converting the pointer to type
    `const char *', copying sizeof B characters from that address into
    field `a' of a temporary of type `union { char a [sizeof B]; B b; }',
    and then reading field `b'.

    Writing through a pointer of type `__norestrict B *' has the same,
    implementation-defined behaviour as writing to field `b' of a temporary
    of type `union { char a [sizeof (B)]; B b; }', converting the pointer
    to type `char *', and then copying sizeof B characters to that address
    from field `a'.

    The order of character copies is not defined -- they may occur
    simultaneously, independently or in any combination.  A volatile
    qualification on B does not change this.  A const qualification is
    honoured by disallowing writes in the usual way.

enjoy,
-- Jamie


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