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?

DJ Delorie wrote:
> 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;

 Maybe it is just me, but it seems more natural to have:
typedef void (*long ifunc)();

 i.e. in C or C++ have:
int *stdptr;
int *short ptr16bits;
int *long ptr64bits;
int *const constptr;
int *volatile volatileptr;

 I am not sure about authorising dereferencing of short pointers or only
 use them when associated to a standard pointer - like:
typedef void (*short func_t)();
func_t array_of_func_ptr[32];
void (*base)();
 and then:
(*base + array_of_func_ptr[i]) ();

 But short pointer have a use (reduce array size of pointers to local objects),
 exist on ia32/ia16 instruction set, and are the only pointer loaded atomic-ally
 in PPC (and other RISCs) (std pointers loaded by "lis r1,symb@hi ; addi r1,symb@l "),
 so basic data structures (queues, stacks) are a lot easier to implement when the
 size is limited to 64 Kbytes.

 The short pointer may also be used as the difference in between two pointers,
 by a cast when the programmer knows the difference will fit:
int array[100], *ptr1 = &array[10], *ptr2 = &array[20];
int *short diffptr = (int *short)(ptr2 - ptr1);
 The result of converting an "int *" to a "int *short" with a too big value should
 be the same as converting an "int" to a "short int" with a too big value.

 Sorry, just 2 cent ideas without implementation...
 Etienne. uncompressed/chunked Wed Aug 16 13:14:16 GMT 2006 
Découvrez un nouveau moyen de poser toutes vos questions quelque soit le sujet ! 
Yahoo! Questions/Réponses pour partager vos connaissances, vos opinions et vos expériences. 

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