Change preprocessor macros to inline functions
authorgkostka <kostka.grzegorz@gmail.com>
Wed, 2 Dec 2015 12:12:52 +0000 (13:12 +0100)
committergkostka <kostka.grzegorz@gmail.com>
Wed, 2 Dec 2015 12:12:52 +0000 (13:12 +0100)
lwext4/ext4_bcache.h

index a7e514a26c4fc2ce6698a5fbe24052cb1e70c3c5..3e05bf472aa357ca6a20db152a33b190d42de36a 100644 (file)
@@ -102,27 +102,6 @@ struct ext4_buf {
        SLIST_ENTRY(ext4_buf) dirty_node;
 };
 
-#define ext4_bcache_insert_dirty_node(bc, buf) \
-do { \
-       if (!(buf)->on_dirty_list) {             \
-               SLIST_INSERT_HEAD(&(bc)->dirty_list, \
-                                 (buf),            \
-                                 dirty_node); \
-               (buf)->on_dirty_list = true;  \
-       } \
-} while (0)
-
-#define ext4_bcache_remove_dirty_node(bc, buf) \
-do { \
-       if ((buf)->on_dirty_list) {             \
-               SLIST_REMOVE(&(bc)->dirty_list,  \
-                               (buf),           \
-                               ext4_buf,      \
-                               dirty_node);   \
-               (buf)->on_dirty_list = false;  \
-       } \
-} while (0)
-
 /**@brief   Block cache descriptor*/
 struct ext4_bcache {
 
@@ -176,6 +155,29 @@ enum bcache_state_bits {
            .lru_ctr = 0,                                                      \
        }
 
+/**@brief   Insert buffer to dirty cache list
+ * @param   bc block cache descriptor
+ * @param   buf buffer descriptor */
+static inline void
+ext4_bcache_insert_dirty_node(struct ext4_bcache *bc, struct ext4_buf *buf) {
+       if (!buf->on_dirty_list) {
+               SLIST_INSERT_HEAD(&bc->dirty_list, buf, dirty_node);
+               buf->on_dirty_list = true;
+       }
+}
+
+/**@brief   Remove buffer to dirty cache list
+ * @param   bc block cache descriptor
+ * @param   buf buffer descriptor */
+static inline void
+ext4_bcache_remove_dirty_node(struct ext4_bcache *bc, struct ext4_buf *buf) {
+       if (buf->on_dirty_list) {
+               SLIST_REMOVE(&bc->dirty_list, buf, ext4_buf, dirty_node);
+               buf->on_dirty_list = false;
+       }
+}
+
+
 /**@brief   Dynamic initialization of block cache.
  * @param   bc block cache descriptor
  * @param   cnt items count in block cache