public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* RE: [Patch] asm workarounds in generic header files
@ 2003-09-09 19:34 Siddha, Suresh B
  2003-09-09 19:51 ` Jes Sorensen
  0 siblings, 1 reply; 14+ messages in thread
From: Siddha, Suresh B @ 2003-09-09 19:34 UTC (permalink / raw)
  To: Christoph Hellwig, Jes Sorensen
  Cc: Andrew Morton, Linus Torvalds, linux-kernel, Nakajima, Jun,
	Mallick, Asit K

Thanks Jes and Christoph for your comments. As you have noticed, 
this patch is not a workaround/hack for any C standard violation. 

We believe that we are trying to improve the code by localizing 
the compiler issues (including the ones for gcc3 and Intel complier)
and by introducing use of compiler intrinsics (e.g. for barrier()).

> Could you try to test your RELOC_HIDE version with various 
> gcc versions
> and maybe as some gcc gurus whether it's fine?  

RELOC_HIDE is handling a specific gcc version behaviour. 
There was a discussion on this sometime back
http://gcc.gnu.org/ml/gcc/2002-01/msg00484.html

Richard Henderson mentioned that asm stmt is the only escape 
hitch for the current compiler behaviour. But as Linus suggested 
in the above mail thread, non-same-type cast(which is the current 
solution for Intel compiler) is the way to go for gcc also.

As far as barrier() is concerned, a cleaner approach would be  
a compiler-specific intrinsic(something like the one implemented by  
Intel compiler) that can tell the programmer's intention explicitly.

Once gcc has a cleaner solution for both these macros, we can 
do-away with these changes.

thanks,
suresh

^ permalink raw reply	[flat|nested] 14+ messages in thread
* RE: [Patch] asm workarounds in generic header files
@ 2003-09-10  5:51 Nakajima, Jun
  0 siblings, 0 replies; 14+ messages in thread
From: Nakajima, Jun @ 2003-09-10  5:51 UTC (permalink / raw)
  To: Andrew Morton, Siddha, Suresh B
  Cc: davidm, torvalds, jes, hch, linux-kernel, Mallick, Asit K

Yes, ECC is only for IA-64. ICC is for x86. ICC does not require
intrinsics because it supports asm inline, and it can build the kernel.
Please look at
http://lists.insecure.org/lists/linux-kernel/2002/Oct/8790.html for
example.

Note that asm inline support is just one of many GCC extensions required
to build the kernel, and for optimization purposes Intel compiler for
IA-64 chose not to support inline asm, but it uses intrinsic to do the
equivalent things.

Thanks,
Jun

> -----Original Message-----
> From: Andrew Morton [mailto:akpm@osdl.org]
> Sent: Tuesday, September 09, 2003 10:08 PM
> To: Siddha, Suresh B
> Cc: davidm@HPL.HP.COM; torvalds@osdl.org; jes@wildopensource.com;
> hch@infradead.org; linux-kernel@vger.kernel.org; Nakajima, Jun;
Mallick,
> Asit K
> Subject: Re: [Patch] asm workarounds in generic header files
> 
> "Siddha, Suresh B" <suresh.b.siddha@intel.com> wrote:
> >
> > --- linux/include/linux/compiler-intel.h	Wed Dec 31 16:00:00 1969
> >  +++ linux-/include/linux/compiler-intel.h	Tue Sep  9 21:34:19 2003
> >  @@ -0,0 +1,21 @@
> >  +/* Never include this file directly.  Include <linux/compiler.h>
> instead.  */
> >  +
> >  +#ifdef __ECC
> >  +
> >  +/* Some compiler specific definitions are overwritten here
> >  + * for Intel ECC compiler
> >  + */
> >  +
> >  +#include <asm/intrinsics.h>
> 
> This is ia64-only, yes?
> 
> Where do we stand with ECC/ia32 support?


^ permalink raw reply	[flat|nested] 14+ messages in thread
* RE: [Patch] asm workarounds in generic header files
@ 2003-09-10  4:50 Siddha, Suresh B
  2003-09-10  5:08 ` Andrew Morton
  0 siblings, 1 reply; 14+ messages in thread
