align.c revision 3f54fd611f536639ec30dd53c48e5ec1897cc7d9
/***********************************************************************
* *
* This software is part of the ast package *
* Copyright (c) 1985-2011 AT&T Intellectual Property *
* and is licensed under the *
* Eclipse Public License, Version 1.0 *
* by AT&T Intellectual Property *
* *
* A copy of the License is available at *
* (with md5 checksum b35adb5213ca9657e911e9befb180842) *
* *
* Information and Software Systems Research *
* AT&T Research *
* Florham Park NJ *
* *
* Glenn Fowler <gsf@research.att.com> *
* David Korn <dgk@research.att.com> *
* Phong Vo <kpv@research.att.com> *
* *
***********************************************************************/
#pragma prototyped
/*
* Glenn Fowler
* AT&T Bell Laboratories
*
* generate align features
*
* NOTE: two's complement binary integral representation assumed
*/
#include <setjmp.h>
union _u_
{
long u1;
char* u2;
double u3;
char u4[1024];
void* u8;
char* (*u9)();
};
struct _s_
{
char s1;
};
static union _u_ u;
static union _u_ v;
int
main()
{
register int i;
register int j;
register int k;
int align0;
int align1;
int align2;
unsigned long bit1;
unsigned long bit2;
unsigned long bits0;
unsigned long bits1;
unsigned long bits2;
bits0 = 0;
k = 0;
for (j = 0; j < align0; j++)
{
bits1 = 0;
for (i = 0; i < align0; i++)
{
}
{
k = j;
}
}
{
}
{
}
printf("\n");
printf("#define ALIGN_INTEGRAL uintptr_t\n");
printf("#define ALIGN_INTEGER(x) ((char*)(x)-(char*)0)\n");
printf("#define ALIGN_POINTER(x) ((char*)(x))\n");
printf("#define ALIGN_ROUND(x,y) ALIGN_POINTER(ALIGN_INTEGER((x)+(y)-1)&~((y)-1))\n");
else
printf("#define ALIGN_ROUND(x,y) ALIGN_POINTER(ALIGN_INTEGER(ALIGN_ALIGN(x)+(((y)+%d)/%d)-1)&~((((y)+%d)/%d)-1))\n", align0, align0, align0, align0);
printf("\n");
{
printf("#define ALIGN_BOUND ALIGN_BOUND2\n");
printf("#define ALIGN_ALIGN(x) ALIGN_ALIGN2(x)\n");
printf("#define ALIGN_TRUNC(x) ALIGN_TRUNC2(x)\n");
}
{
printf("#define ALIGN_BOUND ALIGN_BOUND1\n");
printf("#define ALIGN_ALIGN(x) ALIGN_ALIGN1(x)\n");
printf("#define ALIGN_TRUNC(x) ALIGN_TRUNC1(x)\n");
}
else
{
printf("#define ALIGN_BOUND 1\n");
printf("#define ALIGN_ALIGN(x) ALIGN_POINTER(x)\n");
printf("#define ALIGN_TRUNC(x) ALIGN_POINTER(x)\n");
}
printf("\n");
{
printf("#define ALIGN_BOUND1 ALIGN_BOUND2\n");
printf("#define ALIGN_ALIGN1(x) ALIGN_ALIGN2(x)\n");
printf("#define ALIGN_TRUNC1(x) ALIGN_TRUNC2(x)\n");
}
else
{
printf("#define ALIGN_TRUNC1(x) ALIGN_POINTER(ALIGN_INTEGER((x)+%d)&0x%lx)\n", align1 - 1, ~(bits0|bits1));
}
printf("#if _X64_\n");
printf("#define ALIGN_CLRBIT1(x) ALIGN_POINTER(ALIGN_INTEGER(x)&0xfffffffffffffffeULL)\n");
printf("#else\n");
printf("#define ALIGN_CLRBIT1(x) ALIGN_POINTER(ALIGN_INTEGER(x)&0xfffffffe)\n");
printf("#endif\n");
#else
#endif
printf("\n");
printf("#if _X64_\n");
printf("#define ALIGN_BOUND2 16\n");
printf("#define ALIGN_ALIGN2(x) ALIGN_TRUNC2((x)+15)\n");
printf("#define ALIGN_TRUNC2(x) ALIGN_POINTER(ALIGN_INTEGER(x)&0xfffffffffffffffeULL)\n");
printf("#else\n");
printf("#define ALIGN_BOUND2 8\n");
printf("#define ALIGN_ALIGN2(x) ALIGN_TRUNC2((x)+7)\n");
printf("#define ALIGN_TRUNC2(x) ALIGN_POINTER(ALIGN_INTEGER(x)&0xfffffff8)\n");
printf("#endif\n");
#else
#endif
printf("\n");
return 0;
}