summaryrefslogtreecommitdiffstats
path: root/platform.h
diff options
context:
space:
mode:
authorStefan Tauner <stefan.tauner@alumni.tuwien.ac.at>2015-01-10 09:32:50 +0000
committerStefan Tauner <stefan.tauner@alumni.tuwien.ac.at>2015-01-10 09:32:50 +0000
commit474586a0592070d83eb3cbd468a14290da60591d (patch)
treefcba10fdf1451557f3bc58de6f39d669e5106c46 /platform.h
parent8f882166605ab1f20aa0488b6e9892c2d7cc52bb (diff)
downloadflashrom-474586a0592070d83eb3cbd468a14290da60591d.zip
flashrom-474586a0592070d83eb3cbd468a14290da60591d.tar.gz
Unify target OS and CPU architecture checks
We do CPU architecture checks once for the makefile in arch.h and once for HW access abstraction in hwaccess.c. This patch unifies related files so that they can share the checks to improve maintainability and reduce the chance of inconsistencies. Furthermore, it refines some of the definitions, which - adds "support" for AARCH64 and PPC64, - adds big-endian handling on arm as well as LE handling on PPC64, - fixes compilation of internal.c on AARCH64 and PPC64. Additionally, this patch continues to unify all OS checks in flashrom by adding a new helper macro IS_WINDOWS. The old header file for architecture checking is renamed to platform.h to reflect its broader scope and all new macros are add in there. Corresponding to flashrom svn r1864. Signed-off-by: Stefan Tauner <stefan.tauner@alumni.tuwien.ac.at> Acked-by: Stefan Tauner <stefan.tauner@alumni.tuwien.ac.at>
Diffstat (limited to 'platform.h')
-rw-r--r--platform.h54
1 files changed, 54 insertions, 0 deletions
diff --git a/platform.h b/platform.h
new file mode 100644
index 0000000..f57fd12
--- /dev/null
+++ b/platform.h
@@ -0,0 +1,54 @@
+/*
+ * This file is part of the flashrom project.
+ *
+ * Copyright (C) 2011 Carl-Daniel Hailfinger
+ *
+ * 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; version 2 of the License.
+ *
+ * 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+/*
+ * Header file to determine target OS and CPU architecture.
+ */
+
+#ifndef __PLATFORM_H__
+#define __PLATFORM_H__ 1
+
+// Helper defines for operating systems
+#define IS_LINUX (defined(__gnu_linux__) || defined(__linux__))
+#define IS_MACOSX (defined(__APPLE__) && defined(__MACH__)) /* yes, both. */
+#define IS_WINDOWS (defined(_WIN32) || defined(_WIN64) || defined(__WIN32__) || defined(__WINDOWS__))
+
+// Likewise for target architectures
+#if defined (__i386__) || defined (__x86_64__) || defined(__amd64__)
+ #define __FLASHROM_ARCH__ "x86"
+ #define IS_X86 1
+#elif defined (__mips) || defined (__mips__) || defined (__MIPS__) || defined (mips)
+ #define __FLASHROM_ARCH__ "mips"
+ #define IS_MIPS 1
+#elif defined(__powerpc) || defined(__powerpc__) || defined(__powerpc64__) || defined(__POWERPC__) || \
+ defined(__ppc__) || defined(__ppc64__) || defined(_M_PPC) || defined(_ARCH_PPC) || \
+ defined(_ARCH_PPC64) || defined(__ppc)
+ #define __FLASHROM_ARCH__ "ppc"
+ #define IS_PPC 1
+#elif defined(__arm__) || defined(__TARGET_ARCH_ARM) || defined(_ARM) || defined(_M_ARM) || defined(__arm) || \
+ defined(__aarch64__)
+ #define __FLASHROM_ARCH__ "arm"
+ #define IS_ARM 1
+#endif
+
+#if !(IS_X86 || IS_MIPS || IS_PPC || IS_ARM)
+#error Unknown architecture
+#endif
+
+#endif /* !__PLATFORM_H__ */
OpenPOWER on IntegriCloud