[haiku-gsoc] Re: Implementation Queries

  • From: Adrien Destugues <pulkomandy@xxxxxxxxxxxxx>
  • To: haiku-gsoc@xxxxxxxxxxxxx
  • Date: Tue, 20 Jun 2017 20:40:46 +0200

On Tue, Jun 20, 2017 at 08:06:06PM +0530, Vivek Roy wrote:

Also, I have defined two macros
<https://github.com/vivek-roy/haiku/blob/3c024be9dd0580a98722996fd16a655f9b6ca42b/headers/compatibility/linuxkpi/asm/atomic.h#L60>
:
#define unlikely(x)        x
#define likely(x)           x

I should probably change them to
#define unlikely(x)        (x)
#define likely(x)           (x)

But is that okay? Should I have them in a separate header (as it is used
everywhere in the linux kernel), or something better?

You can use gcc's __builtin_expect to perform what these macros do. IT
hints the compiler that a condition is likely (or unlikely) to be true,
helping it to optimize the "hot" code paths (executed often).

Where does Linux have them? Putting them in the same place in our
compatibility headers would help with not changing code imported from
Linux too much?

-- 
Adrien.

Other related posts: