platform.h
Go to the documentation of this file.
1 //
2 // Copyright (c) 2020 Fraunhofer Institute for Applied Information Technology (FIT)
3 // Network Research Group (NET)
4 // Schloss Birlinghoven, 53754 Sankt Augustin, GERMANY
5 // Contact: support@wiback.org
6 //
7 // This file is part of the SENF code tree.
8 // It is licensed under the 3-clause BSD License (aka New BSD License).
9 // See LICENSE.txt in the top level directory for details or visit
10 // https://opensource.org/licenses/BSD-3-Clause
11 //
12 
13 
14 #include <stddef.h>
15 #include <errno.h>
16 #ifndef _BSD_SOURCE
17 #define _BSD_SOURCE
18 #endif
19 #include <endian.h>
20 
21 #define le16_to_cpu le16toh
22 #define le32_to_cpu le32toh
23 #define get_unaligned(p) \
24 ({ \
25  struct packed_dummy_struct { \
26  typeof(*(p)) __val; \
27  } __attribute__((packed)) *__ptr = (void *) (p); \
28  \
29  __ptr->__val; \
30 })
31 #define get_unaligned_le16(p) le16_to_cpu(get_unaligned((uint16_t *)(p)))
32 #define get_unaligned_le32(p) le32_to_cpu(get_unaligned((uint32_t *)(p)))