From 923afb7df2ed231b06bcce448a1e7b36d949a846 Mon Sep 17 00:00:00 2001 From: Armin Luntzer <armin.luntzer@univie.ac.at> Date: Tue, 21 Feb 2017 14:08:03 +0100 Subject: [PATCH] add kernel/types.h for less cooperative compilers --- arch/sparc/include/asm/io.h | 2 +- arch/sparc/include/stack.h | 2 +- arch/sparc/include/stacktrace.h | 2 +- arch/sparc/include/traps.h | 2 +- include/kernel/ar.h | 2 +- include/kernel/bitops.h | 1 + include/kernel/elf.h | 3 +-- include/kernel/log2.h | 3 +-- include/kernel/sbrk.h | 2 +- include/kernel/sysctl.h | 2 +- include/kernel/types.h | 47 +++++++++++++++++++++++++++++++++ lib/sysctl.c | 1 - 12 files changed, 57 insertions(+), 12 deletions(-) create mode 100644 include/kernel/types.h diff --git a/arch/sparc/include/asm/io.h b/arch/sparc/include/asm/io.h index f4afa6e..8f13df2 100644 --- a/arch/sparc/include/asm/io.h +++ b/arch/sparc/include/asm/io.h @@ -19,7 +19,7 @@ #ifndef _ARCH_SPARC_ASM_IO_H_ #define _ARCH_SPARC_ASM_IO_H_ -#include <stdint.h> +#include <kernel/types.h> #include <uapi/asi.h> /* diff --git a/arch/sparc/include/stack.h b/arch/sparc/include/stack.h index 5f9c76e..42d013e 100644 --- a/arch/sparc/include/stack.h +++ b/arch/sparc/include/stack.h @@ -1,7 +1,7 @@ #ifndef _SPARC_STACK_H_ #define _SPARC_STACK_H_ -#include <stdint.h> +#include <kernel/types.h> /* reg window offset */ #define RW_L0 0x00 diff --git a/arch/sparc/include/stacktrace.h b/arch/sparc/include/stacktrace.h index 2609469..978f6aa 100644 --- a/arch/sparc/include/stacktrace.h +++ b/arch/sparc/include/stacktrace.h @@ -5,7 +5,7 @@ #ifndef _SPARC_STACKTRACE_H_ #define _SPARC_STACKTRACE_H_ -#include <stdint.h> +#include <kernel/types.h> #include <stack.h> struct stack_trace { diff --git a/arch/sparc/include/traps.h b/arch/sparc/include/traps.h index 1b80d59..fb45a41 100644 --- a/arch/sparc/include/traps.h +++ b/arch/sparc/include/traps.h @@ -20,7 +20,7 @@ #ifndef _ARCH_SPARC_TRAPS_H_ #define _ARCH_SPARC_TRAPS_H_ -#include <stdint.h> +#include <kernel/types.h> void trap_handler_install(uint32_t trap, void (*handler)(void)); diff --git a/include/kernel/ar.h b/include/kernel/ar.h index dde2a9d..a8334b2 100644 --- a/include/kernel/ar.h +++ b/include/kernel/ar.h @@ -1,7 +1,7 @@ #ifndef _KERNEL_AR_H_ #define _KERNEL_AR_H_ -#include <stdint.h> +#include <kernel/types.h> #define AR_MAG "!<arch>\n" /* AR MAGIC ID */ #define AR_FMAG "`\n" /* AR HDR END MAGIC */ diff --git a/include/kernel/bitops.h b/include/kernel/bitops.h index 43cc84a..404953e 100644 --- a/include/kernel/bitops.h +++ b/include/kernel/bitops.h @@ -7,6 +7,7 @@ #ifndef _KERNEL_BITOPS_H_ #define _KERNEL_BITOPS_H_ +#include <kernel/types.h> #ifndef __WORDSIZE #define __WORDSIZE (__SIZEOF_LONG__ * 8) diff --git a/include/kernel/elf.h b/include/kernel/elf.h index d51bde0..883eeae 100644 --- a/include/kernel/elf.h +++ b/include/kernel/elf.h @@ -2,8 +2,7 @@ #define _KERNEL_ELF_H_ -#include <stdint.h> -#include <stddef.h> +#include <kernel/types.h> /* some ELF constants&stuff ripped from include/uapi/linux/elf.h */ diff --git a/include/kernel/log2.h b/include/kernel/log2.h index 4cc8dc5..1d65d0d 100644 --- a/include/kernel/log2.h +++ b/include/kernel/log2.h @@ -16,8 +16,7 @@ #ifndef _KERNEL_LOG2_H_ #define _KERNEL_LOG2_H_ -#include <stdint.h> -#include <stdbool.h> +#include <kernel/types.h> /** * fls - find last (most-significant) bit set diff --git a/include/kernel/sbrk.h b/include/kernel/sbrk.h index b4a97bc..2612c95 100644 --- a/include/kernel/sbrk.h +++ b/include/kernel/sbrk.h @@ -5,7 +5,7 @@ #ifndef _KERNEL_SBRK_H_ #define _KERNEL_SBRK_H_ -#include <stdint.h> +#include <kernel/types.h> void *kernel_sbrk(intptr_t increment); diff --git a/include/kernel/sysctl.h b/include/kernel/sysctl.h index d24ea07..5b330f6 100644 --- a/include/kernel/sysctl.h +++ b/include/kernel/sysctl.h @@ -5,7 +5,7 @@ #ifndef _KERNEL_SYSCTL_H_ #define _KERNEL_SYSCTL_H_ -#include <sys/types.h> +#include <kernel/types.h> #include <list.h> #include <kernel/kernel.h> diff --git a/include/kernel/types.h b/include/kernel/types.h new file mode 100644 index 0000000..4463c12 --- /dev/null +++ b/include/kernel/types.h @@ -0,0 +1,47 @@ +/** + * @file include/kernel/types.h + */ + +#ifndef _KERNEL_TYPES_H_ +#define _KERNEL_TYPES_H_ + +#include <stddef.h> + +#include <stdbool.h> + +#ifdef __GNUC__ +#define GCC_VERSION (__GNUC__ * 10000 \ + + __GNUC_MINOR__ * 100 \ + + __GNUC_PATCHLEVEL__) +#endif + + +/* BCC is at least 4.4.2 */ +#if defined(GCC_VERSION) && (GCC_VERSION >= 404020) +#include <stdint.h> +#else +/* this must do... */ +typedef unsigned long uintptr_t; +typedef signed long intptr_t; + +typedef unsigned long long uint64_t; +typedef signed long long int64_t; + +typedef unsigned long uint32_t; +typedef signed long int32_t; + +typedef unsigned short uint16_t; +typedef signed short int16_t; + +typedef unsigned char uint8_t; +typedef signed char int8_t; + +#endif + +#ifndef __SIZEOF_LONG__ +#define __SIZEOF_LONG__ (sizeof(long)) +#endif + + + +#endif /* _KERNEL_TYPES_H_ */ diff --git a/lib/sysctl.c b/lib/sysctl.c index 4cb75bd..0339442 100644 --- a/lib/sysctl.c +++ b/lib/sysctl.c @@ -50,7 +50,6 @@ #include <stdio.h> #include <stdlib.h> -#include <stdint.h> #include <string.h> #include <errno.h> -- GitLab