blob: 9cde05409e008274ffa1144cd98e83dc86a99aa4 [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
Stefan Taunerb0eee9b2015-01-10 09:32:50 +000051#endif
52
Stefan Taunerfb2d77c2015-02-10 08:03:10 +000053#if !(IS_X86 || IS_MIPS || IS_PPC || IS_ARM || IS_SPARC)
Stefan Taunerb0eee9b2015-01-10 09:32:50 +000054#error Unknown architecture
55#endif
56
57#endif /* !__PLATFORM_H__ */