Skip to content

Commit

Permalink
[config] support __builtin_expect LIKELY/UNLIKELY branch optimizations
Browse files Browse the repository at this point in the history
add EXPECT,LIKELY,UNLIKELY macros to feature.h as in the linux kernel and perl5
probe for __builtin_expect() support in a new auto::expect configure step

Usage: if (UNLIKELY(var == 0)) fail();

Add emacs mode:c support for test_c.in files, and relax the coda test for this.
Should be used in all test_c.in files.
  • Loading branch information
Reini Urban committed Mar 5, 2014
1 parent cea93bf commit f475d0b
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions config/gen/config_h/feature_h.in
Expand Up @@ -231,6 +231,28 @@ END_PRINT
}
}

/* from config/auto/expect */
END_PRINT
if (@has_builtin_expect@) {
print OUT <<'END_PRINT';
#define PARROT_HAS_BUILTIN_EXPECT 1
END_PRINT
}
else {
print OUT <<'END_PRINT';
#undef PARROT_HAS_BUILTIN_EXPECT
END_PRINT
}
print OUT <<'END_PRINT';
#ifdef PARROT_HAS_BUILTIN_EXPECT
# define EXPECT(expr,val) __builtin_expect(expr,val)
#else
# define EXPECT(expr,val) (expr)
#endif
#define LIKELY(cond) EXPECT((cond),1)
#define UNLIKELY(cond) EXPECT((cond),0)
END_PRINT

print OUT <<'END_PRINT';

/* from config/auto/expect */
Expand Down

0 comments on commit f475d0b

Please sign in to comment.