Big-endian Gcc on Intel IA32
Etienne Lorrain
etienne_lorrain@yahoo.fr
Thu Dec 20 05:36:00 GMT 2001
Just a (maybe meaningless) comment on attributes:
When you begin to describe your variables with __attribute__(()),
for instance to optimise code size or speed, you also feel a need
to test if the variable as such or such attributes, for instance in
inline functions/macro. Let's take the example of align/alignof:
struct longstruct mydata __attribute__((aligned(16)));
static const struct longstruct emptydata = {};
void init_mydata (struct longstruct *mydataptr)
{
if (alignof (emptydata) > 4)
fast_memcpy(...);
else
slow_memcopy(...);
}
Maybe a more generic way to define and test attributes, at least
for structure types, would be something like:
typedef struct {
unsigned field1, field2;
char field3;
const unsigned __aligned__ = 16; /* not counted in sizeof() */
} an_aligned_16_type;
an_aligned_16_type data;
{ if (data.__aligned__ == 16) {} else {} }
In the same spirit:
typedef struct {
const unsigned __packed__ = 1;
unsigned short d1;
unsigned long d2;
}
typedef struct {
const unsigned __segment__ = __segment_gs;
unsigned char red;
unsigned char green;
unsigned char blue;
} what_I_need_for_another_project;
void fct (void)
{
const unsigned __aligned__ = 64;
....
}
The programmer could also define his own attributes.
Would also not break too much "indent" and "lint" kind of software.
No, I do not have the time to implement, sorry.
Etienne.
___________________________________________________________
Do You Yahoo!? -- Une adresse @yahoo.fr gratuite et en français !
Yahoo! Courrier : http://courrier.yahoo.fr
More information about the Gcc
mailing list