|
Revision 1289, 1.4 kB
(checked in by ensc, 5 years ago)
|
use builtin_expect
|
- Property svn:eol-style set to
native
- Property svn:keywords set to
Author Date Id Revision
|
| Line | |
|---|
| 1 |
|
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 |
|
|---|
| 17 |
|
|---|
| 18 |
|
|---|
| 19 |
#ifndef H_ENSC_IN_WRAPPERS_H |
|---|
| 20 |
# error wrappers_handler.hc can not be used in this way |
|---|
| 21 |
#endif |
|---|
| 22 |
|
|---|
| 23 |
#include <stdlib.h> |
|---|
| 24 |
#include <stdbool.h> |
|---|
| 25 |
#include <stdio.h> |
|---|
| 26 |
|
|---|
| 27 |
static inline ALWAYSINLINE NORETURN void |
|---|
| 28 |
FatalErrnoErrorFail(char const msg[]) |
|---|
| 29 |
{ |
|---|
| 30 |
extern int wrapper_exit_code; |
|---|
| 31 |
|
|---|
| 32 |
#ifdef ENSC_WRAPPERS_PREFIX |
|---|
| 33 |
{ |
|---|
| 34 |
int old_errno = errno; |
|---|
| 35 |
WRITE_MSG(2, ENSC_WRAPPERS_PREFIX); |
|---|
| 36 |
errno = old_errno; |
|---|
| 37 |
} |
|---|
| 38 |
#endif |
|---|
| 39 |
perror(msg); |
|---|
| 40 |
|
|---|
| 41 |
exit(wrapper_exit_code); |
|---|
| 42 |
} |
|---|
| 43 |
|
|---|
| 44 |
static UNUSED void |
|---|
| 45 |
FatalErrnoError(bool condition, char const msg[]) |
|---|
| 46 |
{ |
|---|
| 47 |
if (__builtin_expect(!condition,true)) return; |
|---|
| 48 |
FatalErrnoErrorFail(msg); |
|---|
| 49 |
} |
|---|