From: Siddha, Suresh B @ 2003-09-10  4:50 UTC (permalink / raw)
  To: davidm, Linus Torvalds
  Cc: Jes Sorensen, Christoph Hellwig, Andrew Morton, linux-kernel,
	Nakajima, Jun, Mallick, Asit K

[-- Attachment #1: Type: text/plain, Size: 9544 bytes --]

> How about something like this?
> (the patch has Works-for-Me status...)
> 
> 	--david

Attached the patch with minor changes to David's patch.

include/linux/compiler.h defines the generic 
definitions which are overwritten by per-compiler definitions.

include/linux/compiler-gcc.h contains the common definitions 
for all gcc versions.

include/linux/compiler-gcc[2,3,+].h contains gcc version 
specific definitions.

And intel.diff patch adds Intel compiler specific definitions.

thanks,
suresh

diff -Nru linux/include/linux/compiler-gcc+.h linux-/include/linux/compiler-gcc+.h
--- linux/include/linux/compiler-gcc+.h	Wed Dec 31 16:00:00 1969
+++ linux-/include/linux/compiler-gcc+.h	Tue Sep  9 21:26:03 2003
@@ -0,0 +1,14 @@
+/* Never include this file directly.  Include <linux/compiler.h> instead.  */
+
+/*
+ * These definitions are for Ueber-GCC: always newer than the latest
+ * version and hence sporting everything plus a kitchen-sink.
+ */
+#include <linux/compiler-gcc.h>
+
+#define inline			__inline__ __attribute__((always_inline))
+#define __inline__		__inline__ __attribute__((always_inline))
+#define __inline		__inline__ __attribute__((always_inline))
+#define __deprecated		__attribute__((deprecated))
+#define __attribute_used__	__attribute__((__used__))
+#define __attribute_pure__	__attribute__((pure))
diff -Nru linux/include/linux/compiler-gcc.h linux-/include/linux/compiler-gcc.h
--- linux/include/linux/compiler-gcc.h	Wed Dec 31 16:00:00 1969
+++ linux-/include/linux/compiler-gcc.h	Tue Sep  9 21:26:03 2003
@@ -0,0 +1,17 @@
+/* Never include this file directly.  Include <linux/compiler.h> instead.  */
+
+/*
+ * Common definitions for all gcc versions go here.
+ */
+
+
+/* Optimization barrier */
+/* The "volatile" is due to gcc bugs */
+#define barrier() __asm__ __volatile__("": : :"memory")
+
+/* This macro obfuscates arithmetic on a variable address so that gcc
+   shouldn't recognize the original var, and make assumptions about it */
+#define RELOC_HIDE(ptr, off)					\
+  ({ unsigned long __ptr;					\
+    __asm__ ("" : "=g"(__ptr) : "0"(ptr));		\
+    (typeof(ptr)) (__ptr + (off)); })
diff -Nru linux/include/linux/compiler-gcc2.h linux-/include/linux/compiler-gcc2.h
--- linux/include/linux/compiler-gcc2.h	Wed Dec 31 16:00:00 1969
+++ linux-/include/linux/compiler-gcc2.h	Tue Sep  9 21:26:03 2003
@@ -0,0 +1,23 @@
+/* Never include this file directly.  Include <linux/compiler.h> instead.  */
+
+/* These definitions are for GCC v2.x.  */
+
+/* Somewhere in the middle of the GCC 2.96 development cycle, we implemented
+   a mechanism by which the user can annotate likely branch directions and
+   expect the blocks to be reordered appropriately.  Define __builtin_expect
+   to nothing for earlier compilers.  */
+#include <linux/compiler-gcc.h>
+
+#if __GNUC_MINOR__ < 96
+# define __builtin_expect(x, expected_value) (x)
+#endif
+
+#define __attribute_used__	__attribute__((__unused__))
+
+/*
+ * The attribute `pure' is not implemented in GCC versions earlier
+ * than 2.96.
+ */
+#if __GNUC_MINOR__ >= 96
+# define __attribute_pure__	__attribute__((pure))
+#endif
diff -Nru linux/include/linux/compiler-gcc3.h linux-/include/linux/compiler-gcc3.h
--- linux/include/linux/compiler-gcc3.h	Wed Dec 31 16:00:00 1969
+++ linux-/include/linux/compiler-gcc3.h	Tue Sep  9 21:26:03 2003
@@ -0,0 +1,22 @@
+/* Never include this file directly.  Include <linux/compiler.h> instead.  */
+
+/* These definitions are for GCC v3.x.  */
+#include <linux/compiler-gcc.h>
+
+#if __GNUC_MINOR__ >= 1
+# define inline		__inline__ __attribute__((always_inline))
+# define __inline__	__inline__ __attribute__((always_inline))
+# define __inline	__inline__ __attribute__((always_inline))
+#endif
+
+#if __GNUC_MINOR__ > 0
+# define __deprecated	__attribute__((deprecated))
+#endif
+
+#if __GNUC_MINOR__ >= 3
+# define __attribute_used__	__attribute__((__used__))
+#else
+# define __attribute_used__	__attribute__((__unused__))
+#endif
+
+#define __attribute_pure__	__attribute__((pure))
diff -Nru linux/include/linux/compiler.h linux-/include/linux/compiler.h
--- linux/include/linux/compiler.h	Mon Sep  8 11:51:00 2003
+++ linux-/include/linux/compiler.h	Tue Sep  9 21:32:44 2003
@@ -2,28 +2,28 @@
 #define __LINUX_COMPILER_H
 
 #ifdef __CHECKER__
-  #define __user	__attribute__((noderef, address_space(1)))
-  #define __kernel	/* default address space */
+# define __user		__attribute__((noderef, address_space(1)))
+# define __kernel	/* default address space */
 #else
-  #define __user
-  #define __kernel
+# define __user
+# define __kernel
 #endif
 
-#if (__GNUC__ > 3) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1)
-#define inline		__inline__ __attribute__((always_inline))
-#define __inline__	__inline__ __attribute__((always_inline))
-#define __inline	__inline__ __attribute__((always_inline))
-#endif
-
-/* Somewhere in the middle of the GCC 2.96 development cycle, we implemented
-   a mechanism by which the user can annotate likely branch directions and
-   expect the blocks to be reordered appropriately.  Define __builtin_expect
-   to nothing for earlier compilers.  */
-
-#if __GNUC__ == 2 && __GNUC_MINOR__ < 96
-#define __builtin_expect(x, expected_value) (x)
+#if __GNUC__ > 3
+# include <linux/compiler-gcc+.h>	/* catch-all for GCC 4, 5, etc. */
+#elif __GNUC__ == 3
+# include <linux/compiler-gcc3.h>
+#elif __GNUC__ == 2
+# include <linux/compiler-gcc2.h>
+#else
+# error Sorry, your compiler is too old/not recognized.
 #endif
 
+/* 
+ * Below are the generic compiler related macros required for kernel
+ * build. Actual compiler/compiler version specific implementations 
+ * come from the above header files
+ */
 #define likely(x)	__builtin_expect(!!(x), 1)
 #define unlikely(x)	__builtin_expect(!!(x), 0)
 
@@ -33,10 +33,8 @@
  * Usage is:
  * 		int __deprecated foo(void)
  */
-#if ( __GNUC__ == 3 && __GNUC_MINOR__ > 0 ) || __GNUC__ > 3
-#define __deprecated	__attribute__((deprecated))
-#else
-#define __deprecated
+#ifndef __deprecated
+# define __deprecated		/* unimplemented */
 #endif
 
 /*
@@ -50,10 +48,8 @@
  * In prior versions of gcc, such functions and data would be emitted, but
  * would be warned about except with attribute((unused)).
  */
-#if __GNUC__ == 3 && __GNUC_MINOR__ >= 3 || __GNUC__ > 3
-#define __attribute_used__	__attribute__((__used__))
-#else
-#define __attribute_used__	__attribute__((__unused__))
+#ifndef __attribute_used__
+# define __attribute_used__	/* unimplemented */
 #endif
 
 /*
@@ -65,19 +61,21 @@
  * elimination and loop optimization just as an arithmetic operator
  * would be.
  * [...]
- * The attribute `pure' is not implemented in GCC versions earlier
- * than 2.96.
  */
-#if (__GNUC__ == 2 && __GNUC_MINOR__ >= 96) || __GNUC__ > 2
-#define __attribute_pure__	__attribute__((pure))
-#else
-#define __attribute_pure__	/* unimplemented */
+#ifndef __attribute_pure__
+# define __attribute_pure__	/* unimplemented */
+#endif
+
+/* Optimization barrier */
+#ifndef barrier
+# define barrier() __memory_barrier();
 #endif
 
-/* This macro obfuscates arithmetic on a variable address so that gcc
-   shouldn't recognize the original var, and make assumptions about it */
-#define RELOC_HIDE(ptr, off)					\
+#ifndef RELOC_HIDE
+# define RELOC_HIDE(ptr, off)					\
   ({ unsigned long __ptr;					\
-    __asm__ ("" : "=g"(__ptr) : "0"(ptr));		\
+     __ptr = (unsigned long) (ptr);				\
     (typeof(ptr)) (__ptr + (off)); })
+#endif
+
 #endif /* __LINUX_COMPILER_H */
diff -Nru linux/include/linux/kernel.h linux-/include/linux/kernel.h
--- linux/include/linux/kernel.h	Mon Sep  8 11:51:01 2003
+++ linux-/include/linux/kernel.h	Tue Sep  9 21:26:03 2003
@@ -15,10 +15,6 @@
 #include <asm/byteorder.h>
 #include <asm/bug.h>
 
-/* Optimization barrier */
-/* The "volatile" is due to gcc bugs */
-#define barrier() __asm__ __volatile__("": : :"memory")
-
 #define INT_MAX		((int)(~0U>>1))
 #define INT_MIN		(-INT_MAX - 1)
 #define UINT_MAX	(~0U)
diff -Nru linux/include/linux/compiler-intel.h linux-/include/linux/compiler-intel.h
--- linux/include/linux/compiler-intel.h	Wed Dec 31 16:00:00 1969
+++ linux-/include/linux/compiler-intel.h	Tue Sep  9 21:34:19 2003
@@ -0,0 +1,21 @@
+/* Never include this file directly.  Include <linux/compiler.h> instead.  */
+
+#ifdef __ECC
+
+/* Some compiler specific definitions are overwritten here
+ * for Intel ECC compiler 
+ */
+
+#include <asm/intrinsics.h>
+
+#undef barrier
+#undef RELOC_HIDE
+
+#define barrier() __memory_barrier()
+
+#define RELOC_HIDE(ptr, off)					\
+  ({ unsigned long __ptr;					\
+     __ptr = (unsigned long) (ptr);				\
+    (typeof(ptr)) (__ptr + (off)); })
+
+#endif
diff -Nru linux/include/linux/compiler.h linux-/include/linux/compiler.h
--- linux/include/linux/compiler.h	Tue Sep  9 21:34:11 2003
+++ linux-/include/linux/compiler.h	Tue Sep  9 21:35:08 2003
@@ -19,6 +19,13 @@
 # error Sorry, your compiler is too old/not recognized.
 #endif
 
+/* Intel compiler defines __GNUC__. So we will overwrite implementations
+ * coming from above header files here
+ */
+#ifdef __INTEL_COMPILER
+# include <linux/compiler-intel.h>
+#endif
+
 /* 
  * Below are the generic compiler related macros required for kernel
  * build. Actual compiler/compiler version specific implementations 





[-- Attachment #2: compiler.h.diff --]
[-- Type: application/octet-stream, Size: 7448 bytes --]

diff -Nru linux/include/linux/compiler-gcc+.h linux-/include/linux/compiler-gcc+.h
--- linux/include/linux/compiler-gcc+.h	Wed Dec 31 16:00:00 1969
+++ linux-/include/linux/compiler-gcc+.h	Tue Sep  9 21:26:03 2003
@@ -0,0 +1,14 @@
+/* Never include this file directly.  Include <linux/compiler.h> instead.  */
+
+/*
+ * These definitions are for Ueber-GCC: always newer than the latest
+ * version and hence sporting everything plus a kitchen-sink.
+ */
+#include <linux/compiler-gcc.h>
+
+#define inline			__inline__ __attribute__((always_inline))
+#define __inline__		__inline__ __attribute__((always_inline))
+#define __inline		__inline__ __attribute__((always_inline))
+#define __deprecated		__attribute__((deprecated))
+#define __attribute_used__	__attribute__((__used__))
+#define __attribute_pure__	__attribute__((pure))
diff -Nru linux/include/linux/compiler-gcc.h linux-/include/linux/compiler-gcc.h
--- linux/include/linux/compiler-gcc.h	Wed Dec 31 16:00:00 1969
+++ linux-/include/linux/compiler-gcc.h	Tue Sep  9 21:26:03 2003
@@ -0,0 +1,17 @@
+/* Never include this file directly.  Include <linux/compiler.h> instead.  */
+
+/*
+ * Common definitions for all gcc versions go here.
+ */
+
+
+/* Optimization barrier */
+/* The "volatile" is due to gcc bugs */
+#define barrier() __asm__ __volatile__("": : :"memory")
+
+/* This macro obfuscates arithmetic on a variable address so that gcc
+   shouldn't recognize the original var, and make assumptions about it */
+#define RELOC_HIDE(ptr, off)					\
+  ({ unsigned long __ptr;					\
+    __asm__ ("" : "=g"(__ptr) : "0"(ptr));		\
+    (typeof(ptr)) (__ptr + (off)); })
diff -Nru linux/include/linux/compiler-gcc2.h linux-/include/linux/compiler-gcc2.h
--- linux/include/linux/compiler-gcc2.h	Wed Dec 31 16:00:00 1969
+++ linux-/include/linux/compiler-gcc2.h	Tue Sep  9 21:26:03 2003
@@ -0,0 +1,23 @@
+/* Never include this file directly.  Include <linux/compiler.h> instead.  */
+
+/* These definitions are for GCC v2.x.  */
+
+/* Somewhere in the middle of the GCC 2.96 development cycle, we implemented
+   a mechanism by which the user can annotate likely branch directions and
+   expect the blocks to be reordered appropriately.  Define __builtin_expect
+   to nothing for earlier compilers.  */
+#include <linux/compiler-gcc.h>
+
+#if __GNUC_MINOR__ < 96
+# define __builtin_expect(x, expected_value) (x)
+#endif
+
+#define __attribute_used__	__attribute__((__unused__))
+
+/*
+ * The attribute `pure' is not implemented in GCC versions earlier
+ * than 2.96.
+ */
+#if __GNUC_MINOR__ >= 96
+# define __attribute_pure__	__attribute__((pure))
+#endif
diff -Nru linux/include/linux/compiler-gcc3.h linux-/include/linux/compiler-gcc3.h
--- linux/include/linux/compiler-gcc3.h	Wed Dec 31 16:00:00 1969
+++ linux-/include/linux/compiler-gcc3.h	Tue Sep  9 21:26:03 2003
@@ -0,0 +1,22 @@
+/* Never include this file directly.  Include <linux/compiler.h> instead.  */
+
+/* These definitions are for GCC v3.x.  */
+#include <linux/compiler-gcc.h>
+
+#if __GNUC_MINOR__ >= 1
+# define inline		__inline__ __attribute__((always_inline))
+# define __inline__	__inline__ __attribute__((always_inline))
+# define __inline	__inline__ __attribute__((always_inline))
+#endif
+
+#if __GNUC_MINOR__ > 0
+# define __deprecated	__attribute__((deprecated))
+#endif
+
+#if __GNUC_MINOR__ >= 3
+# define __attribute_used__	__attribute__((__used__))
+#else
+# define __attribute_used__	__attribute__((__unused__))
+#endif
+
+#define __attribute_pure__	__attribute__((pure))
diff -Nru linux/include/linux/compiler.h linux-/include/linux/compiler.h
--- linux/include/linux/compiler.h	Mon Sep  8 11:51:00 2003
+++ linux-/include/linux/compiler.h	Tue Sep  9 21:32:44 2003
@@ -2,28 +2,28 @@
 #define __LINUX_COMPILER_H
 
 #ifdef __CHECKER__
-  #define __user	__attribute__((noderef, address_space(1)))
-  #define __kernel	/* default address space */
+# define __user		__attribute__((noderef, address_space(1)))
+# define __kernel	/* default address space */
 #else
-  #define __user
-  #define __kernel
+# define __user
+# define __kernel
 #endif
 
-#if (__GNUC__ > 3) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1)
-#define inline		__inline__ __attribute__((always_inline))
-#define __inline__	__inline__ __attribute__((always_inline))
-#define __inline	__inline__ __attribute__((always_inline))
-#endif
-
-/* Somewhere in the middle of the GCC 2.96 development cycle, we implemented
-   a mechanism by which the user can annotate likely branch directions and
-   expect the blocks to be reordered appropriately.  Define __builtin_expect
-   to nothing for earlier compilers.  */
-
-#if __GNUC__ == 2 && __GNUC_MINOR__ < 96
-#define __builtin_expect(x, expected_value) (x)
+#if __GNUC__ > 3
+# include <linux/compiler-gcc+.h>	/* catch-all for GCC 4, 5, etc. */
+#elif __GNUC__ == 3
+# include <linux/compiler-gcc3.h>
+#elif __GNUC__ == 2
+# include <linux/compiler-gcc2.h>
+#else
+# error Sorry, your compiler is too old/not recognized.
 #endif
 
+/* 
+ * Below are the generic compiler related macros required for kernel
+ * build. Actual compiler/compiler version specific implementations 
+ * come from the above header files
+ */
 #define likely(x)	__builtin_expect(!!(x), 1)
 #define unlikely(x)	__builtin_expect(!!(x), 0)
 
@@ -33,10 +33,8 @@
  * Usage is:
  * 		int __deprecated foo(void)
  */
-#if ( __GNUC__ == 3 && __GNUC_MINOR__ > 0 ) || __GNUC__ > 3
-#define __deprecated	__attribute__((deprecated))
-#else
-#define __deprecated
+#ifndef __deprecated
+# define __deprecated		/* unimplemented */
 #endif
 
 /*
@@ -50,10 +48,8 @@
  * In prior versions of gcc, such functions and data would be emitted, but
  * would be warned about except with attribute((unused)).
  */
-#if __GNUC__ == 3 && __GNUC_MINOR__ >= 3 || __GNUC__ > 3
-#define __attribute_used__	__attribute__((__used__))
-#else
-#define __attribute_used__	__attribute__((__unused__))
+#ifndef __attribute_used__
+# define __attribute_used__	/* unimplemented */
 #endif
 
 /*
@@ -65,19 +61,21 @@
  * elimination and loop optimization just as an arithmetic operator
  * would be.
  * [...]
- * The attribute `pure' is not implemented in GCC versions earlier
- * than 2.96.
  */
-#if (__GNUC__ == 2 && __GNUC_MINOR__ >= 96) || __GNUC__ > 2
-#define __attribute_pure__	__attribute__((pure))
-#else
-#define __attribute_pure__	/* unimplemented */
+#ifndef __attribute_pure__
+# define __attribute_pure__	/* unimplemented */
+#endif
+
+/* Optimization barrier */
+#ifndef barrier
+# define barrier() __memory_barrier();
 #endif
 
-/* This macro obfuscates arithmetic on a variable address so that gcc
-   shouldn't recognize the original var, and make assumptions about it */
-#define RELOC_HIDE(ptr, off)					\
+#ifndef RELOC_HIDE
+# define RELOC_HIDE(ptr, off)					\
   ({ unsigned long __ptr;					\
-    __asm__ ("" : "=g"(__ptr) : "0"(ptr));		\
+     __ptr = (unsigned long) (ptr);				\
     (typeof(ptr)) (__ptr + (off)); })
+#endif
+
 #endif /* __LINUX_COMPILER_H */
diff -Nru linux/include/linux/kernel.h linux-/include/linux/kernel.h
--- linux/include/linux/kernel.h	Mon Sep  8 11:51:01 2003
+++ linux-/include/linux/kernel.h	Tue Sep  9 21:26:03 2003
@@ -15,10 +15,6 @@
 #include <asm/byteorder.h>
 #include <asm/bug.h>
 
-/* Optimization barrier */
-/* The "volatile" is due to gcc bugs */
-#define barrier() __asm__ __volatile__("": : :"memory")
-
 #define INT_MAX		((int)(~0U>>1))
 #define INT_MIN		(-INT_MAX - 1)
 #define UINT_MAX	(~0U)

[-- Attachment #3: intel.diff --]
[-- Type: application/octet-stream, Size: 1310 bytes --]

diff -Nru linux/include/linux/compiler-intel.h linux-/include/linux/compiler-intel.h
--- linux/include/linux/compiler-intel.h	Wed Dec 31 16:00:00 1969
+++ linux-/include/linux/compiler-intel.h	Tue Sep  9 21:34:19 2003
@@ -0,0 +1,21 @@
+/* Never include this file directly.  Include <linux/compiler.h> instead.  */
+
+#ifdef __ECC
+
+/* Some compiler specific definitions are overwritten here
+ * for Intel ECC compiler 
+ */
+
+#include <asm/intrinsics.h>
+
+#undef barrier
+#undef RELOC_HIDE
+
+#define barrier() __memory_barrier()
+
+#define RELOC_HIDE(ptr, off)					\
+  ({ unsigned long __ptr;					\
+     __ptr = (unsigned long) (ptr);				\
+    (typeof(ptr)) (__ptr + (off)); })
+
+#endif
diff -Nru linux/include/linux/compiler.h linux-/include/linux/compiler.h
--- linux/include/linux/compiler.h	Tue Sep  9 21:34:11 2003
+++ linux-/include/linux/compiler.h	Tue Sep  9 21:35:08 2003
@@ -19,6 +19,13 @@
 # error Sorry, your compiler is too old/not recognized.
 #endif
 
+/* Intel compiler defines __GNUC__. So we will overwrite implementations
+ * coming from above header files here
+ */
+#ifdef __INTEL_COMPILER
+# include <linux/compiler-intel.h>
+#endif
+
 /* 
  * Below are the generic compiler related macros required for kernel
  * build. Actual compiler/compiler version specific implementations 

^ permalink raw reply	[flat|nested] 14+ messages in thread
* [Patch] asm workarounds in generic header files
@ 2003-09-09  1:04 Siddha, Suresh B
  2003-09-09  2:27 ` Jes Sorensen
  2003-09-09  6:40 ` Christoph Hellwig
  0 siblings, 2 replies; 14+ messages in thread
From: Siddha, Suresh B @ 2003-09-09  1:04 UTC (permalink / raw)
  To: Andrew Morton, Linus Torvalds, linux-kernel
  Cc: Nakajima, Jun, Mallick, Asit K

[-- Attachment #1: Type: text/plain, Size: 1742 bytes --]

Intel ecc compiler doesn't support inline assembly. 
Attached patch is required to enable linux kernel build with Intel ecc compiler.
Please apply.

thanks,
suresh

diff -Nru linux/include/linux/compiler.h linux-2.5/include/linux/compiler.h
--- linux/include/linux/compiler.h	Mon Sep  8 11:51:00 2003
+++ linux-2.5/include/linux/compiler.h	Mon Sep  8 13:22:13 2003
@@ -74,10 +74,26 @@
 #define __attribute_pure__	/* unimplemented */
 #endif
 
+#if defined(__INTEL_COMPILER) && defined(__ECC)
+/* Optimization barrier */
+#include <asm/intrinsics.h>
+#define barrier()	__memory_barrier()
+
+#define RELOC_HIDE(ptr, off)					\
+  ({ unsigned long __ptr;					\
+     __ptr = (unsigned long) (ptr);				\
+    (typeof(ptr)) (__ptr + (off)); })
+#else
+/* Optimization barrier */
+/* The "volatile" is due to gcc bugs */
+#define barrier()	asm volatile ("":::"memory")
+
 /* This macro obfuscates arithmetic on a variable address so that gcc
    shouldn't recognize the original var, and make assumptions about it */
 #define RELOC_HIDE(ptr, off)					\
   ({ unsigned long __ptr;					\
     __asm__ ("" : "=g"(__ptr) : "0"(ptr));		\
     (typeof(ptr)) (__ptr + (off)); })
+#endif
+
 #endif /* __LINUX_COMPILER_H */
diff -Nru linux/include/linux/kernel.h linux-2.5/include/linux/kernel.h
--- linux/include/linux/kernel.h	Mon Sep  8 11:51:01 2003
+++ linux-2.5/include/linux/kernel.h	Mon Sep  8 12:06:14 2003
@@ -15,10 +15,6 @@
 #include <asm/byteorder.h>
 #include <asm/bug.h>
 
-/* Optimization barrier */
-/* The "volatile" is due to gcc bugs */
-#define barrier() __asm__ __volatile__("": : :"memory")
-
 #define INT_MAX		((int)(~0U>>1))
 #define INT_MIN		(-INT_MAX - 1)
 #define UINT_MAX	(~0U)

[-- Attachment #2: asm.patch --]
[-- Type: application/octet-stream, Size: 1526 bytes --]

diff -Nru linux/include/linux/compiler.h linux-2.5/include/linux/compiler.h
--- linux/include/linux/compiler.h	Mon Sep  8 11:51:00 2003
+++ linux-2.5/include/linux/compiler.h	Mon Sep  8 13:22:13 2003
@@ -74,10 +74,26 @@
 #define __attribute_pure__	/* unimplemented */
 #endif
 
+#if defined(__INTEL_COMPILER) && defined(__ECC)
+/* Optimization barrier */
+#include <asm/intrinsics.h>
+#define barrier()	__memory_barrier()
+
+#define RELOC_HIDE(ptr, off)					\
+  ({ unsigned long __ptr;					\
+     __ptr = (unsigned long) (ptr);				\
+    (typeof(ptr)) (__ptr + (off)); })
+#else
+/* Optimization barrier */
+/* The "volatile" is due to gcc bugs */
+#define barrier()	asm volatile ("":::"memory")
+
 /* This macro obfuscates arithmetic on a variable address so that gcc
    shouldn't recognize the original var, and make assumptions about it */
 #define RELOC_HIDE(ptr, off)					\
   ({ unsigned long __ptr;					\
     __asm__ ("" : "=g"(__ptr) : "0"(ptr));		\
     (typeof(ptr)) (__ptr + (off)); })
+#endif
+
 #endif /* __LINUX_COMPILER_H */
diff -Nru linux/include/linux/kernel.h linux-2.5/include/linux/kernel.h
--- linux/include/linux/kernel.h	Mon Sep  8 11:51:01 2003
+++ linux-2.5/include/linux/kernel.h	Mon Sep  8 12:06:14 2003
@@ -15,10 +15,6 @@
 #include <asm/byteorder.h>
 #include <asm/bug.h>
 
-/* Optimization barrier */
-/* The "volatile" is due to gcc bugs */
-#define barrier() __asm__ __volatile__("": : :"memory")
-
 #define INT_MAX		((int)(~0U>>1))
 #define INT_MIN		(-INT_MAX - 1)
 #define UINT_MAX	(~0U)

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2003-09-10 17:02 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-09-09 19:34 [Patch] asm workarounds in generic header files Siddha, Suresh B
2003-09-09 19:51 ` Jes Sorensen
2003-09-09 20:25   ` David Mosberger
2003-09-09 20:33     ` Linus Torvalds
2003-09-09 21:16       ` Sam Ravnborg
2003-09-09 23:44       ` David Mosberger
2003-09-10 16:22     ` Jes Sorensen
2003-09-10 17:02       ` David Mosberger
  -- strict thread matches above, loose matches on Subject: below --
2003-09-10  5:51 Nakajima, Jun
2003-09-10  4:50 Siddha, Suresh B
2003-09-10  5:08 ` Andrew Morton
2003-09-09  1:04 Siddha, Suresh B
2003-09-09  2:27 ` Jes Sorensen
2003-09-09  6:40 ` Christoph Hellwig

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox