P99

◆ P99_HANDLE_ERRNO

#define P99_HANDLE_ERRNO
Value:
P00_BLK_START \
P00_BLK_DECL(int const, p99_errno, errno) \
switch (P99_UNLIKELY(!!p99_errno)) case true: \
P00_BLK_AFTER(errno = 0) \
switch (p99_errno) case 0:

Handle and reset errno.

This will inspect errno (which is expensive) exactly once. If errno is 0, it will do nothing as efficiently as possible. Otherwise it will execute the dependent block much as a switch statement:

fprintf(stderr, "The compiler should tell us that this fprintf here is unreachable.\n");
P99_XCASE EINTR : {
fprintf(stderr, "Autsch: call to schnoeck was interrupted!\n");
// do something else in that case
}
P99_XCASE ENOMEM :
fprintf(stderr, "Autsch: call to schnoeck didn't have enough memory!\n");
fprintf(stderr, "AUTSCH: call to schnoeck failed with unhandled case!\n");
perror("AUTSCH");
}
fprintf(stderr, "We are doing some common cleanup for the errno handling code.\n");
}

Definition at line 471 of file p99_block.h.

P99_XCASE
#define P99_XCASE
P99_HANDLE_ERRNO
#define P99_HANDLE_ERRNO
Handle and reset errno.
Definition: p99_block.h:471
P99_XDEFAULT
#define P99_XDEFAULT
P99_UNLIKELY
#define P99_UNLIKELY(...)
Mark the conditional expression as being unlikely.
Definition: p99_compiler.h:994
errno
errno
Definition: p99_constraint.h:199