[haiku-gsoc] Re: Implementation Queries

  • From: Vivek Roy <vivekroyandroid@xxxxxxxxx>
  • To: haiku-gsoc@xxxxxxxxxxxxx
  • Date: Wed, 21 Jun 2017 00:17:36 +0530

Linux has it in linux/compiler.h
I will just include that (I already have that compiled correctly)

Can you just tell me why the freebsd_network compatibility layer has been
implemented in /src/libs/compat/freebsd_network/compat rather than say
headers/compatibility/freebsd_network? I might be needing a lot of those,
should I use them from src or copy the ones I require to headers?

On Wed, Jun 21, 2017 at 12:10 AM, Adrien Destugues <pulkomandy@xxxxxxxxxxxxx

wrote:

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/3c024be9dd0580a98722996fd16a65
5f9b6ca42b/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: