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

Change-Id: I298f575c590d0f28b7ad78747f3ebdbba56b7a27
This commit is contained in:
Colin Cross 2010-04-19 17:05:34 -07:00
parent 12541c6131
commit ed8a7d8442
12 changed files with 95 additions and 42 deletions

View File

@ -37,6 +37,7 @@
#include "devices.h"
#include "parser.h"
#include "util.h"
#include "log.h"
#include <private/android_filesystem_config.h>

View File

@ -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"

View File

@ -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"

View File

@ -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 */

View File

@ -22,6 +22,7 @@
#include <linux/keychord.h>
#include "init.h"
#include "log.h"
#include "property_service.h"
static struct input_keychord *keychords = 0;

46
init/list.h Normal file
View File

@ -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

33
init/log.h Normal file
View File

@ -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

View File

@ -25,7 +25,7 @@
#include <linux/fb.h>
#include <linux/kd.h>
#include "init.h"
#include "log.h"
#ifdef ANDROID
#include <cutils/memory.h>

View File

@ -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>

View File

@ -44,6 +44,7 @@
#include "property_service.h"
#include "init.h"
#include "util.h"
#include "log.h"
#define PERSISTENT_PROPERTY_DIR "/data/property"

View File

@ -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;

View File

@ -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. */