changeset 871:e70a0e7e2260

Apply duane's patch for align power-of-two checking in inline asm. Fixes #159
author Christian Kamm <kamm incasoftware de>
date Sun, 04 Jan 2009 15:39:34 +0100
parents af7a6faf9406
children aa953cc960b6
files gen/asm-x86-32.h gen/asm-x86-64.h
diffstat 2 files changed, 8 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/gen/asm-x86-32.h	Tue Dec 30 11:42:01 2008 +0100
+++ b/gen/asm-x86-32.h	Sun Jan 04 15:39:34 2009 +0100
@@ -1140,7 +1140,7 @@
 
 // mov eax, 4
 // mov eax, fs:4
-// -- have to assume we know wheter or not to use '$'
+// -- have to assume we know whether or not to use '$'
 
 static Token eof_tok;
 static Expression * Handled;
@@ -2517,8 +2517,9 @@
 	Expression * e = parseAsmExp()->optimize(WANTvalue | WANTinterpret);
 	integer_t align = e->toInteger();
 
-	if (align >= 0) {
-	    // %% is this printf portable?
+	if (align & align - 1 == 0) {
+	    //FIXME: This printf is not portable. The use of `align` varies from system to system; 
+	    // on i386 using a.out, .align `n` will align on a 2^`n` boundary instead of an `n` boundary
 #ifdef HAVE_GAS_BALIGN_AND_P2ALIGN 
 	    insnTemplate->printf(".balign\t%u", (unsigned) align);
 #else
--- a/gen/asm-x86-64.h	Tue Dec 30 11:42:01 2008 +0100
+++ b/gen/asm-x86-64.h	Sun Jan 04 15:39:34 2009 +0100
@@ -1260,7 +1260,7 @@
 
 // mov eax, 4
 // mov eax, fs:4
-// -- have to assume we know wheter or not to use '$'
+// -- have to assume we know whether or not to use '$'
 
 static Token eof_tok;
 static Expression * Handled;
@@ -2638,8 +2638,9 @@
 	Expression * e = parseAsmExp()->optimize(WANTvalue | WANTinterpret);
 	integer_t align = e->toInteger();
 
-	if (align >= 0) {
-	    // %% is this printf portable?
+	if (align & align - 1 == 0) {
+	    //FIXME: This printf is not portable. The use of `align` varies from system to system; 
+	    // on i386 using a.out, .align `n` will align on a 2^`n` boundary instead of an `n` boundary
 #ifdef HAVE_GAS_BALIGN_AND_P2ALIGN 
 	    insnTemplate->printf(".balign\t%u", (unsigned) align);
 #else