aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndi Kleen <ak@linux.intel.com>2009-07-14 09:35:36 +0200
committerAndi Kleen <ak@linux.intel.com>2009-07-14 09:35:36 +0200
commitc6141beb1ab26dfd57696f2722b612921b35f09c (patch)
tree5da76b4b75a8eacada7ac9b87828ec9393ec434f
parentef2399d87f88bdf3385379ccd6e953f343a24776 (diff)
downloadmce-test-c6141beb1ab26dfd57696f2722b612921b35f09c.tar.gz
Fix compilation of tcases/ttable with recent kernel
It was too difficult to compile with kernel includes, so add a hierarchy of fake kernel includes to stub out kernel functions. Signed-off-by: Andi Kleen <ak@linux.intel.com>
-rw-r--r--tsrc/Makefile6
-rw-r--r--tsrc/kinclude/README3
-rw-r--r--tsrc/kinclude/linux/debugfs.h15
-rw-r--r--tsrc/kinclude/linux/fs.h10
-rw-r--r--tsrc/kinclude/linux/init.h5
-rw-r--r--tsrc/kinclude/linux/percpu.h9
-rw-r--r--tsrc/kinclude/linux/seq_file.h22
-rw-r--r--tsrc/kinclude/linux/sysdev.h2
-rw-r--r--tsrc/tcases.c2
-rw-r--r--tsrc/ttable.c2
10 files changed, 72 insertions, 4 deletions
diff --git a/tsrc/Makefile b/tsrc/Makefile
index 3064559..b72d395 100644
--- a/tsrc/Makefile
+++ b/tsrc/Makefile
@@ -3,6 +3,8 @@ BROWSER := links -g
CFLAGS += -I ${LSRC}/arch/x86/kernel/cpu/mcheck/ -g -Wall
+KFLAGS := -I ./kinclude
+
all: standalone
standalone: tinjpage tinjpage-working tkillpoison
@@ -10,10 +12,10 @@ standalone: tinjpage tinjpage-working tkillpoison
requireskernel: tcases ttable
tcases: tcases.c ${LSRC}/arch/x86/kernel/cpu/mcheck/mce-severity.c ${LSRC}/arch/x86/kernel/cpu/mcheck/mce-internal.h
- ${CC} ${CFLAGS} -o tcases tcases.c
+ ${CC} ${CFLAGS} ${KFLAGS} -o tcases tcases.c
ttable: ttable.c ${LSRC}/arch/x86/kernel/cpu/mcheck/mce-severity.c ${LSRC}/arch/x86/kernel/cpu/mcheck/mce-internal.h
- ${CC} ${CFLAGS} -o ttable ttable.c
+ ${CC} ${CFLAGS} ${KFLAGS} -o ttable ttable.c
x.html: ttable
./ttable ${TFLAGS} > x.html
diff --git a/tsrc/kinclude/README b/tsrc/kinclude/README
new file mode 100644
index 0000000..4521cd1
--- /dev/null
+++ b/tsrc/kinclude/README
@@ -0,0 +1,3 @@
+
+Fake kernel includes to build some kernel code in user context.
+
diff --git a/tsrc/kinclude/linux/debugfs.h b/tsrc/kinclude/linux/debugfs.h
new file mode 100644
index 0000000..a366984
--- /dev/null
+++ b/tsrc/kinclude/linux/debugfs.h
@@ -0,0 +1,15 @@
+
+static inline struct dentry *debugfs_create_file(const char *name, mode_t mode,
+ struct dentry *parent, void *data,
+ const struct file_operations *fops)
+{
+ return NULL;
+}
+
+static inline struct dentry *debugfs_create_dir(const char *name, struct dentry *parent)
+{
+ return NULL;
+}
+
+
+static inline void debugfs_remove(struct dentry *dentry) { }
diff --git a/tsrc/kinclude/linux/fs.h b/tsrc/kinclude/linux/fs.h
new file mode 100644
index 0000000..964b343
--- /dev/null
+++ b/tsrc/kinclude/linux/fs.h
@@ -0,0 +1,10 @@
+struct inode;
+struct file;
+struct dentry;
+
+struct file_operations {
+ ssize_t (*read) (struct file *, char *, size_t, loff_t *);
+ int (*open) (struct inode *, struct file *);
+ int (*release) (struct inode *, struct file *);
+ ssize_t (*write) (struct file *, const char *, size_t, loff_t *);
+};
diff --git a/tsrc/kinclude/linux/init.h b/tsrc/kinclude/linux/init.h
new file mode 100644
index 0000000..77cd3ac
--- /dev/null
+++ b/tsrc/kinclude/linux/init.h
@@ -0,0 +1,5 @@
+
+#define __init
+#define __user
+
+#define late_initcall(x) typeof(x) x __attribute__((used))
diff --git a/tsrc/kinclude/linux/percpu.h b/tsrc/kinclude/linux/percpu.h
new file mode 100644
index 0000000..55b111a
--- /dev/null
+++ b/tsrc/kinclude/linux/percpu.h
@@ -0,0 +1,9 @@
+
+#define DECLARE_PER_CPU(x,y)
+#define BITS_PER_LONG (sizeof(long)*8)
+#define DECLARE_BITMAP(x,y) unsigned long x[((y) + BITS_PER_LONG - 1) / BITS_PER_LONG];
+#define MAX_NR_BANKS 32
+#define ARRAY_SIZE(x) (sizeof(x) / sizeof(*(x)))
+
+struct cpuinfo_x86;
+
diff --git a/tsrc/kinclude/linux/seq_file.h b/tsrc/kinclude/linux/seq_file.h
new file mode 100644
index 0000000..9b0c9f3
--- /dev/null
+++ b/tsrc/kinclude/linux/seq_file.h
@@ -0,0 +1,22 @@
+
+#include <linux/fs.h>
+
+struct file;
+
+struct seq_file {
+};
+
+struct seq_operations {
+ void * (*start) (struct seq_file *m, loff_t *pos);
+ void (*stop) (struct seq_file *m, void *v);
+ void * (*next) (struct seq_file *m, void *v, loff_t *pos);
+ int (*show) (struct seq_file *m, void *v);
+};
+
+#define seq_printf(a, b, c...) printf(b , ## c)
+static inline int seq_open(struct file *f, const struct seq_operations *o) { return -1; }
+
+static inline ssize_t seq_read(struct file *a, char *b, size_t c, loff_t *d) { return 0; }
+static inline ssize_t seq_write(struct file *a, const char *b, size_t c, loff_t *d) { return 0; }
+static inline int seq_release(struct inode *a, struct file *b) { return 0; }
+
diff --git a/tsrc/kinclude/linux/sysdev.h b/tsrc/kinclude/linux/sysdev.h
new file mode 100644
index 0000000..a6d1cd8
--- /dev/null
+++ b/tsrc/kinclude/linux/sysdev.h
@@ -0,0 +1,2 @@
+
+struct sysdev_attribute {};
diff --git a/tsrc/tcases.c b/tsrc/tcases.c
index cd4c70b..13f473e 100644
--- a/tsrc/tcases.c
+++ b/tsrc/tcases.c
@@ -5,10 +5,10 @@
#define __KERNEL__ 1
#include <asm/types.h>
#include <asm/mce.h>
+#include <errno.h>
typedef unsigned long long u64;
-
#define MCI_STATUS_S (1ULL<<56) /* Signaled machine check */
#define MCI_STATUS_AR (1ULL<<55) /* Action required */
diff --git a/tsrc/ttable.c b/tsrc/ttable.c
index 82db752..792b07f 100644
--- a/tsrc/ttable.c
+++ b/tsrc/ttable.c
@@ -9,6 +9,7 @@
#include <string.h>
#include <assert.h>
#include <unistd.h>
+#include <errno.h>
#define __KERNEL__ 1
#include <asm/types.h>
#include <asm/mce.h>
@@ -67,7 +68,6 @@ struct bit {
struct mce basem;
-#define ARRAY_SIZE(x) (sizeof(x)/sizeof(*(x)))
#define bit_for_each(i,v) for (i = 0; i < 64; i++) if ((v) & (1ULL << i))
struct result {