blob: c5a52ef897fae203c51fec31aaf1da720c05be2b [file] [log] [blame]
Stefan Taunerb0eee9b2015-01-10 09:32:50 +00001/*
2 * This file is part of the flashrom project.
3 *
4 * Copyright (C) 2011 Carl-Daniel Hailfinger
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 2 of the License.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 */
19
20/*
21 * Header file to determine target OS and CPU architecture.
22 */
23
24#ifndef __PLATFORM_H__
25#define __PLATFORM_H__ 1
26
27// Helper defines for operating systems
28#define IS_LINUX (defined(__gnu_linux__) || defined(__linux__))
29#define IS_MACOSX (defined(__APPLE__) && defined(__MACH__)) /* yes, both. */
30#define IS_WINDOWS (defined(_WIN32) || defined(_WIN64) || defined(__WIN32__) || defined(__WINDOWS__))
31
32// Likewise for target architectures
33#if defined (__i386__) || defined (__x86_64__) || defined(__amd64__)
34 #define __FLASHROM_ARCH__ "x86"
35 #define IS_X86 1
36#elif defined (__mips) || defined (__mips__) || defined (__MIPS__) || defined (mips)
37 #define __FLASHROM_ARCH__ "mips"
38 #define IS_MIPS 1
39#elif defined(__powerpc) || defined(__powerpc__) || defined(__powerpc64__) || defined(__POWERPC__) || \
40 defined(__ppc__) || defined(__ppc64__) || defined(_M_PPC) || defined(_ARCH_PPC) || \
41 defined(_ARCH_PPC64) || defined(__ppc)
42 #define __FLASHROM_ARCH__ "ppc"
43 #define IS_PPC 1
44#elif defined(__arm__) || defined(__TARGET_ARCH_ARM) || defined(_ARM) || defined(_M_ARM) || defined(__arm) || \
45 defined(__aarch64__)
46 #define __FLASHROM_ARCH__ "arm"
47 #define IS_ARM 1
Stefan Taunerfb2d77c2015-02-10 08:03:10 +000048#elif defined (__sparc__) || defined (__sparc)
49 #define __FLASHROM_ARCH__ "sparc"
50 #define IS_SPARC 1
Carl-Daniel Hailfinger8d0d53f2016-02-25 20:10:26 +000051#elif defined (__alpha__)
52 #define __FLASHROM_ARCH__ "alpha"
53 #define IS_ALPHA 1
54#elif defined (__hppa__) || defined (__hppa)
55 #define __FLASHROM_ARCH__ "hppa"
56 #define IS_HPPA 1
57#elif defined (__m68k__)
58 #define __FLASHROM_ARCH__ "m68k"
59 #define IS_M68K 1
60#elif defined (__sh__)
61 #define __FLASHROM_ARCH__ "sh"
62 #define IS_SH 1
63#elif defined(__s390__) || defined(__s390x__) || defined(__zarch__)
64 #define __FLASHROM_ARCH__ "s390"
65 #define IS_S390 1
Stefan Taunerb0eee9b2015-01-10 09:32:50 +000066#endif
67
Carl-Daniel Hailfinger8d0d53f2016-02-25 20:10:26 +000068#if !(IS_X86 || IS_MIPS || IS_PPC || IS_ARM || IS_SPARC || IS_ALPHA || IS_HPPA || IS_M68K || IS_SH || IS_S390)
Stefan Taunerb0eee9b2015-01-10 09:32:50 +000069#error Unknown architecture
70#endif
71
72#endif /* !__PLATFORM_H__ */