blob: 668857607bf73c1aab92a82c413d3be893d71891 [file] [log] [blame]
Marek Vasut9ad82a72025-03-17 04:12:45 +01001/*
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
6 Free exFAT implementation.
7 Copyright (C) 2010-2023 Andrew Nayenko
8
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation, either version 2 of the License, or
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
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.
22*/
23
24#ifndef PLATFORM_H_INCLUDED
25#define PLATFORM_H_INCLUDED
26
27#if defined(__linux__) || defined(__GLIBC__) || defined(__GNU__)
28
Marek Vasut894cf722025-03-17 04:12:46 +010029#ifndef __UBOOT__
Marek Vasut9ad82a72025-03-17 04:12:45 +010030#include <endian.h>
31#include <byteswap.h>
Marek Vasut894cf722025-03-17 04:12:46 +010032#endif
Marek Vasut9ad82a72025-03-17 04:12:45 +010033#define exfat_bswap16(x) bswap_16(x)
34#define exfat_bswap32(x) bswap_32(x)
35#define exfat_bswap64(x) bswap_64(x)
36#define EXFAT_BYTE_ORDER __BYTE_ORDER
37#define EXFAT_LITTLE_ENDIAN __LITTLE_ENDIAN
38#define EXFAT_BIG_ENDIAN __BIG_ENDIAN
39
40#elif defined(__APPLE__)
41
42#include <machine/endian.h>
43#include <libkern/OSByteOrder.h>
44#define exfat_bswap16(x) OSSwapInt16(x)
45#define exfat_bswap32(x) OSSwapInt32(x)
46#define exfat_bswap64(x) OSSwapInt64(x)
47#define EXFAT_BYTE_ORDER BYTE_ORDER
48#define EXFAT_LITTLE_ENDIAN LITTLE_ENDIAN
49#define EXFAT_BIG_ENDIAN BIG_ENDIAN
50
51#elif defined(__FreeBSD__) || defined(__DragonFly__) || defined(__NetBSD__) || defined(__OpenBSD__)
52
53#include <sys/endian.h>
54#define exfat_bswap16(x) bswap16(x)
55#define exfat_bswap32(x) bswap32(x)
56#define exfat_bswap64(x) bswap64(x)
57#define EXFAT_BYTE_ORDER _BYTE_ORDER
58#define EXFAT_LITTLE_ENDIAN _LITTLE_ENDIAN
59#define EXFAT_BIG_ENDIAN _BIG_ENDIAN
60
61#elif defined(__sun)
62
63#include <endian.h>
64#define exfat_bswap16(x) bswap_16(x)
65#define exfat_bswap32(x) bswap_32(x)
66#define exfat_bswap64(x) bswap_64(x)
67#define EXFAT_BYTE_ORDER __BYTE_ORDER
68#define EXFAT_LITTLE_ENDIAN __LITTLE_ENDIAN
69#define EXFAT_BIG_ENDIAN __BIG_ENDIAN
70
71#else
72#error Unknown platform
73#endif
74
75#endif /* ifndef PLATFORM_H_INCLUDED */