eal: fix 32-bit structure marker
[dpdk.git] / lib / librte_eal / common / include / rte_common.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2010-2019 Intel Corporation
3  */
4
5 #ifndef _RTE_COMMON_H_
6 #define _RTE_COMMON_H_
7
8 /**
9  * @file
10  *
11  * Generic, commonly-used macro and inline function definitions
12  * for DPDK.
13  */
14
15 #ifdef __cplusplus
16 extern "C" {
17 #endif
18
19 #include <stdint.h>
20 #include <stdlib.h>
21 #include <ctype.h>
22 #include <errno.h>
23 #include <limits.h>
24
25 #include <rte_config.h>
26
27 /* OS specific include */
28 #include <rte_os.h>
29
30 #ifndef typeof
31 #define typeof __typeof__
32 #endif
33
34 #ifndef asm
35 #define asm __asm__
36 #endif
37
38 /** C extension macro for environments lacking C11 features. */
39 #if !defined(__STDC_VERSION__) || __STDC_VERSION__ < 201112L
40 #define RTE_STD_C11 __extension__
41 #else
42 #define RTE_STD_C11
43 #endif
44
45 /** Define GCC_VERSION **/
46 #ifdef RTE_TOOLCHAIN_GCC
47 #define GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 +  \
48                 __GNUC_PATCHLEVEL__)
49 #endif
50
51 #ifdef RTE_ARCH_STRICT_ALIGN
52 typedef uint64_t unaligned_uint64_t __attribute__ ((aligned(1)));
53 typedef uint32_t unaligned_uint32_t __attribute__ ((aligned(1)));
54 typedef uint16_t unaligned_uint16_t __attribute__ ((aligned(1)));
55 #else
56 typedef uint64_t unaligned_uint64_t;
57 typedef uint32_t unaligned_uint32_t;
58 typedef uint16_t unaligned_uint16_t;
59 #endif
60
61 /**
62  * Force alignment
63  */
64 #define __rte_aligned(a) __attribute__((__aligned__(a)))
65
66 /**
67  * Force a structure to be packed
68  */
69 #define __rte_packed __attribute__((__packed__))
70
71 /******* Macro to mark functions and fields scheduled for removal *****/
72 #define __rte_deprecated        __attribute__((__deprecated__))
73
74 /**
75  * Mark a function or variable to a weak reference.
76  */
77 #define __rte_weak __attribute__((__weak__))
78
79 /*********** Macros to eliminate unused variable warnings ********/
80
81 /**
82  * short definition to mark a function parameter unused
83  */
84 #define __rte_unused __attribute__((__unused__))
85
86 /**
87  * definition to mark a variable or function parameter as used so
88  * as to avoid a compiler warning
89  */
90 #define RTE_SET_USED(x) (void)(x)
91
92 #define RTE_PRIORITY_LOG 101
93 #define RTE_PRIORITY_BUS 110
94 #define RTE_PRIORITY_CLASS 120
95 #define RTE_PRIORITY_LAST 65535
96
97 #define RTE_PRIO(prio) \
98         RTE_PRIORITY_ ## prio
99
100 /**
101  * Run function before main() with high priority.
102  *
103  * @param func
104  *   Constructor function.
105  * @param prio
106  *   Priority number must be above 100.
107  *   Lowest number is the first to run.
108  */
109 #ifndef RTE_INIT_PRIO /* Allow to override from EAL */
110 #define RTE_INIT_PRIO(func, prio) \
111 static void __attribute__((constructor(RTE_PRIO(prio)), used)) func(void)
112 #endif
113
114 /**
115  * Run function before main() with low priority.
116  *
117  * The constructor will be run after prioritized constructors.
118  *
119  * @param func
120  *   Constructor function.
121  */
122 #define RTE_INIT(func) \
123         RTE_INIT_PRIO(func, LAST)
124
125 /**
126  * Run after main() with low priority.
127  *
128  * @param func
129  *   Destructor function name.
130  * @param prio
131  *   Priority number must be above 100.
132  *   Lowest number is the last to run.
133  */
134 #ifndef RTE_FINI_PRIO /* Allow to override from EAL */
135 #define RTE_FINI_PRIO(func, prio) \
136 static void __attribute__((destructor(RTE_PRIO(prio)), used)) func(void)
137 #endif
138
139 /**
140  * Run after main() with high priority.
141  *
142  * The destructor will be run *before* prioritized destructors.
143  *
144  * @param func
145  *   Destructor function name.
146  */
147 #define RTE_FINI(func) \
148         RTE_FINI_PRIO(func, LAST)
149
150 /**
151  * Force a function to be inlined
152  */
153 #define __rte_always_inline inline __attribute__((always_inline))
154
155 /**
156  * Force a function to be noinlined
157  */
158 #define __rte_noinline  __attribute__((noinline))
159
160 /*********** Macros for pointer arithmetic ********/
161
162 /**
163  * add a byte-value offset to a pointer
164  */
165 #define RTE_PTR_ADD(ptr, x) ((void*)((uintptr_t)(ptr) + (x)))
166
167 /**
168  * subtract a byte-value offset from a pointer
169  */
170 #define RTE_PTR_SUB(ptr, x) ((void*)((uintptr_t)ptr - (x)))
171
172 /**
173  * get the difference between two pointer values, i.e. how far apart
174  * in bytes are the locations they point two. It is assumed that
175  * ptr1 is greater than ptr2.
176  */
177 #define RTE_PTR_DIFF(ptr1, ptr2) ((uintptr_t)(ptr1) - (uintptr_t)(ptr2))
178
179 /**
180  * Workaround to cast a const field of a structure to non-const type.
181  */
182 #define RTE_CAST_FIELD(var, field, type) \
183         (*(type *)((uintptr_t)(var) + offsetof(typeof(*(var)), field)))
184
185 /*********** Macros/static functions for doing alignment ********/
186
187
188 /**
189  * Macro to align a pointer to a given power-of-two. The resultant
190  * pointer will be a pointer of the same type as the first parameter, and
191  * point to an address no higher than the first parameter. Second parameter
192  * must be a power-of-two value.
193  */
194 #define RTE_PTR_ALIGN_FLOOR(ptr, align) \
195         ((typeof(ptr))RTE_ALIGN_FLOOR((uintptr_t)ptr, align))
196
197 /**
198  * Macro to align a value to a given power-of-two. The resultant value
199  * will be of the same type as the first parameter, and will be no
200  * bigger than the first parameter. Second parameter must be a
201  * power-of-two value.
202  */
203 #define RTE_ALIGN_FLOOR(val, align) \
204         (typeof(val))((val) & (~((typeof(val))((align) - 1))))
205
206 /**
207  * Macro to align a pointer to a given power-of-two. The resultant
208  * pointer will be a pointer of the same type as the first parameter, and
209  * point to an address no lower than the first parameter. Second parameter
210  * must be a power-of-two value.
211  */
212 #define RTE_PTR_ALIGN_CEIL(ptr, align) \
213         RTE_PTR_ALIGN_FLOOR((typeof(ptr))RTE_PTR_ADD(ptr, (align) - 1), align)
214
215 /**
216  * Macro to align a value to a given power-of-two. The resultant value
217  * will be of the same type as the first parameter, and will be no lower
218  * than the first parameter. Second parameter must be a power-of-two
219  * value.
220  */
221 #define RTE_ALIGN_CEIL(val, align) \
222         RTE_ALIGN_FLOOR(((val) + ((typeof(val)) (align) - 1)), align)
223
224 /**
225  * Macro to align a pointer to a given power-of-two. The resultant
226  * pointer will be a pointer of the same type as the first parameter, and
227  * point to an address no lower than the first parameter. Second parameter
228  * must be a power-of-two value.
229  * This function is the same as RTE_PTR_ALIGN_CEIL
230  */
231 #define RTE_PTR_ALIGN(ptr, align) RTE_PTR_ALIGN_CEIL(ptr, align)
232
233 /**
234  * Macro to align a value to a given power-of-two. The resultant
235  * value will be of the same type as the first parameter, and
236  * will be no lower than the first parameter. Second parameter
237  * must be a power-of-two value.
238  * This function is the same as RTE_ALIGN_CEIL
239  */
240 #define RTE_ALIGN(val, align) RTE_ALIGN_CEIL(val, align)
241
242 /**
243  * Macro to align a value to the multiple of given value. The resultant
244  * value will be of the same type as the first parameter and will be no lower
245  * than the first parameter.
246  */
247 #define RTE_ALIGN_MUL_CEIL(v, mul) \
248         (((v + (typeof(v))(mul) - 1) / ((typeof(v))(mul))) * (typeof(v))(mul))
249
250 /**
251  * Macro to align a value to the multiple of given value. The resultant
252  * value will be of the same type as the first parameter and will be no higher
253  * than the first parameter.
254  */
255 #define RTE_ALIGN_MUL_FLOOR(v, mul) \
256         ((v / ((typeof(v))(mul))) * (typeof(v))(mul))
257
258 /**
259  * Macro to align value to the nearest multiple of the given value.
260  * The resultant value might be greater than or less than the first parameter
261  * whichever difference is the lowest.
262  */
263 #define RTE_ALIGN_MUL_NEAR(v, mul)                              \
264         ({                                                      \
265                 typeof(v) ceil = RTE_ALIGN_MUL_CEIL(v, mul);    \
266                 typeof(v) floor = RTE_ALIGN_MUL_FLOOR(v, mul);  \
267                 (ceil - v) > (v - floor) ? floor : ceil;        \
268         })
269
270 /**
271  * Checks if a pointer is aligned to a given power-of-two value
272  *
273  * @param ptr
274  *   The pointer whose alignment is to be checked
275  * @param align
276  *   The power-of-two value to which the ptr should be aligned
277  *
278  * @return
279  *   True(1) where the pointer is correctly aligned, false(0) otherwise
280  */
281 static inline int
282 rte_is_aligned(void *ptr, unsigned align)
283 {
284         return RTE_PTR_ALIGN(ptr, align) == ptr;
285 }
286
287 /*********** Macros for compile type checks ********/
288
289 /**
290  * Triggers an error at compilation time if the condition is true.
291  */
292 #define RTE_BUILD_BUG_ON(condition) ((void)sizeof(char[1 - 2*!!(condition)]))
293
294 /*********** Cache line related macros ********/
295
296 /** Cache line mask. */
297 #define RTE_CACHE_LINE_MASK (RTE_CACHE_LINE_SIZE-1)
298
299 /** Return the first cache-aligned value greater or equal to size. */
300 #define RTE_CACHE_LINE_ROUNDUP(size) \
301         (RTE_CACHE_LINE_SIZE * ((size + RTE_CACHE_LINE_SIZE - 1) / \
302         RTE_CACHE_LINE_SIZE))
303
304 /** Cache line size in terms of log2 */
305 #if RTE_CACHE_LINE_SIZE == 64
306 #define RTE_CACHE_LINE_SIZE_LOG2 6
307 #elif RTE_CACHE_LINE_SIZE == 128
308 #define RTE_CACHE_LINE_SIZE_LOG2 7
309 #else
310 #error "Unsupported cache line size"
311 #endif
312
313 /** Minimum Cache line size. */
314 #define RTE_CACHE_LINE_MIN_SIZE 64
315
316 /** Force alignment to cache line. */
317 #define __rte_cache_aligned __rte_aligned(RTE_CACHE_LINE_SIZE)
318
319 /** Force minimum cache line alignment. */
320 #define __rte_cache_min_aligned __rte_aligned(RTE_CACHE_LINE_MIN_SIZE)
321
322 /*********** PA/IOVA type definitions ********/
323
324 /** Physical address */
325 typedef uint64_t phys_addr_t;
326 #define RTE_BAD_PHYS_ADDR ((phys_addr_t)-1)
327
328 /**
329  * IO virtual address type.
330  * When the physical addressing mode (IOVA as PA) is in use,
331  * the translation from an IO virtual address (IOVA) to a physical address
332  * is a direct mapping, i.e. the same value.
333  * Otherwise, in virtual mode (IOVA as VA), an IOMMU may do the translation.
334  */
335 typedef uint64_t rte_iova_t;
336 #define RTE_BAD_IOVA ((rte_iova_t)-1)
337
338 /*********** Structure alignment markers ********/
339
340 /** Generic marker for any place in a structure. */
341 __extension__ typedef void    *RTE_MARKER[0];
342 /** Marker for 1B alignment in a structure. */
343 __extension__ typedef uint8_t  RTE_MARKER8[0];
344 /** Marker for 2B alignment in a structure. */
345 __extension__ typedef uint16_t RTE_MARKER16[0];
346 /** Marker for 4B alignment in a structure. */
347 __extension__ typedef uint32_t RTE_MARKER32[0];
348 /** Marker for 8B alignment in a structure. */
349 __extension__ typedef uint64_t RTE_MARKER64[0];
350
351 /**
352  * Combines 32b inputs most significant set bits into the least
353  * significant bits to construct a value with the same MSBs as x
354  * but all 1's under it.
355  *
356  * @param x
357  *    The integer whose MSBs need to be combined with its LSBs
358  * @return
359  *    The combined value.
360  */
361 static inline uint32_t
362 rte_combine32ms1b(register uint32_t x)
363 {
364         x |= x >> 1;
365         x |= x >> 2;
366         x |= x >> 4;
367         x |= x >> 8;
368         x |= x >> 16;
369
370         return x;
371 }
372
373 /**
374  * Combines 64b inputs most significant set bits into the least
375  * significant bits to construct a value with the same MSBs as x
376  * but all 1's under it.
377  *
378  * @param v
379  *    The integer whose MSBs need to be combined with its LSBs
380  * @return
381  *    The combined value.
382  */
383 static inline uint64_t
384 rte_combine64ms1b(register uint64_t v)
385 {
386         v |= v >> 1;
387         v |= v >> 2;
388         v |= v >> 4;
389         v |= v >> 8;
390         v |= v >> 16;
391         v |= v >> 32;
392
393         return v;
394 }
395
396 /*********** Macros to work with powers of 2 ********/
397
398 /**
399  * Macro to return 1 if n is a power of 2, 0 otherwise
400  */
401 #define RTE_IS_POWER_OF_2(n) ((n) && !(((n) - 1) & (n)))
402
403 /**
404  * Returns true if n is a power of 2
405  * @param n
406  *     Number to check
407  * @return 1 if true, 0 otherwise
408  */
409 static inline int
410 rte_is_power_of_2(uint32_t n)
411 {
412         return n && !(n & (n - 1));
413 }
414
415 /**
416  * Aligns input parameter to the next power of 2
417  *
418  * @param x
419  *   The integer value to align
420  *
421  * @return
422  *   Input parameter aligned to the next power of 2
423  */
424 static inline uint32_t
425 rte_align32pow2(uint32_t x)
426 {
427         x--;
428         x = rte_combine32ms1b(x);
429
430         return x + 1;
431 }
432
433 /**
434  * Aligns input parameter to the previous power of 2
435  *
436  * @param x
437  *   The integer value to align
438  *
439  * @return
440  *   Input parameter aligned to the previous power of 2
441  */
442 static inline uint32_t
443 rte_align32prevpow2(uint32_t x)
444 {
445         x = rte_combine32ms1b(x);
446
447         return x - (x >> 1);
448 }
449
450 /**
451  * Aligns 64b input parameter to the next power of 2
452  *
453  * @param v
454  *   The 64b value to align
455  *
456  * @return
457  *   Input parameter aligned to the next power of 2
458  */
459 static inline uint64_t
460 rte_align64pow2(uint64_t v)
461 {
462         v--;
463         v = rte_combine64ms1b(v);
464
465         return v + 1;
466 }
467
468 /**
469  * Aligns 64b input parameter to the previous power of 2
470  *
471  * @param v
472  *   The 64b value to align
473  *
474  * @return
475  *   Input parameter aligned to the previous power of 2
476  */
477 static inline uint64_t
478 rte_align64prevpow2(uint64_t v)
479 {
480         v = rte_combine64ms1b(v);
481
482         return v - (v >> 1);
483 }
484
485 /*********** Macros for calculating min and max **********/
486
487 /**
488  * Macro to return the minimum of two numbers
489  */
490 #define RTE_MIN(a, b) \
491         __extension__ ({ \
492                 typeof (a) _a = (a); \
493                 typeof (b) _b = (b); \
494                 _a < _b ? _a : _b; \
495         })
496
497 /**
498  * Macro to return the maximum of two numbers
499  */
500 #define RTE_MAX(a, b) \
501         __extension__ ({ \
502                 typeof (a) _a = (a); \
503                 typeof (b) _b = (b); \
504                 _a > _b ? _a : _b; \
505         })
506
507 /*********** Other general functions / macros ********/
508
509 /**
510  * Searches the input parameter for the least significant set bit
511  * (starting from zero).
512  * If a least significant 1 bit is found, its bit index is returned.
513  * If the content of the input parameter is zero, then the content of the return
514  * value is undefined.
515  * @param v
516  *     input parameter, should not be zero.
517  * @return
518  *     least significant set bit in the input parameter.
519  */
520 static inline uint32_t
521 rte_bsf32(uint32_t v)
522 {
523         return (uint32_t)__builtin_ctz(v);
524 }
525
526 /**
527  * Searches the input parameter for the least significant set bit
528  * (starting from zero). Safe version (checks for input parameter being zero).
529  *
530  * @warning ``pos`` must be a valid pointer. It is not checked!
531  *
532  * @param v
533  *     The input parameter.
534  * @param pos
535  *     If ``v`` was not 0, this value will contain position of least significant
536  *     bit within the input parameter.
537  * @return
538  *     Returns 0 if ``v`` was 0, otherwise returns 1.
539  */
540 static inline int
541 rte_bsf32_safe(uint64_t v, uint32_t *pos)
542 {
543         if (v == 0)
544                 return 0;
545
546         *pos = rte_bsf32(v);
547         return 1;
548 }
549
550 /**
551  * Return the rounded-up log2 of a integer.
552  *
553  * @note Contrary to the logarithm mathematical operation,
554  * rte_log2_u32(0) == 0 and not -inf.
555  *
556  * @param v
557  *     The input parameter.
558  * @return
559  *     The rounded-up log2 of the input, or 0 if the input is 0.
560  */
561 static inline uint32_t
562 rte_log2_u32(uint32_t v)
563 {
564         if (v == 0)
565                 return 0;
566         v = rte_align32pow2(v);
567         return rte_bsf32(v);
568 }
569
570
571 /**
572  * Return the last (most-significant) bit set.
573  *
574  * @note The last (most significant) bit is at position 32.
575  * @note rte_fls_u32(0) = 0, rte_fls_u32(1) = 1, rte_fls_u32(0x80000000) = 32
576  *
577  * @param x
578  *     The input parameter.
579  * @return
580  *     The last (most-significant) bit set, or 0 if the input is 0.
581  */
582 static inline int
583 rte_fls_u32(uint32_t x)
584 {
585         return (x == 0) ? 0 : 32 - __builtin_clz(x);
586 }
587
588 /**
589  * Searches the input parameter for the least significant set bit
590  * (starting from zero).
591  * If a least significant 1 bit is found, its bit index is returned.
592  * If the content of the input parameter is zero, then the content of the return
593  * value is undefined.
594  * @param v
595  *     input parameter, should not be zero.
596  * @return
597  *     least significant set bit in the input parameter.
598  */
599 static inline int
600 rte_bsf64(uint64_t v)
601 {
602         return (uint32_t)__builtin_ctzll(v);
603 }
604
605 /**
606  * Searches the input parameter for the least significant set bit
607  * (starting from zero). Safe version (checks for input parameter being zero).
608  *
609  * @warning ``pos`` must be a valid pointer. It is not checked!
610  *
611  * @param v
612  *     The input parameter.
613  * @param pos
614  *     If ``v`` was not 0, this value will contain position of least significant
615  *     bit within the input parameter.
616  * @return
617  *     Returns 0 if ``v`` was 0, otherwise returns 1.
618  */
619 static inline int
620 rte_bsf64_safe(uint64_t v, uint32_t *pos)
621 {
622         if (v == 0)
623                 return 0;
624
625         *pos = rte_bsf64(v);
626         return 1;
627 }
628
629 /**
630  * Return the last (most-significant) bit set.
631  *
632  * @note The last (most significant) bit is at position 64.
633  * @note rte_fls_u64(0) = 0, rte_fls_u64(1) = 1,
634  *       rte_fls_u64(0x8000000000000000) = 64
635  *
636  * @param x
637  *     The input parameter.
638  * @return
639  *     The last (most-significant) bit set, or 0 if the input is 0.
640  */
641 static inline int
642 rte_fls_u64(uint64_t x)
643 {
644         return (x == 0) ? 0 : 64 - __builtin_clzll(x);
645 }
646
647 /**
648  * Return the rounded-up log2 of a 64-bit integer.
649  *
650  * @note Contrary to the logarithm mathematical operation,
651  * rte_log2_u64(0) == 0 and not -inf.
652  *
653  * @param v
654  *     The input parameter.
655  * @return
656  *     The rounded-up log2 of the input, or 0 if the input is 0.
657  */
658 static inline uint32_t
659 rte_log2_u64(uint64_t v)
660 {
661         if (v == 0)
662                 return 0;
663         v = rte_align64pow2(v);
664         /* we checked for v being 0 already, so no undefined behavior */
665         return rte_bsf64(v);
666 }
667
668 #ifndef offsetof
669 /** Return the offset of a field in a structure. */
670 #define offsetof(TYPE, MEMBER)  __builtin_offsetof (TYPE, MEMBER)
671 #endif
672
673 /**
674  * Return pointer to the wrapping struct instance.
675  *
676  * Example:
677  *
678  *  struct wrapper {
679  *      ...
680  *      struct child c;
681  *      ...
682  *  };
683  *
684  *  struct child *x = obtain(...);
685  *  struct wrapper *w = container_of(x, struct wrapper, c);
686  */
687 #ifndef container_of
688 #define container_of(ptr, type, member) __extension__ ({                \
689                         const typeof(((type *)0)->member) *_ptr = (ptr); \
690                         __attribute__((unused)) type *_target_ptr =     \
691                                 (type *)(ptr);                          \
692                         (type *)(((uintptr_t)_ptr) - offsetof(type, member)); \
693                 })
694 #endif
695
696 /**
697  * Get the size of a field in a structure.
698  *
699  * @param type
700  *   The type of the structure.
701  * @param field
702  *   The field in the structure.
703  * @return
704  *   The size of the field in the structure, in bytes.
705  */
706 #define RTE_SIZEOF_FIELD(type, field) (sizeof(((type *)0)->field))
707
708 #define _RTE_STR(x) #x
709 /** Take a macro value and get a string version of it */
710 #define RTE_STR(x) _RTE_STR(x)
711
712 /**
713  * ISO C helpers to modify format strings using variadic macros.
714  * This is a replacement for the ", ## __VA_ARGS__" GNU extension.
715  * An empty %s argument is appended to avoid a dangling comma.
716  */
717 #define RTE_FMT(fmt, ...) fmt "%.0s", __VA_ARGS__ ""
718 #define RTE_FMT_HEAD(fmt, ...) fmt
719 #define RTE_FMT_TAIL(fmt, ...) __VA_ARGS__
720
721 /** Mask value of type "tp" for the first "ln" bit set. */
722 #define RTE_LEN2MASK(ln, tp)    \
723         ((tp)((uint64_t)-1 >> (sizeof(uint64_t) * CHAR_BIT - (ln))))
724
725 /** Number of elements in the array. */
726 #define RTE_DIM(a)      (sizeof (a) / sizeof ((a)[0]))
727
728 /**
729  * Converts a numeric string to the equivalent uint64_t value.
730  * As well as straight number conversion, also recognises the suffixes
731  * k, m and g for kilobytes, megabytes and gigabytes respectively.
732  *
733  * If a negative number is passed in  i.e. a string with the first non-black
734  * character being "-", zero is returned. Zero is also returned in the case of
735  * an error with the strtoull call in the function.
736  *
737  * @param str
738  *     String containing number to convert.
739  * @return
740  *     Number.
741  */
742 static inline uint64_t
743 rte_str_to_size(const char *str)
744 {
745         char *endptr;
746         unsigned long long size;
747
748         while (isspace((int)*str))
749                 str++;
750         if (*str == '-')
751                 return 0;
752
753         errno = 0;
754         size = strtoull(str, &endptr, 0);
755         if (errno)
756                 return 0;
757
758         if (*endptr == ' ')
759                 endptr++; /* allow 1 space gap */
760
761         switch (*endptr){
762         case 'G': case 'g': size *= 1024; /* fall-through */
763         case 'M': case 'm': size *= 1024; /* fall-through */
764         case 'K': case 'k': size *= 1024; /* fall-through */
765         default:
766                 break;
767         }
768         return size;
769 }
770
771 /**
772  * Function to terminate the application immediately, printing an error
773  * message and returning the exit_code back to the shell.
774  *
775  * This function never returns
776  *
777  * @param exit_code
778  *     The exit code to be returned by the application
779  * @param format
780  *     The format string to be used for printing the message. This can include
781  *     printf format characters which will be expanded using any further parameters
782  *     to the function.
783  */
784 void
785 rte_exit(int exit_code, const char *format, ...)
786         __attribute__((noreturn))
787         __attribute__((format(printf, 2, 3)));
788
789 #ifdef __cplusplus
790 }
791 #endif
792
793 #endif