summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTommi Rantala <tt.rantala@gmail.com>2012-09-19 12:39:26 +0300
committerTommi Rantala <tt.rantala@gmail.com>2012-09-28 14:51:19 +0300
commite3e49dc28aee0dc78f0243d932a5c950aaec7e3e (patch)
treefad8fb881296bb8169f064658385e5bd2ae3b15b
parent397f32a378d4b7acc962bf4a0056dca2197077dd (diff)
downloadlibunwind-e3e49dc28aee0dc78f0243d932a5c950aaec7e3e.tar.gz
Define and use `NOINLINE'
-rw-r--r--include/compiler.h2
-rw-r--r--tests/Gperf-simple.c7
-rw-r--r--tests/Gperf-trace.c7
-rw-r--r--tests/Ltest-varargs.c14
-rw-r--r--tests/crasher.c12
5 files changed, 23 insertions, 19 deletions
diff --git a/include/compiler.h b/include/compiler.h
index f519877c..e15f7a7e 100644
--- a/include/compiler.h
+++ b/include/compiler.h
@@ -33,6 +33,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
#ifdef __GNUC__
# define ALIGNED(x) __attribute__((aligned(x)))
# define UNUSED __attribute__((unused))
+# define NOINLINE __attribute__((noinline))
# define NORETURN __attribute__((noreturn))
# define ALIAS(name) __attribute__((alias (#name)))
# if (__GNUC__ > 3) || (__GNUC__ == 3 && __GNUC_MINOR__ > 2)
@@ -55,6 +56,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
# define ALIGNED(x)
# define ALWAYS_INLINE
# define UNUSED
+# define NOINLINE
# define NORETURN
# define ALIAS(name)
# define HIDDEN
diff --git a/tests/Gperf-simple.c b/tests/Gperf-simple.c
index ab46008d..21734066 100644
--- a/tests/Gperf-simple.c
+++ b/tests/Gperf-simple.c
@@ -27,6 +27,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
#include <unistd.h>
#include <libunwind.h>
+#include "compiler.h"
#include <sys/resource.h>
#include <sys/time.h>
@@ -53,7 +54,7 @@ gettime (void)
return tv.tv_sec + 1e-6*tv.tv_usec;
}
-static int __attribute__((noinline))
+static int NOINLINE
measure_unwind (int maxlevel, double *step)
{
double stop, start;
@@ -88,7 +89,7 @@ measure_unwind (int maxlevel, double *step)
static int f1 (int, int, double *);
-static int __attribute__((noinline))
+static int NOINLINE
g1 (int level, int maxlevel, double *step)
{
if (level == maxlevel)
@@ -98,7 +99,7 @@ g1 (int level, int maxlevel, double *step)
return f1 (level + 1, maxlevel, step) + level;
}
-static int __attribute__((noinline))
+static int NOINLINE
f1 (int level, int maxlevel, double *step)
{
if (level == maxlevel)
diff --git a/tests/Gperf-trace.c b/tests/Gperf-trace.c
index 7e95e66d..cc4fac68 100644
--- a/tests/Gperf-trace.c
+++ b/tests/Gperf-trace.c
@@ -27,6 +27,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
#include <unistd.h>
#include <libunwind.h>
+#include "compiler.h"
#include <sys/resource.h>
#include <sys/time.h>
@@ -53,7 +54,7 @@ gettime (void)
return tv.tv_sec + 1e-6*tv.tv_usec;
}
-static int __attribute__((noinline))
+static int NOINLINE
measure_unwind (int maxlevel, double *step)
{
double stop, start;
@@ -74,7 +75,7 @@ measure_unwind (int maxlevel, double *step)
static int f1 (int, int, double *);
-static int __attribute__((noinline))
+static int NOINLINE
g1 (int level, int maxlevel, double *step)
{
if (level == maxlevel)
@@ -84,7 +85,7 @@ g1 (int level, int maxlevel, double *step)
return f1 (level + 1, maxlevel, step) + level;
}
-static int __attribute__((noinline))
+static int NOINLINE
f1 (int level, int maxlevel, double *step)
{
if (level == maxlevel)
diff --git a/tests/Ltest-varargs.c b/tests/Ltest-varargs.c
index 603fb57b..dd12c86b 100644
--- a/tests/Ltest-varargs.c
+++ b/tests/Ltest-varargs.c
@@ -1,5 +1,7 @@
#define UNW_LOCAL_ONLY
#include <libunwind.h>
+#include "compiler.h"
+
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
@@ -9,12 +11,12 @@ int ok;
int verbose;
#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 3)
-void a (int, ...) __attribute__((noinline, optimize(0)));
-void b (void) __attribute__((noinline, optimize(0)));
-void c (void) __attribute__((noinline, optimize(0)));
+void a (int, ...) __attribute__((optimize(0)));
+void b (void) __attribute__((optimize(0)));
+void c (void) __attribute__((optimize(0)));
#endif
-void
+void NOINLINE
b (void)
{
void *v[20];
@@ -33,13 +35,13 @@ b (void)
printf ("[%d] %p\n", i, v[i]);
}
-void
+void NOINLINE
c (void)
{
b ();
}
-void
+void NOINLINE
a (int d, ...)
{
switch (d)
diff --git a/tests/crasher.c b/tests/crasher.c
index 9a005b9c..2cf65e8d 100644
--- a/tests/crasher.c
+++ b/tests/crasher.c
@@ -1,5 +1,7 @@
/* This program should crash and produce coredump */
+#include "compiler.h"
+
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
@@ -85,24 +87,20 @@ write_maps(char *fname)
#endif
#ifdef __GNUC__
-int a(void) __attribute__((noinline));
-int b(int x) __attribute__((noinline));
-int c(int x) __attribute__((noinline, alias("b")));
+int c(int x) NOINLINE __attribute__((alias("b")));
#define compiler_barrier() asm volatile("");
#else
-int a(void);
-int b(int x);
int c(int x);
#define compiler_barrier()
#endif
-int a(void)
+int NOINLINE a(void)
{
*(volatile int *)32 = 1;
return 1;
}
-int b(int x)
+int NOINLINE b(int x)
{
int r;