cc.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2015 Martine Lenders <mlenders@inf.fu-berlin.de>
3  *
4  * This file is subject to the terms and conditions of the GNU Lesser
5  * General Public License v2.1. See the file LICENSE in the top level
6  * directory for more details.
7  */
8 
20 #ifndef ARCH_CC_H
21 #define ARCH_CC_H
22 
23 #include <inttypes.h>
24 #include <stdio.h>
25 #include <stdlib.h>
26 
27 #include "irq.h"
28 #include "byteorder.h"
29 #include "mutex.h"
30 
31 #ifdef MODULE_LOG
32 #include "log.h"
33 #endif
34 
35 #ifdef __cplusplus
36 extern "C" {
37 #endif
38 
39 #ifndef BYTE_ORDER
40 #if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
41 # define BYTE_ORDER (LITTLE_ENDIAN)
42 #elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
43 # define BYTE_ORDER (BIG_ENDIAN)
44 #else
45 # error "Byte order is neither little nor big!"
46 #endif
47 #endif
48 
53 #define X8_F "02" PRIx8
54 #define U16_F PRIu16
55 #define S16_F PRId16
56 #define X16_F PRIx16
57 #define U32_F PRIu32
58 #define S32_F PRId32
59 #define X32_F PRIx32
60 
61 #define SZT_F "lu"
62 
68 #define PACK_STRUCT_FIELD(x) x
69 #define PACK_STRUCT_STRUCT __attribute__((packed))
70 #define PACK_STRUCT_BEGIN
71 #define PACK_STRUCT_END
72 
78 #ifdef MODULE_LOG
79 # define LWIP_PLATFORM_DIAG(x) LOG_INFO x
80 # ifdef NDEBUG
81 # define LWIP_PLATFORM_ASSERT(x)
82 # else
83 # define LWIP_PLATFORM_ASSERT(x) \
84  do { \
85  LOG_ERROR("Assertion \"%s\" failed at %s:%d\n", x, __FILE__, __LINE__); \
86  fflush(NULL); \
87  abort(); \
88  } while (0)
89 # endif
90 #else
91 # define LWIP_PLATFORM_DIAG(x) printf x
92 # ifdef NDEBUG
93 # define LWIP_PLATFORM_ASSERT(x)
94 # else
95 # define LWIP_PLATFORM_ASSERT(x) \
96  do { \
97  printf("Assertion \"%s\" failed at %s:%d\n", x, __FILE__, __LINE__); \
98  fflush(NULL); \
99  abort(); \
100  } while (0)
101 # endif
102 #endif
103 
105 #ifdef __cplusplus
106 }
107 #endif
108 
109 #endif /* ARCH_CC_H */
110 
byteorder.h
Functions to work with different byte orders.
irq.h
IRQ driver interface.
log.h
System logging header.
mutex.h
Mutex for thread synchronization.
inttypes.h
Adds include for missing inttype definitions.