-3

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?

poige
  • 6,195
  • 2
  • 30
  • 57
  • could be among the differences for https://unix.stackexchange.com/questions/118141/bsd-kernel-vs-linux-kernel – poige Jun 27 '20 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 Jun 28 '20 at 01: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 Jun 30 '20 at 03:17

1 Answers1

3

Well for starters there are …

… FreeBSD

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

… OpenBSD

$ grep -r builtin_expect /usr/src/sys | wc -l
       4
$ grep -r predict_true /usr/src/sys | wc -l
      51
$ 
JdeBP
  • 66,967
  • 12
  • 159
  • 343
  • ok, sounds good. ) But not that massively as in Linux kernel though. – poige Jun 27 '20 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 Jun 27 '20 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 Jun 27 '20 at 18:13
  • 1
    @poige The higher number of occurrences in source codes does not imply higher performance or even higher execution count. – undercat Jun 27 '20 at 22:41
  • @JdeBP also by "use" the whole question means "use by programmers", hence `grep | wc -l` does tell that indeed. – poige Jun 28 '20 at 03:18
  • @undercatapplaudsMonica the question isn't about performance comparison. Obviously number of codepaths covered with `likely()`/`unlikely()` hints in Linux kernel code by order of magnitudes exceeds those in given examples for Open- and FreeBSD. – poige Jun 28 '20 at 07:00