[OPTIM] force inlining of large functions with gcc >= 3
GCC 3 and above do not inline large functions, which is a problem
with ebtree where most core functions are inlined.
This simple patch has both reduced code size and increased speed.
It should be back-ported to ebtree.
diff --git a/include/common/ebtree.h b/include/common/ebtree.h
index b737bc9..a2024bc 100644
--- a/include/common/ebtree.h
+++ b/include/common/ebtree.h
@@ -333,6 +333,17 @@
#endif
#endif
+/* By default, gcc does not inline large chunks of code, but we want it to
+ * respect our choices.
+ */
+#if !defined(forceinline)
+#if __GNUC__ < 3
+#define forceinline inline
+#else
+#define forceinline inline __attribute__((always_inline))
+#endif
+#endif
+
/* Support passing function parameters in registers. For this, the
* CONFIG_EBTREE_REGPARM macro has to be set to the maximal number of registers
* allowed. Some functions have intentionally received a regparm lower than
@@ -492,7 +503,7 @@
* a subtree of at least 2 entries. It will probably never be needed inlined,
* and it is not for end-user.
*/
-static inline struct eb_node *
+static forceinline struct eb_node *
__eb_insert_dup(struct eb_node *sub, struct eb_node *new)
{
struct eb_node *head = sub;
@@ -658,7 +669,7 @@
/* Removes a leaf node from the tree if it was still in it. Marks the node
* as unlinked.
*/
-static inline void __eb_delete(struct eb_node *node)
+static forceinline void __eb_delete(struct eb_node *node)
{
__label__ delete_unlink;
unsigned int pside, gpside, sibtype;