[hipl-dev] [Branch ~hipl-core/hipl/trunk] Rev 5224: De-inline hip_lp_next and move it from the .h file to the .c file.

  • From: noreply@xxxxxxxxxxxxx
  • To: HIPL core team <hipl-dev@xxxxxxxxxxxxx>
  • Date: Tue, 30 Nov 2010 14:44:41 -0000

------------------------------------------------------------
revno: 5224
committer: Diego Biurrun <diego@xxxxxxxxxx>
branch nick: hipl
timestamp: Tue 2010-11-30 15:40:39 +0100
message:
  De-inline hip_lp_next and move it from the .h file to the .c file.
  
  The inlined function was causing trouble when compiling with -Os:
  firewall/port_bindings.c: In function ‘hip_port_bindings_get’:
  firewall/line_parser.h:97: error: inlining failed in call to ‘hip_lp_next’: 
optimizing for size and code size would grow
  firewall/port_bindings.c:352: error: called from here
  firewall/line_parser.h:97: error: inlining failed in call to ‘hip_lp_next’: 
optimizing for size and code size would grow
  firewall/port_bindings.c:371: error: called from here
  
  Since we need to build with -Os at least for OpenWrt, deinlining this
  function appears to be the most sensible compromise.
modified:
  firewall/line_parser.c
  firewall/line_parser.h


--
lp:hipl
https://code.launchpad.net/~hipl-core/hipl/trunk

Your team HIPL core team is subscribed to branch lp:hipl.
To unsubscribe from this branch go to 
https://code.launchpad.net/~hipl-core/hipl/trunk/+edit-subscription
=== modified file 'firewall/line_parser.c'
--- firewall/line_parser.c      2010-11-12 17:49:42 +0000
+++ firewall/line_parser.c      2010-11-30 14:40:39 +0000
@@ -83,3 +83,46 @@
         lp->cur = NULL;
     }
 }
+
+/**
+ * Get the next line in a parsing pass with a line parser.
+ *
+ * Each invocation of this function returns a pointer to consecutive lines in
+ * the buffer to parse.
+ * After the last line has been reached, NULL is returned.
+ * In that case, parsing can restart by calling hip_lp_first().
+ *
+ * @param lp the line parser parser to use.
+ * @return a pointer to a line in the buffer or NULL if there are no more lines
+ *  available.
+ */
+char *hip_lp_next(struct hip_line_parser *const lp)
+{
+    size_t remaining;
+
+    if (!lp ||
+        !lp->cur ||
+        !lp->ma ||
+        !lp->ma->start ||
+        !lp->ma->end ||
+        lp->cur < lp->ma->start ||
+        lp->cur >= lp->ma->end) {
+        return NULL;
+    }
+
+    remaining   = lp->ma->end - lp->cur;
+    lp->cur     = memchr(lp->cur, '\n', remaining);
+
+    // given the rest of the parsing code, we should always find a \n, but
+    // let's check to be sure
+    if (lp->cur) {
+        // cur should not point to the new-line character but to the next one:
+        lp->cur += 1;
+        // is there text on the line here or are we at the end?
+        if (lp->cur >= lp->ma->end) {
+            lp->cur = NULL;
+        }
+    }
+
+    return lp->cur;
+}

=== modified file 'firewall/line_parser.h'
--- firewall/line_parser.h      2010-11-30 10:47:41 +0000
+++ firewall/line_parser.h      2010-11-30 14:40:39 +0000
@@ -40,6 +40,7 @@
 int hip_lp_create(struct hip_line_parser *const lp,
                   const struct hip_mem_area *const ma);
 void hip_lp_delete(struct hip_line_parser *const lp);
+char *hip_lp_next(struct hip_line_parser *const lp);
 
 /**
  * Represents the parsing state on a memory area object.
@@ -82,47 +83,4 @@
     return lp->cur;
 }
 
-/**
- * Get the next line in a parsing pass with a line parser.
- *
- * Each invocation of this function returns a pointer to consecutive lines in
- * the buffer to parse.
- * After the last line has been reached, NULL is returned.
- * In that case, parsing can restart by calling hip_lp_first().
- *
- * @param lp the line parser parser to use.
- * @return a pointer to a line in the buffer or NULL if there are no more lines
- *  available.
- */
-static inline char *hip_lp_next(struct hip_line_parser *const lp)
-{
-    size_t remaining;
-
-    if (!lp ||
-        !lp->cur ||
-        !lp->ma ||
-        !lp->ma->start ||
-        !lp->ma->end ||
-        lp->cur < lp->ma->start ||
-        lp->cur >= lp->ma->end) {
-        return NULL;
-    }
-
-    remaining   = lp->ma->end - lp->cur;
-    lp->cur     = memchr(lp->cur, '\n', remaining);
-
-    // given the rest of the parsing code, we should always find a \n, but
-    // let's check to be sure
-    if (lp->cur) {
-        // cur should not point to the new-line character but to the next one:
-        lp->cur += 1;
-        // is there text on the line here or are we at the end?
-        if (lp->cur >= lp->ma->end) {
-            lp->cur = NULL;
-        }
-    }
-
-    return lp->cur;
-}
-
 #endif /* HIP_FIREWALL_LINE_PARSER_H */

Other related posts:

  • » [hipl-dev] [Branch ~hipl-core/hipl/trunk] Rev 5224: De-inline hip_lp_next and move it from the .h file to the .c file. - noreply