]> git.hungrycats.org Git - linux/commitdiff
ia64: If the compiler supports it, use attribute (model (small)) to
authorDavid Mosberger <davidm@tiger.hpl.hp.com>
Wed, 16 Jul 2003 12:44:13 +0000 (05:44 -0700)
committerDavid Mosberger <davidm@tiger.hpl.hp.com>
Wed, 16 Jul 2003 12:44:13 +0000 (05:44 -0700)
tell the compiler that per-CPU variables can be addressed
with "addl".

On the simulator kernel, this saves about 2776 bytes in the
kernel image.  On a zx1 kernel, it saves about 5593 bytes.
As per-CPU variables are used more, these savings will
increase, of course.

arch/ia64/scripts/check-model.c [new file with mode: 0644]
arch/ia64/scripts/toolchain-flags
include/asm-ia64/percpu.h

diff --git a/arch/ia64/scripts/check-model.c b/arch/ia64/scripts/check-model.c
new file mode 100644 (file)
index 0000000..e1d4e86
--- /dev/null
@@ -0,0 +1 @@
+int __attribute__ ((__model__ (__small__))) x;
index 4867bbb21e2caa5e439f23e3012d5625409cece8..6a59cd4cb74836209d6ffa088e17abf5de22d9be 100755 (executable)
@@ -2,6 +2,7 @@
 #
 # Check whether linker can handle cross-segment @segrel():
 #
+CPPFLAGS=""
 CC=$1
 OBJDUMP=$2
 dir=$(dirname $0)
@@ -11,10 +12,17 @@ $CC -nostdlib -static -Wl,-T$dir/check-segrel.lds $dir/check-segrel.S -o $out
 res=$($OBJDUMP --full --section .rodata $out | fgrep 000 | cut -f3 -d' ')
 rm -f $out
 if [ $res != 00000a00 ]; then
-    echo " -DHAVE_BUGGY_SEGREL"
+    CPPFLAGS="$CPPFLAGS -DHAVE_BUGGY_SEGREL"
     cat >&2 <<EOF
 warning: your linker cannot handle cross-segment segment-relative relocations.
          please upgrade to a newer version (it is safe to use this linker, but
          the kernel will be bigger than strictly necessary).
 EOF
 fi
+
+if ! $CC -c $dir/check-model.c -o $out | grep -q 'attribute directive ignored'
+then
+    CPPFLAGS="$CPPFLAGS -DHAVE_MODEL_SMALL_ATTRIBUTE"
+fi
+rm -f $out
+echo $CPPFLAGS
index 2fc53d7e9f64ba548d7421c553ec4d2179c2021c..b0980ac007234cccc662b676cc6856aa061622f6 100644 (file)
 
 #include <linux/threads.h>
 
-#define DECLARE_PER_CPU(type, name) extern __typeof__(type) per_cpu__##name
+#ifdef HAVE_MODEL_SMALL_ATTRIBUTE
+# define __SMALL_ADDR_AREA     __attribute__((__model__ (__small__)))
+#else
+# define __SMALL_ADDR_AREA
+#endif
+
+#define DECLARE_PER_CPU(type, name)                            \
+       extern __SMALL_ADDR_AREA __typeof__(type) per_cpu__##name
 
 /* Separate out the type, so (int[3], foo) works. */
-#define DEFINE_PER_CPU(type, name) \
-    __attribute__((__section__(".data.percpu"))) __typeof__(type) per_cpu__##name
+#define DEFINE_PER_CPU(type, name)                             \
+       __attribute__((__section__(".data.percpu")))            \
+       __SMALL_ADDR_AREA __typeof__(type) per_cpu__##name
 
 /*
  * Pretty much a literal copy of asm-generic/percpu.h, except that percpu_modcopy() is an