bigbiff bigbiff | 61cdc02 | 2013-08-08 08:35:06 -0400 | [diff] [blame] | 1 | /* |
| 2 | platform.h (14.05.13) |
| 3 | OS-specific code (libc-specific in fact). Note that systems with the |
| 4 | same kernel can use different libc implementations. |
| 5 | |
Matt Mower | 09ef1e4 | 2015-12-13 11:29:45 -0600 | [diff] [blame] | 6 | Free exFAT implementation. |
| 7 | Copyright (C) 2010-2015 Andrew Nayenko |
bigbiff bigbiff | 61cdc02 | 2013-08-08 08:35:06 -0400 | [diff] [blame] | 8 | |
Matt Mower | 09ef1e4 | 2015-12-13 11:29:45 -0600 | [diff] [blame] | 9 | This program is free software; you can redistribute it and/or modify |
bigbiff bigbiff | 61cdc02 | 2013-08-08 08:35:06 -0400 | [diff] [blame] | 10 | it under the terms of the GNU General Public License as published by |
Matt Mower | 09ef1e4 | 2015-12-13 11:29:45 -0600 | [diff] [blame] | 11 | the Free Software Foundation, either version 2 of the License, or |
bigbiff bigbiff | 61cdc02 | 2013-08-08 08:35:06 -0400 | [diff] [blame] | 12 | (at your option) any later version. |
| 13 | |
| 14 | This program is distributed in the hope that it will be useful, |
| 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 17 | GNU General Public License for more details. |
| 18 | |
Matt Mower | 09ef1e4 | 2015-12-13 11:29:45 -0600 | [diff] [blame] | 19 | You should have received a copy of the GNU General Public License along |
| 20 | with this program; if not, write to the Free Software Foundation, Inc., |
| 21 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
bigbiff bigbiff | 61cdc02 | 2013-08-08 08:35:06 -0400 | [diff] [blame] | 22 | */ |
| 23 | |
| 24 | #ifndef PLATFORM_H_INCLUDED |
| 25 | #define PLATFORM_H_INCLUDED |
| 26 | |
Matt Mower | 09ef1e4 | 2015-12-13 11:29:45 -0600 | [diff] [blame] | 27 | #if defined(__linux__) || defined(__GLIBC__) || defined(__GNU__) |
bigbiff bigbiff | 61cdc02 | 2013-08-08 08:35:06 -0400 | [diff] [blame] | 28 | |
| 29 | #include <endian.h> |
| 30 | #include <byteswap.h> |
Matt Mower | 09ef1e4 | 2015-12-13 11:29:45 -0600 | [diff] [blame] | 31 | #define exfat_bswap16(x) bswap_16(x) |
| 32 | #define exfat_bswap32(x) bswap_32(x) |
| 33 | #define exfat_bswap64(x) bswap_64(x) |
| 34 | #define EXFAT_BYTE_ORDER __BYTE_ORDER |
| 35 | #define EXFAT_LITTLE_ENDIAN __LITTLE_ENDIAN |
| 36 | #define EXFAT_BIG_ENDIAN __BIG_ENDIAN |
bigbiff bigbiff | 61cdc02 | 2013-08-08 08:35:06 -0400 | [diff] [blame] | 37 | |
| 38 | #elif defined(__APPLE__) |
| 39 | |
| 40 | #include <machine/endian.h> |
| 41 | #include <libkern/OSByteOrder.h> |
Matt Mower | 09ef1e4 | 2015-12-13 11:29:45 -0600 | [diff] [blame] | 42 | #define exfat_bswap16(x) OSSwapInt16(x) |
| 43 | #define exfat_bswap32(x) OSSwapInt32(x) |
| 44 | #define exfat_bswap64(x) OSSwapInt64(x) |
| 45 | #define EXFAT_BYTE_ORDER BYTE_ORDER |
| 46 | #define EXFAT_LITTLE_ENDIAN LITTLE_ENDIAN |
| 47 | #define EXFAT_BIG_ENDIAN BIG_ENDIAN |
bigbiff bigbiff | 61cdc02 | 2013-08-08 08:35:06 -0400 | [diff] [blame] | 48 | |
Matt Mower | 09ef1e4 | 2015-12-13 11:29:45 -0600 | [diff] [blame] | 49 | #elif defined(__ANDROID__) || defined(__FreeBSD__) || defined(__DragonFlyBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) |
bigbiff bigbiff | 61cdc02 | 2013-08-08 08:35:06 -0400 | [diff] [blame] | 50 | |
| 51 | #include <sys/endian.h> |
Matt Mower | 09ef1e4 | 2015-12-13 11:29:45 -0600 | [diff] [blame] | 52 | #define exfat_bswap16(x) bswap16(x) |
| 53 | #define exfat_bswap32(x) bswap32(x) |
| 54 | #define exfat_bswap64(x) bswap64(x) |
| 55 | #define EXFAT_BYTE_ORDER _BYTE_ORDER |
| 56 | #define EXFAT_LITTLE_ENDIAN _LITTLE_ENDIAN |
| 57 | #define EXFAT_BIG_ENDIAN _BIG_ENDIAN |
bigbiff | c40c1c5 | 2014-11-01 09:34:57 -0400 | [diff] [blame] | 58 | |
bigbiff bigbiff | 61cdc02 | 2013-08-08 08:35:06 -0400 | [diff] [blame] | 59 | #else |
| 60 | #error Unknown platform |
bigbiff | c40c1c5 | 2014-11-01 09:34:57 -0400 | [diff] [blame] | 61 | #endif |
| 62 | |
bigbiff bigbiff | 61cdc02 | 2013-08-08 08:35:06 -0400 | [diff] [blame] | 63 | #endif /* ifndef PLATFORM_H_INCLUDED */ |