Stefan Tauner | b0eee9b | 2015-01-10 09:32:50 +0000 | [diff] [blame] | 1 | /* |
| 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 |
Patrick Georgi | d2a03b3 | 2017-03-13 13:48:03 +0100 | [diff] [blame] | 28 | #if defined(__gnu_linux__) || defined(__linux__) |
| 29 | #define IS_LINUX 1 |
| 30 | #else |
| 31 | #define IS_LINUX 0 |
| 32 | #endif |
| 33 | #if defined(__APPLE__) && defined(__MACH__) /* yes, both. */ |
| 34 | #define IS_MACOSX 1 |
| 35 | #else |
| 36 | #define IS_MACOSX 0 |
| 37 | #endif |
| 38 | #if defined(_WIN32) || defined(_WIN64) || defined(__WIN32__) || defined(__WINDOWS__) |
| 39 | #define IS_WINDOWS 1 |
| 40 | #else |
| 41 | #define IS_WINDOWS 0 |
| 42 | #endif |
Stefan Tauner | b0eee9b | 2015-01-10 09:32:50 +0000 | [diff] [blame] | 43 | |
| 44 | // Likewise for target architectures |
| 45 | #if defined (__i386__) || defined (__x86_64__) || defined(__amd64__) |
| 46 | #define __FLASHROM_ARCH__ "x86" |
| 47 | #define IS_X86 1 |
| 48 | #elif defined (__mips) || defined (__mips__) || defined (__MIPS__) || defined (mips) |
| 49 | #define __FLASHROM_ARCH__ "mips" |
| 50 | #define IS_MIPS 1 |
| 51 | #elif defined(__powerpc) || defined(__powerpc__) || defined(__powerpc64__) || defined(__POWERPC__) || \ |
| 52 | defined(__ppc__) || defined(__ppc64__) || defined(_M_PPC) || defined(_ARCH_PPC) || \ |
| 53 | defined(_ARCH_PPC64) || defined(__ppc) |
| 54 | #define __FLASHROM_ARCH__ "ppc" |
| 55 | #define IS_PPC 1 |
| 56 | #elif defined(__arm__) || defined(__TARGET_ARCH_ARM) || defined(_ARM) || defined(_M_ARM) || defined(__arm) || \ |
| 57 | defined(__aarch64__) |
| 58 | #define __FLASHROM_ARCH__ "arm" |
| 59 | #define IS_ARM 1 |
Stefan Tauner | fb2d77c | 2015-02-10 08:03:10 +0000 | [diff] [blame] | 60 | #elif defined (__sparc__) || defined (__sparc) |
| 61 | #define __FLASHROM_ARCH__ "sparc" |
| 62 | #define IS_SPARC 1 |
Carl-Daniel Hailfinger | 8d0d53f | 2016-02-25 20:10:26 +0000 | [diff] [blame] | 63 | #elif defined (__alpha__) |
| 64 | #define __FLASHROM_ARCH__ "alpha" |
| 65 | #define IS_ALPHA 1 |
| 66 | #elif defined (__hppa__) || defined (__hppa) |
| 67 | #define __FLASHROM_ARCH__ "hppa" |
| 68 | #define IS_HPPA 1 |
| 69 | #elif defined (__m68k__) |
| 70 | #define __FLASHROM_ARCH__ "m68k" |
| 71 | #define IS_M68K 1 |
| 72 | #elif defined (__sh__) |
| 73 | #define __FLASHROM_ARCH__ "sh" |
| 74 | #define IS_SH 1 |
| 75 | #elif defined(__s390__) || defined(__s390x__) || defined(__zarch__) |
| 76 | #define __FLASHROM_ARCH__ "s390" |
| 77 | #define IS_S390 1 |
Stefan Tauner | b0eee9b | 2015-01-10 09:32:50 +0000 | [diff] [blame] | 78 | #endif |
| 79 | |
Carl-Daniel Hailfinger | 8d0d53f | 2016-02-25 20:10:26 +0000 | [diff] [blame] | 80 | #if !(IS_X86 || IS_MIPS || IS_PPC || IS_ARM || IS_SPARC || IS_ALPHA || IS_HPPA || IS_M68K || IS_SH || IS_S390) |
Stefan Tauner | b0eee9b | 2015-01-10 09:32:50 +0000 | [diff] [blame] | 81 | #error Unknown architecture |
| 82 | #endif |
| 83 | |
| 84 | #endif /* !__PLATFORM_H__ */ |