This is my personal library I use for projects at Codam.
docker run -it -v ...:/home harmsmits/libtester /bin/bash
Credits to wikipedia.
#define likely(x) __builtin_expect(!!(x), 1)
#define unlikely(x) __builtin_expect(!!(x), 0)
An example:
const char *home_dir ;
home_dir = getenv("HOME");
if (likely(home_dir))
printf("home directory: %s\n", home_dir);
else
perror("getenv");
For above example, we have marked “if” condition as “likely()” true, so compiler
will put true code immediately after branch, and false code within the branch
instruction. In this way compiler can achieve optimization. But we won't use
likely() and unlikely() macros blindly. If prediction is correct, it means
there is zero cycle of jump instruction, but if prediction is wrong, then it
will take several cycles, because the processor will need to flush it’s pipeline
which is worst than no prediction.
Content type
Image
Digest
Size
173.8 MB
Last updated
over 6 years ago
docker pull harmsmits/libtester