align.c revision 1
1N/A/*********************************************************************** 1N/A* This software is part of the ast package * 1N/A* Copyright (c) 1985-2011 AT&T Intellectual Property * 1N/A* and is licensed under the * 1N/A* Common Public License, Version 1.0 * 1N/A* by AT&T Intellectual Property * 1N/A* A copy of the License is available at * 1N/A* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) * 1N/A* Information and Software Systems Research * 1N/A* Glenn Fowler <gsf@research.att.com> * 1N/A* David Korn <dgk@research.att.com> * 1N/A* Phong Vo <kpv@research.att.com> * 1N/A***********************************************************************/ 1N/A * AT&T Bell Laboratories 1N/A * generate align features 1N/A * NOTE: two's complement binary integral representation assumed 1N/A printf(
"typedef unsigned %s ALIGN_INTEGRAL;\n",
sizeof(
char*) >=
sizeof(
long) ?
"long" :
sizeof(
char*) >=
sizeof(
int) ?
"int" :
"short");
1N/A printf(
"#define ALIGN_CHUNK %d\n",
sizeof(
char*) >=
4 ?
8192 :
1024);
1N/A printf(
"#define ALIGN_INTEGRAL %s\n",
sizeof(
char*) >=
sizeof(
long) ?
"long" :
sizeof(
char*) >=
sizeof(
int) ?
"int" :
"short");
1N/A printf(
"#define ALIGN_INTEGER(x) ((ALIGN_INTEGRAL)(x))\n");
1N/A printf(
"#define ALIGN_POINTER(x) ((char*)(x))\n");
1N/A if (
bits2 == (
align2 -
1))
printf(
"#define ALIGN_ROUND(x,y) ALIGN_POINTER(ALIGN_INTEGER((x)+(y)-1)&~((y)-1))\n");
1N/A printf(
"#define ALIGN_BOUND ALIGN_BOUND2\n");
1N/A printf(
"#define ALIGN_ALIGN(x) ALIGN_ALIGN2(x)\n");
1N/A printf(
"#define ALIGN_TRUNC(x) ALIGN_TRUNC2(x)\n");
1N/A printf(
"#define ALIGN_BOUND ALIGN_BOUND1\n");
1N/A printf(
"#define ALIGN_ALIGN(x) ALIGN_ALIGN1(x)\n");
1N/A printf(
"#define ALIGN_TRUNC(x) ALIGN_TRUNC1(x)\n");
1N/A printf(
"#define ALIGN_ALIGN(x) ALIGN_POINTER(x)\n");
1N/A printf(
"#define ALIGN_TRUNC(x) ALIGN_POINTER(x)\n");
1N/A printf(
"#define ALIGN_BOUND1 ALIGN_BOUND2\n");
1N/A printf(
"#define ALIGN_ALIGN1(x) ALIGN_ALIGN2(x)\n");
1N/A printf(
"#define ALIGN_TRUNC1(x) ALIGN_TRUNC2(x)\n");
1N/A printf(
"#define ALIGN_CLRBIT1(x) ALIGN_POINTER(ALIGN_INTEGER(x)&0x%lx)\n", ~
bit1);
1N/A printf(
"#define ALIGN_SETBIT1(x) ALIGN_POINTER(ALIGN_INTEGER(x)|0x%lx)\n",
bit1);
1N/A printf(
"#define ALIGN_TSTBIT1(x) ALIGN_POINTER(ALIGN_INTEGER(x)&0x%lx)\n",
bit1);
1N/A printf(
"#define ALIGN_CLRBIT2(x) ALIGN_POINTER(ALIGN_INTEGER(x)&0x%lx)\n", ~
bit2);
1N/A printf(
"#define ALIGN_SETBIT2(x) ALIGN_POINTER(ALIGN_INTEGER(x)|0x%lx)\n",
bit2);
1N/A printf(
"#define ALIGN_TSTBIT2(x) ALIGN_POINTER(ALIGN_INTEGER(x)&0x%lx)\n",
bit2);