init: Move list and log handling to list.h and log.h

Change-Id: I298f575c590d0f28b7ad78747f3ebdbba56b7a27
diff --git a/init/builtins.c b/init/builtins.c
index 3c29f0c..1c839cd 100644
--- a/init/builtins.c
+++ b/init/builtins.c
@@ -37,6 +37,7 @@
 #include "devices.h"
 #include "parser.h"
 #include "util.h"
+#include "log.h"
 
 #include <private/android_filesystem_config.h>
 
diff --git a/init/devices.c b/init/devices.c
index 3263e5e..452e7e7 100644
--- a/init/devices.c
+++ b/init/devices.c
@@ -32,9 +32,10 @@
 #include <sys/time.h>
 #include <asm/page.h>
 
-#include "init.h"
 #include "devices.h"
 #include "util.h"
+#include "log.h"
+#include "list.h"
 
 #define CMDLINE_PREFIX  "/dev"
 #define SYSFS_PREFIX    "/sys"
diff --git a/init/init.c b/init/init.c
index 936880a..e2889b6 100755
--- a/init/init.c
+++ b/init/init.c
@@ -40,6 +40,8 @@
 
 #include "devices.h"
 #include "init.h"
+#include "list.h"
+#include "log.h"
 #include "property_service.h"
 #include "bootchart.h"
 #include "signal_handler.h"
diff --git a/init/init.h b/init/init.h
index 9d12604..59d72c0 100644
--- a/init/init.h
+++ b/init/init.h
@@ -17,47 +17,10 @@
 #ifndef _INIT_INIT_H
 #define _INIT_INIT_H
 
+#include "list.h"
+
 void handle_control_message(const char *msg, const char *arg);
 
-void log_init(void);
-void log_set_level(int level);
-void log_close(void);
-void log_write(int level, const char *fmt, ...)
-    __attribute__ ((format(printf, 2, 3)));
-
-#define ERROR(x...)   log_write(3, "<3>init: " x)
-#define NOTICE(x...)  log_write(5, "<5>init: " x)
-#define INFO(x...)    log_write(6, "<6>init: " x)
-
-#define LOG_DEFAULT_LEVEL  3  /* messages <= this level are logged */
-#define LOG_UEVENTS        0  /* log uevent messages if 1. verbose */
-
-struct listnode
-{
-    struct listnode *next;
-    struct listnode *prev;
-};
-
-#define node_to_item(node, container, member) \
-    (container *) (((char*) (node)) - offsetof(container, member))
-
-#define list_declare(name) \
-    struct listnode name = { \
-        .next = &name, \
-        .prev = &name, \
-    }
-
-#define list_for_each(node, list) \
-    for (node = (list)->next; node != (list); node = node->next)
-
-void list_init(struct listnode *list);
-void list_add_tail(struct listnode *list, struct listnode *item);
-void list_remove(struct listnode *item);
-
-#define list_empty(list) ((list) == (list)->next)
-#define list_head(list) ((list)->next)
-#define list_tail(list) ((list)->prev)
-
 struct command
 {
         /* list of commands in an action */
diff --git a/init/keychords.c b/init/keychords.c
index bc286dd..53ab391 100644
--- a/init/keychords.c
+++ b/init/keychords.c
@@ -22,6 +22,7 @@
 #include <linux/keychord.h>
 
 #include "init.h"
+#include "log.h"
 #include "property_service.h"
 
 static struct input_keychord *keychords = 0;
diff --git a/init/list.h b/init/list.h
new file mode 100644
index 0000000..04cb0d3
--- /dev/null
+++ b/init/list.h
@@ -0,0 +1,46 @@
+/*
+ * Copyright (C) 2010 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef _INIT_LIST_H_
+#define _INIT_LIST_H_
+
+struct listnode
+{
+    struct listnode *next;
+    struct listnode *prev;
+};
+
+#define node_to_item(node, container, member) \
+    (container *) (((char*) (node)) - offsetof(container, member))
+
+#define list_declare(name) \
+    struct listnode name = { \
+        .next = &name, \
+        .prev = &name, \
+    }
+
+#define list_for_each(node, list) \
+    for (node = (list)->next; node != (list); node = node->next)
+
+void list_init(struct listnode *list);
+void list_add_tail(struct listnode *list, struct listnode *item);
+void list_remove(struct listnode *item);
+
+#define list_empty(list) ((list) == (list)->next)
+#define list_head(list) ((list)->next)
+#define list_tail(list) ((list)->prev)
+
+#endif
diff --git a/init/log.h b/init/log.h
new file mode 100644
index 0000000..3d93965
--- /dev/null
+++ b/init/log.h
@@ -0,0 +1,33 @@
+/*
+ * Copyright (C) 2010 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef _INIT_LOG_H_
+#define _INIT_LOG_H_
+
+void log_init(void);
+void log_set_level(int level);
+void log_close(void);
+void log_write(int level, const char *fmt, ...)
+    __attribute__ ((format(printf, 2, 3)));
+
+#define ERROR(x...)   log_write(3, "<3>init: " x)
+#define NOTICE(x...)  log_write(5, "<5>init: " x)
+#define INFO(x...)    log_write(6, "<6>init: " x)
+
+#define LOG_DEFAULT_LEVEL  3  /* messages <= this level are logged */
+#define LOG_UEVENTS        0  /* log uevent messages if 1. verbose */
+
+#endif
diff --git a/init/logo.c b/init/logo.c
index 6a740bf..614224c 100644
--- a/init/logo.c
+++ b/init/logo.c
@@ -25,7 +25,7 @@
 #include <linux/fb.h>
 #include <linux/kd.h>
 
-#include "init.h"
+#include "log.h"
 
 #ifdef ANDROID
 #include <cutils/memory.h>
diff --git a/init/parser.c b/init/parser.c
index b045216..b085da8 100644
--- a/init/parser.c
+++ b/init/parser.c
@@ -11,6 +11,8 @@
 #include "property_service.h"
 #include "parser.h"
 #include "util.h"
+#include "list.h"
+#include "log.h"
 
 #include <cutils/iosched_policy.h>
 
diff --git a/init/property_service.c b/init/property_service.c
index b1c6552..a5a7a70 100644
--- a/init/property_service.c
+++ b/init/property_service.c
@@ -44,6 +44,7 @@
 #include "property_service.h"
 #include "init.h"
 #include "util.h"
+#include "log.h"
 
 #define PERSISTENT_PROPERTY_DIR  "/data/property"
 
diff --git a/init/signal_handler.c b/init/signal_handler.c
index e5d308d..3e5d136 100644
--- a/init/signal_handler.c
+++ b/init/signal_handler.c
@@ -26,7 +26,9 @@
 #include <sys/reboot.h>
 
 #include "init.h"
+#include "list.h"
 #include "util.h"
+#include "log.h"
 
 static int signal_fd = -1;
 static int signal_recv_fd = -1;
diff --git a/init/util.c b/init/util.c
index a56ba0d..b955e7e 100644
--- a/init/util.c
+++ b/init/util.c
@@ -33,7 +33,8 @@
 
 #include <private/android_filesystem_config.h>
 
-#include "init.h"
+#include "log.h"
+#include "list.h"
 
 static int log_fd = -1;
 /* Inital log level before init.rc is parsed and this this is reset. */