diff options
author | Justus Winter <4winter@informatik.uni-hamburg.de> | 2015-04-07 18:01:06 +0200 |
---|---|---|
committer | Justus Winter <4winter@informatik.uni-hamburg.de> | 2015-04-07 18:01:06 +0200 |
commit | 3c93520fe3db24434b4e3b32a75c72dc16db6dda (patch) | |
tree | ae756f9f464439bcf685ae81250bd4ce63ec3ab0 /debian/patches/0001-kern-import-macros.h-from-x15.patch | |
parent | cdcfc6bd47fedfb62ba68ea3ad3166c78cfc6e46 (diff) |
add patch series
Diffstat (limited to 'debian/patches/0001-kern-import-macros.h-from-x15.patch')
-rw-r--r-- | debian/patches/0001-kern-import-macros.h-from-x15.patch | 194 |
1 files changed, 194 insertions, 0 deletions
diff --git a/debian/patches/0001-kern-import-macros.h-from-x15.patch b/debian/patches/0001-kern-import-macros.h-from-x15.patch new file mode 100644 index 0000000..4750e3e --- /dev/null +++ b/debian/patches/0001-kern-import-macros.h-from-x15.patch @@ -0,0 +1,194 @@ +From c95b4f4fdc90f14123e6d14c23c4c2a25d32f74f Mon Sep 17 00:00:00 2001 +From: Justus Winter <4winter@informatik.uni-hamburg.de> +Date: Tue, 31 Mar 2015 12:57:05 +0200 +Subject: [PATCH gnumach 1/7] kern: import `macros.h' from x15 + +Import the macro definitions from the x15 kernel project, and replace +all similar definitions littered all over the place with it. + +Importing this file will make importing code from the x15 kernel +easier. We are already using the red-black tree implementation and +the slab allocator from it, and we will import even more code in the +near future. + +* Makefrag.am (libkernel_a_SOURCES): Add new file. +* kern/list.h: Do not define `structof', include `macros.h' instead. +* kern/rbtree.h: Likewise. +* kern/slab.c: Do not define `ARRAY_SIZE', include `macros.h' instead. +* i386/grub/misc.h: Likewise. +* kern/macros.h: New file. +--- + Makefrag.am | 1 + + i386/grub/misc.h | 2 +- + kern/list.h | 4 +--- + kern/macros.h | 71 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + kern/rbtree.h | 5 +--- + kern/slab.c | 2 +- + 6 files changed, 76 insertions(+), 9 deletions(-) + create mode 100644 kern/macros.h + +diff --git a/Makefrag.am b/Makefrag.am +index 9166143..77110c8 100644 +--- a/Makefrag.am ++++ b/Makefrag.am +@@ -172,6 +172,7 @@ libkernel_a_SOURCES += \ + kern/machine.c \ + kern/machine.h \ + kern/macro_help.h \ ++ kern/macros.h \ + kern/pc_sample.c \ + kern/pc_sample.h \ + kern/printf.c \ +diff --git a/i386/grub/misc.h b/i386/grub/misc.h +index c6cd456..b71140a 100644 +--- a/i386/grub/misc.h ++++ b/i386/grub/misc.h +@@ -21,6 +21,7 @@ + #define GRUB_MISC_HEADER 1 + + #include <stdarg.h> ++#include <kern/macros.h> + #include <grub/types.h> + #include <grub/symbol.h> + #include <grub/err.h> +@@ -32,7 +33,6 @@ + #define ALIGN_UP_OVERHEAD(addr, align) ((-(addr)) & ((typeof (addr)) (align) - 1)) + #define ALIGN_DOWN(addr, align) \ + ((addr) & ~((typeof (addr)) align - 1)) +-#define ARRAY_SIZE(array) (sizeof (array) / sizeof (array[0])) + #define COMPILE_TIME_ASSERT(cond) switch (0) { case 1: case !(cond): ; } + + #define grub_dprintf(condition, ...) grub_real_dprintf(GRUB_FILE, __LINE__, condition, __VA_ARGS__) +diff --git a/kern/list.h b/kern/list.h +index ad782a8..be92762 100644 +--- a/kern/list.h ++++ b/kern/list.h +@@ -31,9 +31,7 @@ + + #include <stddef.h> + #include <sys/types.h> +- +-#define structof(ptr, type, member) \ +- ((type *)((char *)ptr - offsetof(type, member))) ++#include <kern/macros.h> + + /* + * Structure used as both head and node. +diff --git a/kern/macros.h b/kern/macros.h +new file mode 100644 +index 0000000..db38842 +--- /dev/null ++++ b/kern/macros.h +@@ -0,0 +1,71 @@ ++/* ++ * Copyright (c) 2009, 2010, 2013 Richard Braun. ++ * ++ * This program is free software: you can redistribute it and/or modify ++ * it under the terms of the GNU General Public License as published by ++ * the Free Software Foundation, either version 3 of the License, or ++ * (at your option) any later version. ++ * ++ * This program is distributed in the hope that it will be useful, ++ * but WITHOUT ANY WARRANTY; without even the implied warranty of ++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++ * GNU General Public License for more details. ++ * ++ * You should have received a copy of the GNU General Public License ++ * along with this program. If not, see <http://www.gnu.org/licenses/>. ++ * ++ * ++ * Helper macros. ++ */ ++ ++#ifndef _KERN_MACROS_H ++#define _KERN_MACROS_H ++ ++#define MACRO_BEGIN ({ ++#define MACRO_END }) ++ ++#define __QUOTE(x) #x ++#define QUOTE(x) __QUOTE(x) ++ ++#ifdef __ASSEMBLER__ ++#define DECL_CONST(x, s) x ++#else /* __ASSEMBLER__ */ ++#define __DECL_CONST(x, s) x##s ++#define DECL_CONST(x, s) __DECL_CONST(x, s) ++#endif /* __ASSEMBLER__ */ ++ ++#define STRLEN(x) (sizeof(x) - 1) ++#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) ++ ++#define MIN(a, b) ((a) < (b) ? (a) : (b)) ++#define MAX(a, b) ((a) > (b) ? (a) : (b)) ++ ++#define DIV_CEIL(n, d) (((n) + (d) - 1) / (d)) ++ ++#define P2ALIGNED(x, a) (((x) & ((a) - 1)) == 0) ++#define ISP2(x) P2ALIGNED(x, x) ++#define P2ALIGN(x, a) ((x) & -(a)) ++#define P2ROUND(x, a) (-(-(x) & -(a))) ++#define P2END(x, a) (-(~(x) & -(a))) ++ ++#define structof(ptr, type, member) \ ++ ((type *)((char *)(ptr) - offsetof(type, member))) ++ ++#define alignof(x) __alignof__(x) ++ ++#define likely(expr) __builtin_expect(!!(expr), 1) ++#define unlikely(expr) __builtin_expect(!!(expr), 0) ++ ++#define barrier() asm volatile("" : : : "memory") ++ ++#define __noreturn __attribute__((noreturn)) ++#define __aligned(x) __attribute__((aligned(x))) ++#define __always_inline inline __attribute__((always_inline)) ++#define __section(x) __attribute__((section(x))) ++#define __packed __attribute__((packed)) ++#define __alias(x) __attribute__((alias(x))) ++ ++#define __format_printf(fmt, args) \ ++ __attribute__((format(printf, fmt, args))) ++ ++#endif /* _KERN_MACROS_H */ +diff --git a/kern/rbtree.h b/kern/rbtree.h +index f577f7e..4ee0e15 100644 +--- a/kern/rbtree.h ++++ b/kern/rbtree.h +@@ -31,12 +31,9 @@ + + #include <stddef.h> + #include <kern/assert.h> +-#include <kern/macro_help.h> ++#include <kern/macros.h> + #include <sys/types.h> + +-#define structof(ptr, type, member) \ +- ((type *)((char *)ptr - offsetof(type, member))) +- + /* + * Indexes of the left and right nodes in the children array of a node. + */ +diff --git a/kern/slab.c b/kern/slab.c +index 19ebfed..60378b5 100644 +--- a/kern/slab.c ++++ b/kern/slab.c +@@ -79,6 +79,7 @@ + #include <string.h> + #include <kern/assert.h> + #include <kern/mach_clock.h> ++#include <kern/macros.h> + #include <kern/printf.h> + #include <kern/slab.h> + #include <kern/kalloc.h> +@@ -96,7 +97,6 @@ + /* + * Utility macros. + */ +-#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) + #define P2ALIGNED(x, a) (((x) & ((a) - 1)) == 0) + #define ISP2(x) P2ALIGNED(x, x) + #define P2ALIGN(x, a) ((x) & -(a)) +-- +2.1.4 + |