Snapdragon® Telematics Application Framework (TelAF) Interface Specification
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 //--------------------------------------------------------------------------------------------------
31 //--------------------------------------------------------------------------------------------------
32 #ifdef __ARMCC_VERSION
33 #pragma anon_unions
34 #endif
35 
36 //--------------------------------------------------------------------------------------------------
44 //--------------------------------------------------------------------------------------------------
45 typedef enum
46 {
47  LE_OK = 0,
48  LE_NOT_FOUND = -1,
51  LE_NO_MEMORY = -4,
53  LE_FAULT = -6,
55  LE_TIMEOUT = -8,
56  LE_OVERFLOW = -9,
57  LE_UNDERFLOW = -10,
59  LE_DEADLOCK = -12,
61  LE_DUPLICATE = -14,
63  LE_CLOSED = -16,
64  LE_BUSY = -17,
66  LE_IO_ERROR = -19,
69  LE_TERMINATED = -22,
71  LE_SUSPENDED = -24,
72 }
74 
75 
76 //--------------------------------------------------------------------------------------------------
85 //--------------------------------------------------------------------------------------------------
86 #define EXIT_UNAVAILABLE 69
87 
88 
89 //--------------------------------------------------------------------------------------------------
94 //--------------------------------------------------------------------------------------------------
95 typedef enum
96 {
97  LE_OFF = 0,
98  LE_ON = 1,
99 }
100 le_onoff_t;
101 
102 
103 //--------------------------------------------------------------------------------------------------
109 //--------------------------------------------------------------------------------------------------
110 #define BIT0 0x01
111 #define BIT1 0x02
112 #define BIT2 0x04
113 #define BIT3 0x08
114 #define BIT4 0x10
115 #define BIT5 0x20
116 #define BIT6 0x40
117 #define BIT7 0x80
118 // @}
119 
120 //--------------------------------------------------------------------------------------------------
131 //--------------------------------------------------------------------------------------------------
132 #define CONTAINER_OF(memberPtr, type, member) \
133  ((type*)(((uint8_t*)(memberPtr))-((size_t)(&(((type*)0)->member)))))
134 
135 
136 //--------------------------------------------------------------------------------------------------
165 //--------------------------------------------------------------------------------------------------
166 #define NUM_ARRAY_MEMBERS(array) \
167  (sizeof(array) / sizeof((array)[0]))
168 
169 
170 //--------------------------------------------------------------------------------------------------
192 //--------------------------------------------------------------------------------------------------
193 #define INDEX_OF_ARRAY_MEMBER(array, memberPtr) \
194  ((((size_t)memberPtr) - ((size_t)array)) / sizeof(*(memberPtr)))
195 
196 
197 //--------------------------------------------------------------------------------------------------
230 //--------------------------------------------------------------------------------------------------
231 #define STRINGIZE(x) STRINGIZE_EXPAND(x)
232 
233 //--------------------------------------------------------------------------------------------------
237 //--------------------------------------------------------------------------------------------------
238 #define STRINGIZE_EXPAND(x) #x // Needed to expand macros.
239 
240 //--------------------------------------------------------------------------------------------------
247 //--------------------------------------------------------------------------------------------------
248 #define CAT(a, ...) PRIMITIVE_CAT(a, __VA_ARGS__)
249 
250 //--------------------------------------------------------------------------------------------------
254 //--------------------------------------------------------------------------------------------------
255 #define PRIMITIVE_CAT(a, ...) a ## __VA_ARGS__
256 
257 //--------------------------------------------------------------------------------------------------
261 //--------------------------------------------------------------------------------------------------
262 #define SECOND(a, b, ...) b
263 
264 //--------------------------------------------------------------------------------------------------
270 //--------------------------------------------------------------------------------------------------
271 #define LE_DEFAULT(...) SECOND(__VA_ARGS__)
272 
273 //--------------------------------------------------------------------------------------------------
296 //--------------------------------------------------------------------------------------------------
297 #define LE_SHARED __attribute__((visibility ("default")))
298 
299 //--------------------------------------------------------------------------------------------------
323 //--------------------------------------------------------------------------------------------------
324 #ifdef __GNUC_GNU_INLINE__
325 // Using gcc inline semantics
326 # define LE_DECLARE_INLINE extern inline
327 # define LE_DEFINE_INLINE inline
328 #else
329 // Use C99 inline semantics
330 # define LE_DECLARE_INLINE inline
331 # define LE_DEFINE_INLINE extern inline
332 #endif
333 
334 // Clang feature check macros -- define to return sensible defaults if macro is not available.
335 #ifndef __is_identifier
336 # define __is_identifier(x) 1
337 #endif
338 
339 #ifndef __has_warning
340 # define __has_warning(x) 0
341 #endif
342 
343 #ifndef __has_attribute
344 # define __has_attribute(x) 0
345 #endif
346 
347 #if !__is_identifier(_Nonnull)
348 
349 // Nullability information is not complete. Normally clang will warn in that case.
350 # if __has_warning("-Wnullability-completeness")
351 # pragma clang diagnostic ignored "-Wnullability-completeness"
352 # endif
353 
354 //--------------------------------------------------------------------------------------------------
358 //--------------------------------------------------------------------------------------------------
359 # define LE_NONNULL _Nonnull
360 
361 //--------------------------------------------------------------------------------------------------
365 //--------------------------------------------------------------------------------------------------
366 # define LE_NULLABLE _Nullable
367 #else
368 # define LE_NONNULL
369 # define LE_NULLABLE
370 #endif
371 
372 //--------------------------------------------------------------------------------------------------
378 //--------------------------------------------------------------------------------------------------
379 #define LE_UNUSED(v) ((void) (v))
380 
381 //--------------------------------------------------------------------------------------------------
385 //--------------------------------------------------------------------------------------------------
386 #if (__STDC_VERSION__ >= 199901L) || LE_CONFIG_LINUX
387 # define __PRIS_PREFIX "z"
388 #elif defined(__LP64__) || defined(_LP64)
389 # define __PRIS_PREFIX "ll"
390 #else
391 # define __PRIS_PREFIX "l"
392 #endif
393 
394 #define PRIdS __PRIS_PREFIX "d"
395 #define PRIxS __PRIS_PREFIX "x"
396 #define PRIuS __PRIS_PREFIX "u"
397 #define PRIXS __PRIS_PREFIX "X"
398 #define PRIoS __PRIS_PREFIX "o"
399 
400 
401 #if !defined(static_assert) && !defined(__cplusplus)
402 //--------------------------------------------------------------------------------------------------
406 //--------------------------------------------------------------------------------------------------
407 # if __GNUC__ || __STDC_VERSION__ >= 201112L
408 # define static_assert(cond, msg) _Static_assert((cond), #cond ": " msg)
409 # else
410 # define static_assert(cond, msg) ((void)sizeof(char[1 - 2*!(cond)]))
411 # endif
412 #endif
413 
414 #if __GNUC__
415 // ({ }) is a GNU extension, so only use it if compiler is GCC-compatible
416 # define inline_static_assert(cond, msg) ({ static_assert(cond, msg); })
417 #else
418 # define inline_static_assert(cond, msg) ((void)(0))
419 #endif
420 
421 //--------------------------------------------------------------------------------------------------
425 //--------------------------------------------------------------------------------------------------
426 #define LE_CONFIG_IS_ENABLED(option) (("" STRINGIZE(option))[0] == '1')
427 
428 #endif // LEGATO_BASICS_INCLUDE_GUARD
An overflow occurred or would have occurred.
Definition: le_basics.h:56
Communications error.
Definition: le_basics.h:54
An index or other value is out of range.
Definition: le_basics.h:50
Format error.
Definition: le_basics.h:60
The process, operation, data stream, session, etc. has stopped.
Definition: le_basics.h:69
Would have caused a deadlock.
Definition: le_basics.h:59
A transient or temporary loss of a service or resource.
Definition: le_basics.h:68
Definition: le_basics.h:49
The operation is in progress.
Definition: le_basics.h:70
Definition: le_basics.h:98
Duplicate entry found or operation already performed.
Definition: le_basics.h:61
Unimplemented functionality.
Definition: le_basics.h:67
Unspecified internal error.
Definition: le_basics.h:53
The resource is busy.
Definition: le_basics.h:64
The resource is closed.
Definition: le_basics.h:63
Current user does not have permission to perform requested action.
Definition: le_basics.h:52
Definition: le_basics.h:97
Insufficient memory is available.
Definition: le_basics.h:51
Referenced item does not exist or could not be found.
Definition: le_basics.h:48
An underflow occurred or would have occurred.
Definition: le_basics.h:57
The underlying resource does not support this operation.
Definition: le_basics.h:65
Would have blocked if non-blocking behaviour was not requested.
Definition: le_basics.h:58
Parameter is invalid.
Definition: le_basics.h:62
le_onoff_t
Definition: le_basics.h:95
le_result_t
Definition: le_basics.h:45
Successful.
Definition: le_basics.h:47
The operation is suspended.
Definition: le_basics.h:71
A time-out occurred.
Definition: le_basics.h:55
An IO operation failed.
Definition: le_basics.h:66