diff options
-rw-r--r-- | arch/x86/machine/boot.h | 8 | ||||
-rw-r--r-- | arch/x86/machine/param.h | 17 | ||||
-rw-r--r-- | lib/macros.h | 55 |
3 files changed, 46 insertions, 34 deletions
diff --git a/arch/x86/machine/boot.h b/arch/x86/machine/boot.h index 03e934ce..69b8f5a2 100644 --- a/arch/x86/machine/boot.h +++ b/arch/x86/machine/boot.h @@ -18,18 +18,20 @@ #ifndef _X86_BOOT_H #define _X86_BOOT_H +#include <lib/macros.h> + /* * The kernel is physically loaded at BOOT_OFFSET by the boot loader. It * will quickly establish the necessary mappings to run at KERNEL_OFFSET. * * See the linker script for more information. */ -#define BOOT_OFFSET 0x00100000 +#define BOOT_OFFSET DECL_CONST(0x100000, UL) #ifdef __LP64__ -#define KERNEL_OFFSET 0xffffffff80000000 +#define KERNEL_OFFSET DECL_CONST(0xffffffff80000000, UL) #else /* __LP64__ */ -#define KERNEL_OFFSET 0xc0000000 +#define KERNEL_OFFSET DECL_CONST(0xc0000000, UL) #endif /* __LP64__ */ /* diff --git a/arch/x86/machine/param.h b/arch/x86/machine/param.h index a03e1050..2b5553d7 100644 --- a/arch/x86/machine/param.h +++ b/arch/x86/machine/param.h @@ -19,6 +19,7 @@ #define _X86_PARAM_H #include <machine/boot.h> +#include <lib/macros.h> #define __LITTLE_ENDIAN__ @@ -42,8 +43,8 @@ /* * User space boundaries. */ -#define VM_MIN_ADDRESS 0UL -#define VM_MAX_ADDRESS (unsigned long)KERNEL_OFFSET +#define VM_MIN_ADDRESS DECL_CONST(0, UL) +#define VM_MAX_ADDRESS KERNEL_OFFSET /* * Kernel stack size for threads and interrupt handlers. @@ -54,9 +55,9 @@ * Size of a linear mapping of PTEs (see the pmap module). */ #ifdef PAE -#define VM_PMAP_PTEMAP_SIZE 0x800000UL +#define VM_PMAP_PTEMAP_SIZE DECL_CONST(0x800000, UL) #else /* PAE */ -#define VM_PMAP_PTEMAP_SIZE 0x400000UL +#define VM_PMAP_PTEMAP_SIZE DECL_CONST(0x400000, UL) #endif /* PAE */ /* @@ -94,15 +95,15 @@ * Segment boundaries. */ #ifdef PAE -#define VM_PHYS_NORMAL_LIMIT 0x100000000ULL -#define VM_PHYS_HIGHMEM_LIMIT 0x1000000000ULL +#define VM_PHYS_NORMAL_LIMIT DECL_CONST(0x100000000, ULL) +#define VM_PHYS_HIGHMEM_LIMIT DECL_CONST(0x1000000000, ULL) #else /* PAE */ -#define VM_PHYS_NORMAL_LIMIT 0xfffff000UL +#define VM_PHYS_NORMAL_LIMIT DECL_CONST(0xfffff000, UL) #endif /* PAE */ /* * Virtual space reserved for kernel map entries. */ -#define VM_MAP_KENTRY_SIZE 0x800000UL +#define VM_MAP_KENTRY_SIZE DECL_CONST(0x800000, UL) #endif /* _X86_PARAM_H */ diff --git a/lib/macros.h b/lib/macros.h index ca6379ac..4894a335 100644 --- a/lib/macros.h +++ b/lib/macros.h @@ -21,42 +21,51 @@ #ifndef _LIB_MACROS_H #define _LIB_MACROS_H +#ifndef __ASSEMBLY__ #include <lib/stddef.h> +#endif /* __ASSEMBLY__ */ -#define MACRO_BEGIN ({ -#define MACRO_END }) +#define MACRO_BEGIN ({ +#define MACRO_END }) -#define XQUOTE(x) #x -#define QUOTE(x) XQUOTE(x) +#define XQUOTE(x) #x +#define QUOTE(x) XQUOTE(x) -#define STRLEN(x) (sizeof(x) - 1) -#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) +#ifdef __ASSEMBLY__ +#define DECL_CONST(x, s) x +#else /* __ASSEMBLY__ */ +#define __DECL_CONST(x, s) x##s +#define DECL_CONST(x, s) __DECL_CONST(x, s) +#endif /* __ASSEMBLY__ */ -#define MIN(a, b) ((a) < (b) ? (a) : (b)) -#define MAX(a, b) ((a) > (b) ? (a) : (b)) +#define STRLEN(x) (sizeof(x) - 1) +#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)) -#define P2ROUND(x, a) (-(-(x) & -(a))) -#define P2END(x, a) (-(~(x) & -(a))) +#define MIN(a, b) ((a) < (b) ? (a) : (b)) +#define MAX(a, b) ((a) > (b) ? (a) : (b)) + +#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 alignof(x) __alignof__(x) -#define likely(expr) __builtin_expect(!!(expr), 1) -#define unlikely(expr) __builtin_expect(!!(expr), 0) +#define likely(expr) __builtin_expect(!!(expr), 1) +#define unlikely(expr) __builtin_expect(!!(expr), 0) -#define barrier() asm volatile("" : : : "memory") +#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 __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))) |