This is the mail archive of the 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]
Other format: [Raw text]

Re: does gcc support multiple sizes, or not?

> I'm not sure if I understand.  In ISO C++, it would be fine for "char *"
> to have more bits than all other pointers.  The standard says X* -> Y*
> -> X* is value-preserving if Y has no stricter alignment than X.  Since
> "char" has weak alignment requirements, Y can be "char".  Is that what
> you mean?

No, I meant if we go A -> B -> A, it's defined iff sizeof(B) >= sizeof(A)

> In ISO C++, there's of course no notion of "char *far" or "char
> *near"; there's just "char *".  So, there's no way to directly map
> your intended type system onto the conversion sequence above.

The problem seems to revolve around casts.  How about if I turn the
abort into a useful message about casting between pointer sizes, and
require the user to use a builtin to convert pointers?  In the case of
TPF, a "normal" cast wouldn't do the right thing anyway.  Of course,
we should make C give a similar warning, so as to not surprise users.

I strongly request we continue supporting the use of attribute((mode))
to create pointers of different sizes, at least for copying and
passing.  The m32c reset vector and interrupt table really want to be
set up like this example:

typedef void (*ifunc)() __attribute__((mode(SI)));
ifunc __attribute__((section(".resetvec"))) reset_vector = start;
extern ifunc ivects[];

  ivects[i] = dummy_handler;
  memcpy(ivects+1, ivects, 63*4);
  if (...)
    ivects[A0_VEC] = timer_a0_handler;
  if (...)
    ivects[A1_VEC] = timer_a1_handler;

It seems like there are plenty of examples of OSs which would benefit
from an easy way to manage nondefault pointer sizes, even if we can't
use them for everything a default pointer can be used for.

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