about summary refs log tree commit diff stats
path: root/src/libwifi/core/radiotap/platform.h
diff options
context:
space:
mode:
authorMarc <foxtrot@malloc.me>2021-11-30 22:39:26 +0000
committerMarc <foxtrot@malloc.me>2021-12-01 16:54:44 +0000
commitae6c98a48da409d040604aeffb84a38155fb5bac (patch)
treec27a8e28972209581ce3fba2130bf0c2b4f9c9c0 /src/libwifi/core/radiotap/platform.h
downloadlibwifi-ae6c98a48da409d040604aeffb84a38155fb5bac.tar.gz
libwifi-ae6c98a48da409d040604aeffb84a38155fb5bac.tar.bz2
libwifi-ae6c98a48da409d040604aeffb84a38155fb5bac.zip
Initial Commit
Signed-off-by: Marc <foxtrot@malloc.me>
Diffstat (limited to 'src/libwifi/core/radiotap/platform.h')
-rw-r--r--src/libwifi/core/radiotap/platform.h81
1 files changed, 81 insertions, 0 deletions
diff --git a/src/libwifi/core/radiotap/platform.h b/src/libwifi/core/radiotap/platform.h new file mode 100644 index 0000000..e0ad99f --- /dev/null +++ b/src/libwifi/core/radiotap/platform.h
@@ -0,0 +1,81 @@
1#include <errno.h>
2#include <stddef.h>
3#include <string.h>
4
5#if defined(linux) || defined(Linux) || defined(__linux__) || defined(__linux) || defined(__gnu_linux__)
6#include <endian.h>
7#if defined(__UCLIBC__)
8#include <asm/byteorder.h>
9#ifndef le16toh
10#define le16toh __le16_to_cpu
11#endif
12#ifndef le32toh
13#define le32toh __le32_to_cpu
14#endif
15#endif
16#endif
17
18#if defined(__CYGWIN32__) || defined(CYGWIN)
19#include <asm/byteorder.h>
20#include <endian.h>
21#endif
22
23#if defined(__APPLE__)
24#include <machine/endian.h>
25#endif
26
27#if defined(__FreeBSD__) || defined(__DragonFly__) || defined(__OpenBSD__) || defined(__MidnightBSD__) || \
28 defined(__NetBSD__)
29#include <sys/endian.h>
30#include <sys/types.h>
31#endif
32
33#if defined(__SVR4) && defined(__sun__)
34#include <sys/byteorder.h>
35#include <sys/types.h>
36#endif
37
38#ifndef le16_to_cpu
39#define le16_to_cpu le16toh
40#endif
41
42#ifndef le32_to_cpu
43#define le32_to_cpu le32toh
44#endif
45
46#if defined(_MSC_VER)
47// Microsoft
48#define EXPORT __declspec(dllexport)
49#define IMPORT __declspec(dllimport)
50#elif defined(__GNUC__) || defined(__llvm__) || defined(__clang__) || defined(__INTEL_COMPILER)
51#define EXPORT __attribute__((visibility("default")))
52#define IMPORT
53#else
54// do nothing and hope for the best?
55#define EXPORT
56#define IMPORT
57#pragma warning Unknown dynamic link import / export semantics.
58#endif
59
60#if defined(RADIOTAP_FAST_UNALIGNED_ACCESS)
61#define get_unaligned(p) \
62 __extension__({ \
63 struct packed_dummy_struct { \
64 typeof(*(p)) __val; \
65 } __attribute__((packed)) *__ptr = (void *) (p); \
66 \
67 __ptr->__val; \
68 })
69#else
70#define get_unaligned(p) \
71 __extension__({ \
72 typeof(*(p)) __tmp; \
73 memmove(&__tmp, (p), sizeof(*(p))); \
74 __tmp; \
75 })
76#endif
77
78#define get_unaligned_le16(p) le16_to_cpu(get_unaligned((uint16_t *) (p)))
79#define get_unaligned_le32(p) le32_to_cpu(get_unaligned((uint32_t *) (p)))
80
81#define UNALIGNED_ADDRESS(x) ((void *) (x))