From 54a201552db7477aa04a625fd5bc938ad8c97800 Mon Sep 17 00:00:00 2001 From: Tavian Barnes Date: Mon, 28 Feb 2011 18:12:01 -0500 Subject: New DMNSN_HOT macro. --- libdimension/compiler.h | 22 ++++++++++++++-------- libdimension/polynomial.c | 4 ++-- libdimension/prtree.c | 4 ++-- 3 files changed, 18 insertions(+), 12 deletions(-) (limited to 'libdimension') diff --git a/libdimension/compiler.h b/libdimension/compiler.h index 0500762..fb6c80f 100644 --- a/libdimension/compiler.h +++ b/libdimension/compiler.h @@ -29,16 +29,22 @@ #include #ifdef DMNSN_PROFILE -#define dmnsn_likely(test) \ - dmnsn_expect(!!(test), true, DMNSN_FUNC, __FILE__, __LINE__) -#define dmnsn_unlikely(test) \ - dmnsn_expect(!!(test), false, DMNSN_FUNC, __FILE__, __LINE__) + #define dmnsn_likely(test) \ + dmnsn_expect(!!(test), true, DMNSN_FUNC, __FILE__, __LINE__) + #define dmnsn_unlikely(test) \ + dmnsn_expect(!!(test), false, DMNSN_FUNC, __FILE__, __LINE__) #elif defined(__GNUC__) -#define dmnsn_likely(test) __builtin_expect(!!(test), true) -#define dmnsn_unlikely(test) __builtin_expect(!!(test), false) + #define dmnsn_likely(test) __builtin_expect(!!(test), true) + #define dmnsn_unlikely(test) __builtin_expect(!!(test), false) #else -#define dmnsn_likely(test) (test) -#define dmnsn_unlikely(test) (test) + #define dmnsn_likely(test) (test) + #define dmnsn_unlikely(test) (test) +#endif + +#ifdef __GNUC__ + #define DMNSN_HOT __attribute__((hot)) +#else + #define DMNSN_HOT #endif #endif /* DIMENSION_IMPL_COMPILER_H */ diff --git a/libdimension/polynomial.c b/libdimension/polynomial.c index 0c4168d..681f631 100644 --- a/libdimension/polynomial.c +++ b/libdimension/polynomial.c @@ -23,7 +23,7 @@ * Polynomials. */ -#include "dimension.h" +#include "dimension-impl.h" #include /** Get the real degree of a polynomial, ignoring leading zeros. */ @@ -394,7 +394,7 @@ dmnsn_solve_cubic(double poly[4], double x[3]) } /* Uspensky's algorithm */ -size_t +DMNSN_HOT size_t dmnsn_solve_polynomial(const double poly[], size_t degree, double x[]) { /* Copy the polynomial so we can be destructive */ diff --git a/libdimension/prtree.c b/libdimension/prtree.c index d95c2d2..9bab7c3 100644 --- a/libdimension/prtree.c +++ b/libdimension/prtree.c @@ -677,7 +677,7 @@ dmnsn_ray_box_intersection(dmnsn_optimized_line optline, return tmax >= dmnsn_max(0.0, tmin) && tmin < t; } -bool +DMNSN_HOT bool dmnsn_prtree_intersection(const dmnsn_prtree *tree, dmnsn_line ray, dmnsn_intersection *intersection) { @@ -722,7 +722,7 @@ dmnsn_prtree_intersection(const dmnsn_prtree *tree, dmnsn_line ray, return !isinf(t); } -bool +DMNSN_HOT bool dmnsn_prtree_inside(const dmnsn_prtree *tree, dmnsn_vector point) { /* Search the unbounded objects */ -- cgit v1.2.3