[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[cinvoke-svn] r88 - in trunk/cinvoke/lib: . arch
From: |
will |
Subject: |
[cinvoke-svn] r88 - in trunk/cinvoke/lib: . arch |
Date: |
12 Jul 2006 23:12:31 -0400 |
Author: will
Date: 2006-07-12 23:12:31 -0400 (Wed, 12 Jul 2006)
New Revision: 88
Modified:
trunk/cinvoke/lib/arch/cl_x86_win.h
trunk/cinvoke/lib/arch/empty_empty_empty.h
trunk/cinvoke/lib/arch/gcc_ppc_osx.h
trunk/cinvoke/lib/arch/gcc_x64_unix.h
trunk/cinvoke/lib/arch/gcc_x86_unix.h
trunk/cinvoke/lib/cinvoke.h
trunk/cinvoke/lib/structure.c
Log:
added support for osx's strange alignment rules
Modified: trunk/cinvoke/lib/arch/cl_x86_win.h
===================================================================
--- trunk/cinvoke/lib/arch/cl_x86_win.h 2006-07-13 00:23:15 UTC (rev 87)
+++ trunk/cinvoke/lib/arch/cl_x86_win.h 2006-07-13 03:12:31 UTC (rev 88)
@@ -108,4 +108,6 @@
#define ARCH_REGPARMS_IN_STACKSIZE 0
+#define ARCH_CLAMP_NONFIRST_STRUCTALIGN 0
+
#endif
Modified: trunk/cinvoke/lib/arch/empty_empty_empty.h
===================================================================
--- trunk/cinvoke/lib/arch/empty_empty_empty.h 2006-07-13 00:23:15 UTC (rev 87)
+++ trunk/cinvoke/lib/arch/empty_empty_empty.h 2006-07-13 03:12:31 UTC (rev 88)
@@ -173,7 +173,8 @@
// TODO: Set this to the number of bytes to leave blank at the top
// of the stack after the copied arguments. Usually 0. Note if you
// set this to a value other than 0, you must allocate additional
-// space in ARCH_PUT_STACK_BYTES
+// space in ARCH_PUT_STACK_BYTES (and de-allocate additional space in
+// ARCH_REMOVE_STACK_BYTES!).
#define ARCH_STACK_TOPSKIP 0
// TODO: Set this to 1 if args being passed in registers are
@@ -181,4 +182,9 @@
// there. Usually 0.
#define ARCH_REGPARMS_IN_STACKSIZE 0
+// TODO: If there is a maximum alignment size for structure members
+// other than the first, set it here. AFAIK the only arch to need
+// this is OSX/PPC
+#define ARCH_CLAMP_NONFIRST_STRUCTALIGN 0
+
#endif
Modified: trunk/cinvoke/lib/arch/gcc_ppc_osx.h
===================================================================
--- trunk/cinvoke/lib/arch/gcc_ppc_osx.h 2006-07-13 00:23:15 UTC (rev 87)
+++ trunk/cinvoke/lib/arch/gcc_ppc_osx.h 2006-07-13 03:12:31 UTC (rev 88)
@@ -231,4 +231,6 @@
#define ARCH_REGPARMS_IN_STACKSIZE 1
+#define ARCH_CLAMP_NONFIRST_STRUCTALIGN 4
+
#endif
Modified: trunk/cinvoke/lib/arch/gcc_x64_unix.h
===================================================================
--- trunk/cinvoke/lib/arch/gcc_x64_unix.h 2006-07-13 00:23:15 UTC (rev 87)
+++ trunk/cinvoke/lib/arch/gcc_x64_unix.h 2006-07-13 03:12:31 UTC (rev 88)
@@ -183,4 +183,6 @@
#define ARCH_REGPARMS_IN_STACKSIZE 0
+#define ARCH_CLAMP_NONFIRST_STRUCTALIGN 0
+
#endif
Modified: trunk/cinvoke/lib/arch/gcc_x86_unix.h
===================================================================
--- trunk/cinvoke/lib/arch/gcc_x86_unix.h 2006-07-13 00:23:15 UTC (rev 87)
+++ trunk/cinvoke/lib/arch/gcc_x86_unix.h 2006-07-13 03:12:31 UTC (rev 88)
@@ -103,4 +103,6 @@
#define ARCH_REGPARMS_IN_STACKSIZE 0
+#define ARCH_CLAMP_NONFIRST_STRUCTALIGN 0
+
#endif
Modified: trunk/cinvoke/lib/cinvoke.h
===================================================================
--- trunk/cinvoke/lib/cinvoke.h 2006-07-13 00:23:15 UTC (rev 87)
+++ trunk/cinvoke/lib/cinvoke.h 2006-07-13 03:12:31 UTC (rev 88)
@@ -149,14 +149,13 @@
struct _CInvStructure *structtype;
cinv_type_t type;
int offset;
- int alignment;
} CInvStructMember;
typedef struct _CInvStructure {
struct hashtable *members;
- CInvStructMember *firstmember;
int nextoffset;
int finished;
+ int alignment;
} CInvStructure;
typedef struct _CInvCallback {
Modified: trunk/cinvoke/lib/structure.c
===================================================================
--- trunk/cinvoke/lib/structure.c 2006-07-13 00:23:15 UTC (rev 87)
+++ trunk/cinvoke/lib/structure.c 2006-07-13 03:12:31 UTC (rev 88)
@@ -44,8 +44,8 @@
}
st->nextoffset = 0;
st->finished = 0;
- st->firstmember = NULL;
-
+ st->alignment = 1;
+
context_clear_error(context);
return st;
}
@@ -78,18 +78,23 @@
}
get_size(type, &dummy, &sz, &align);
+
+#if ARCH_CLAMP_NONFIRST_STRUCTALIGN
+ if (hashtable_count(structure->members))
+ align = ARCH_CLAMP_NONFIRST_STRUCTALIGN;
+#endif
+
if ((structure->nextoffset % align) != 0)
structure->nextoffset += align - (structure->nextoffset %
align);
member->structtype = NULL;
member->type = type;
member->offset = structure->nextoffset;
- member->alignment = align;
-
+
hashtable_insert(structure->members, namecopy, member);
- if (!structure->firstmember)
- structure->firstmember = member;
+ if (align > structure->alignment)
+ structure->alignment = align;
structure->nextoffset += sz;
@@ -111,6 +116,7 @@
"the child structure is not finished", 0);
return CINV_ERROR;
}
+
if (hashtable_search(structure->members, name)) {
context_set_error(context, CINV_E_INVAL,
"the structure already contains a member by that name",
0);
@@ -128,22 +134,25 @@
context_set_nomem(context);
return CINV_ERROR;
}
+
+ align = type->alignment;
+
+#if ARCH_CLAMP_NONFIRST_STRUCTALIGN
+ if (hashtable_count(structure->members))
+ align = ARCH_CLAMP_NONFIRST_STRUCTALIGN;
+#endif
- if (type->firstmember)
- align = type->firstmember->alignment;
-
if ((structure->nextoffset % align) != 0)
structure->nextoffset += align - (structure->nextoffset %
align);
member->structtype = type;
member->type = 0;
member->offset = structure->nextoffset;
- member->alignment = align;
hashtable_insert(structure->members, namecopy, member);
- if (!structure->firstmember)
- structure->firstmember = member;
+ if (align > structure->alignment)
+ structure->alignment = align;
structure->nextoffset += type->nextoffset;
@@ -159,11 +168,9 @@
}
// compute final padding
- if (structure->firstmember) {
- if ((structure->nextoffset % structure->firstmember->alignment)
!= 0) {
- structure->nextoffset +=
structure->firstmember->alignment -
- (structure->nextoffset %
structure->firstmember->alignment);
- }
+ if ((structure->nextoffset % structure->alignment) != 0) {
+ structure->nextoffset += structure->alignment -
+ (structure->nextoffset % structure->alignment);
}
structure->finished = 1;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [cinvoke-svn] r88 - in trunk/cinvoke/lib: . arch,
will <=