mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-30 08:21:25 +00:00
another attempt to check word alignment
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@37203 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
39b14aa9d6
commit
f236bb6bfb
1 changed files with 29 additions and 13 deletions
|
@ -10,18 +10,34 @@
|
||||||
|
|
||||||
int main ()
|
int main ()
|
||||||
{
|
{
|
||||||
char buf[32];
|
char *buf = malloc(30);
|
||||||
char *ptr = buf;
|
void *v;
|
||||||
short sval = 4;
|
int *sp;
|
||||||
int ival = 3;
|
int *sq;
|
||||||
if (0 == ((int)ptr % 2))
|
int *ip;
|
||||||
{
|
int *iq;
|
||||||
ptr++;
|
int i;
|
||||||
}
|
|
||||||
*(short *)ptr = sval;
|
for (i = 0 ; i < 30; i++)
|
||||||
*(int *)(ptr + sizeof(short)) = ival;
|
{
|
||||||
ptr[sizeof(short) + sizeof(int)] = 0;
|
buf[i] = i;
|
||||||
puts (ptr); /* force compiler not to optimise out the above assignments */
|
}
|
||||||
exit (0);
|
v = buf;
|
||||||
|
|
||||||
|
sp = (short*)(v + 1);
|
||||||
|
sq = (short*)(v + 2);
|
||||||
|
if (*sp == *sq)
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
ip = (int*)(v + 1);
|
||||||
|
iq = (int*)(v + 2);
|
||||||
|
if (*ip == *iq)
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue