As pointed out in an answer, there's some use of similar hints to compiler in say, FreeBSD and OpenBSD, but those hints coverage of Linux kernel code is a few magnitudes higher. It might make sense to change the wording to "almost don't use" but lets just keep it in mind

What other OSes except Linux are known to use that technique?

  • could be among the differences for unix.stackexchange.com/questions/118141/…
    – poige
    Commented Jun 27, 2020 at 17:02
  • Your edit attempt might be self-contained but of errors and some ignorance. unlike() isn't used at all. There's unlikely() though but I didn't mention it because likely() alone is enough to explain what is it about and link in the question has it even in deeper details.
    – poige
    Commented Jun 28, 2020 at 1:45
  • I'd rather post an article in blog about this — both about difference between Linux and BSDs and about why this question didn't make it on SE. People should know theirs "heroes". Reputation isn't only those SE numbers, remember.
    – poige
    Commented Jun 30, 2020 at 3:17

1 Answer 1


Well for starters there are …

… FreeBSD

% bsdgrep -r builtin_expect /usr/src/sys | wc -l
% bsdgrep -r predict_true /usr/src/sys | wc -l

… OpenBSD

$ grep -r builtin_expect /usr/src/sys | wc -l
$ grep -r predict_true /usr/src/sys | wc -l
  • ok, sounds good. ) But not that massively as in Linux kernel though.
    – poige
    Commented Jun 27, 2020 at 17:27
  • Inside kernel's kernel/ sub-dir alone: fgrep -r 'likely(' . | wc -l → 1023, it doesn't include neither network stack, nor filesystems.
    – poige
    Commented Jun 27, 2020 at 17:40
  • 1
    The results of grep do not tell one how "massively" something like this is used, just whether it is used, which is what you actually asked.
    – JdeBP
    Commented Jun 27, 2020 at 18:13
  • 1
    @poige The higher number of occurrences in source codes does not imply higher performance or even higher execution count.
    – undercat
    Commented Jun 27, 2020 at 22:41
  • @JdeBP also by "use" the whole question means "use by programmers", hence grep | wc -l does tell that indeed.
    – poige
    Commented Jun 28, 2020 at 3:18

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .