le_basics.h
Go to the documentation of this file.
1 
23 #ifndef LEGATO_BASICS_INCLUDE_GUARD
24 #define LEGATO_BASICS_INCLUDE_GUARD
25 
26 //--------------------------------------------------------------------------------------------------
34 //--------------------------------------------------------------------------------------------------
35 typedef enum
36 {
37  LE_OK = 0,
38  LE_NOT_FOUND = -1,
41  LE_NO_MEMORY = -4,
43  LE_FAULT = -6,
45  LE_TIMEOUT = -8,
46  LE_OVERFLOW = -9,
47  LE_UNDERFLOW = -10,
49  LE_DEADLOCK = -12,
51  LE_DUPLICATE = -14,
53  LE_CLOSED = -16,
54  LE_BUSY = -17,
56  LE_IO_ERROR = -19,
59 }
61 
62 
63 //--------------------------------------------------------------------------------------------------
68 //--------------------------------------------------------------------------------------------------
69 typedef enum
70 {
71  LE_OFF = 0,
72  LE_ON = 1,
73 }
75 
76 
77 //--------------------------------------------------------------------------------------------------
83 //--------------------------------------------------------------------------------------------------
84 #define BIT0 0x01
85 #define BIT1 0x02
86 #define BIT2 0x04
87 #define BIT3 0x08
88 #define BIT4 0x10
89 #define BIT5 0x20
90 #define BIT6 0x40
91 #define BIT7 0x80
92 // @}
93 
94 //--------------------------------------------------------------------------------------------------
105 //--------------------------------------------------------------------------------------------------
106 #define CONTAINER_OF(memberPtr, type, member) \
107  ((type*)(((uint8_t*)(memberPtr))-((size_t)(&(((type*)0)->member)))))
108 
109 
110 //--------------------------------------------------------------------------------------------------
139 //--------------------------------------------------------------------------------------------------
140 #define NUM_ARRAY_MEMBERS(array) \
141  (sizeof(array) / sizeof((array)[0]))
142 
143 
144 //--------------------------------------------------------------------------------------------------
166 //--------------------------------------------------------------------------------------------------
167 #define INDEX_OF_ARRAY_MEMBER(array, memberPtr) \
168  ((((size_t)memberPtr) - ((size_t)array)) / sizeof(*(memberPtr)))
169 
170 
171 //--------------------------------------------------------------------------------------------------
204 //--------------------------------------------------------------------------------------------------
205 #define STRINGIZE(x) STRINGIZE_EXPAND(x)
206 
207 //--------------------------------------------------------------------------------------------------
211 //--------------------------------------------------------------------------------------------------
212 #define STRINGIZE_EXPAND(x) #x // Needed to expand macros.
213 
214 
215 //--------------------------------------------------------------------------------------------------
238 //--------------------------------------------------------------------------------------------------
239 #define LE_SHARED __attribute__((visibility ("default")))
240 
241 
242 #endif // LEGATO_BASICS_INCLUDE_GUARD
Format error.
Definition: le_basics.h:50
The underlying resource does not support this operation.
Definition: le_basics.h:55
Current user does not have permission to perform requested action.
Definition: le_basics.h:42
Unspecified internal error.
Definition: le_basics.h:43
Duplicate entry found or operation already performed.
Definition: le_basics.h:51
Insufficient memory is available.
Definition: le_basics.h:41
le_result_t
Definition: le_basics.h:35
An IO operation failed.
Definition: le_basics.h:56
Would have caused a deadlock.
Definition: le_basics.h:49
Successful.
Definition: le_basics.h:37
Unimplemented functionality.
Definition: le_basics.h:57
An overflow occurred or would have occurred.
Definition: le_basics.h:46
A time-out occurred.
Definition: le_basics.h:45
An underflow occurred or would have occurred.
Definition: le_basics.h:47
Referenced item does not exist or could not be found.
Definition: le_basics.h:38
The resource is closed.
Definition: le_basics.h:53
A transient or temporary loss of a service or resource.
Definition: le_basics.h:58
Definition: le_basics.h:39
The resource is busy.
Definition: le_basics.h:54
An index or other value is out of range.
Definition: le_basics.h:40
Parameter is invalid.
Definition: le_basics.h:52
Would have blocked if non-blocking behaviour was not requested.
Definition: le_basics.h:48
Communications error.
Definition: le_basics.h:44
le_onoff_t
Definition: le_basics.h:69