* [PATCH] Add asm-compat.h to x86
@ 2007-10-30 14:55 Mathieu Desnoyers
2007-10-31 1:27 ` Jeremy Fitzhardinge
0 siblings, 1 reply; 3+ messages in thread
From: Mathieu Desnoyers @ 2007-10-30 14:55 UTC (permalink / raw)
To: Thomas Gleixner, Ingo Molnar, H. Peter Anvin; +Cc: linux-kernel
Add asm-compat.h to x86
In assembly code and in gcc inline assembly, we need .long to express a "c long"
type on i386 and a .quad to express the same on x86_64. Use macros similar to
powerpc "PPC_LONG" to express those. Name chosen: ASM_LONG. (didn't feel like
X86_LONG was required).
This is useful in inline assembly within code shared between 32 and 64
bits architectures in x86.
More compatible assembly macros could be added in this header later when
needed.
I had to create this to implement a merged optimized immediate values
header for x86.
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
CC: Thomas Gleixner <tglx@linutronix.de>
CC: Ingo Molnar <mingo@elte.hu>
CC: "H. Peter Anvin" <hpa@zytor.com>
---
include/asm-x86/asm-compat.h | 29 +++++++++++++++++++++++++++++
1 file changed, 29 insertions(+)
Index: linux-2.6-lttng/include/asm-x86/asm-compat.h
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ linux-2.6-lttng/include/asm-x86/asm-compat.h 2007-10-24 09:41:09.000000000 -0400
@@ -0,0 +1,29 @@
+#ifndef _ASM_X86_ASM_COMPAT_H
+#define _ASM_X86_ASM_COMPAT_H
+
+#include <asm/types.h>
+
+#ifdef __ASSEMBLY__
+# define stringify_in_c(...) __VA_ARGS__
+# define ASM_CONST(x) x
+#else
+/* This version of stringify will deal with commas... */
+# define __stringify_in_c(...) #__VA_ARGS__
+# define stringify_in_c(...) __stringify_in_c(__VA_ARGS__) " "
+# define __ASM_CONST(x) x##UL
+# define ASM_CONST(x) __ASM_CONST(x)
+#endif
+
+#ifdef CONFIG_X86_64
+
+/* operations for longs and pointers */
+#define ASM_LONG stringify_in_c(.quad)
+
+#else /* 32-bit */
+
+/* operations for longs and pointers */
+#define ASM_LONG stringify_in_c(.long)
+
+#endif
+
+#endif /* _ASM_X86_ASM_COMPAT_H */
--
Mathieu Desnoyers
Computer Engineering Ph.D. Student, Ecole Polytechnique de Montreal
OpenPGP key fingerprint: 8CD5 52C3 8E3C 4140 715F BA06 3F25 A8FE 3BAE 9A68
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] Add asm-compat.h to x86
2007-10-30 14:55 [PATCH] Add asm-compat.h to x86 Mathieu Desnoyers
@ 2007-10-31 1:27 ` Jeremy Fitzhardinge
2007-10-31 1:30 ` Glauber de Oliveira Costa
0 siblings, 1 reply; 3+ messages in thread
From: Jeremy Fitzhardinge @ 2007-10-31 1:27 UTC (permalink / raw)
To: Mathieu Desnoyers
Cc: Thomas Gleixner, Ingo Molnar, H. Peter Anvin, linux-kernel,
Glauber de Oliveira Costa
Mathieu Desnoyers wrote:
> Add asm-compat.h to x86
>
> In assembly code and in gcc inline assembly, we need .long to express a "c long"
> type on i386 and a .quad to express the same on x86_64. Use macros similar to
> powerpc "PPC_LONG" to express those. Name chosen: ASM_LONG. (didn't feel like
> X86_LONG was required).
>
> This is useful in inline assembly within code shared between 32 and 64
> bits architectures in x86.
>
> More compatible assembly macros could be added in this header later when
> needed.
>
> I had to create this to implement a merged optimized immediate values
> header for x86.
>
Seems sound to me, and this header might be a useful place to put other
things, like macros to emit exceptions, etc...
J
> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
> CC: Thomas Gleixner <tglx@linutronix.de>
> CC: Ingo Molnar <mingo@elte.hu>
> CC: "H. Peter Anvin" <hpa@zytor.com>
> ---
> include/asm-x86/asm-compat.h | 29 +++++++++++++++++++++++++++++
> 1 file changed, 29 insertions(+)
>
> Index: linux-2.6-lttng/include/asm-x86/asm-compat.h
> ===================================================================
> --- /dev/null 1970-01-01 00:00:00.000000000 +0000
> +++ linux-2.6-lttng/include/asm-x86/asm-compat.h 2007-10-24 09:41:09.000000000 -0400
> @@ -0,0 +1,29 @@
> +#ifndef _ASM_X86_ASM_COMPAT_H
> +#define _ASM_X86_ASM_COMPAT_H
> +
> +#include <asm/types.h>
> +
> +#ifdef __ASSEMBLY__
> +# define stringify_in_c(...) __VA_ARGS__
> +# define ASM_CONST(x) x
> +#else
> +/* This version of stringify will deal with commas... */
> +# define __stringify_in_c(...) #__VA_ARGS__
> +# define stringify_in_c(...) __stringify_in_c(__VA_ARGS__) " "
> +# define __ASM_CONST(x) x##UL
> +# define ASM_CONST(x) __ASM_CONST(x)
> +#endif
> +
> +#ifdef CONFIG_X86_64
> +
> +/* operations for longs and pointers */
> +#define ASM_LONG stringify_in_c(.quad)
> +
> +#else /* 32-bit */
> +
> +/* operations for longs and pointers */
> +#define ASM_LONG stringify_in_c(.long)
> +
> +#endif
> +
> +#endif /* _ASM_X86_ASM_COMPAT_H */
>
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] Add asm-compat.h to x86
2007-10-31 1:27 ` Jeremy Fitzhardinge
@ 2007-10-31 1:30 ` Glauber de Oliveira Costa
0 siblings, 0 replies; 3+ messages in thread
From: Glauber de Oliveira Costa @ 2007-10-31 1:30 UTC (permalink / raw)
To: Jeremy Fitzhardinge
Cc: Mathieu Desnoyers, Thomas Gleixner, Ingo Molnar, H. Peter Anvin,
linux-kernel
On 10/30/07, Jeremy Fitzhardinge <jeremy@goop.org> wrote:
> Mathieu Desnoyers wrote:
> > Add asm-compat.h to x86
> >
> > In assembly code and in gcc inline assembly, we need .long to express a "c long"
> > type on i386 and a .quad to express the same on x86_64. Use macros similar to
> > powerpc "PPC_LONG" to express those. Name chosen: ASM_LONG. (didn't feel like
> > X86_LONG was required).
> >
> > This is useful in inline assembly within code shared between 32 and 64
> > bits architectures in x86.
> >
> > More compatible assembly macros could be added in this header later when
> > needed.
> >
> > I had to create this to implement a merged optimized immediate values
> > header for x86.
> >
>
> Seems sound to me, and this header might be a useful place to put other
> things, like macros to emit exceptions, etc...
>
I have already done similar things in the unified pvops patch. But it
was just a few locations, and I didn't fell the need for a common
thing. But it is definitely useful.
--
Glauber de Oliveira Costa.
"Free as in Freedom"
http://glommer.net
"The less confident you are, the more serious you have to act."
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2007-10-31 1:30 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-10-30 14:55 [PATCH] Add asm-compat.h to x86 Mathieu Desnoyers
2007-10-31 1:27 ` Jeremy Fitzhardinge
2007-10-31 1:30 ` Glauber de Oliveira Costa
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox