init: Move list and log handling to list.h and log.h
Change-Id: I298f575c590d0f28b7ad78747f3ebdbba56b7a27
This commit is contained in:
parent
12541c6131
commit
ed8a7d8442
|
@ -37,6 +37,7 @@
|
|||
#include "devices.h"
|
||||
#include "parser.h"
|
||||
#include "util.h"
|
||||
#include "log.h"
|
||||
|
||||
#include <private/android_filesystem_config.h>
|
||||
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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"
|
||||
|
|
41
init/init.h
41
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 */
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
#include <linux/keychord.h>
|
||||
|
||||
#include "init.h"
|
||||
#include "log.h"
|
||||
#include "property_service.h"
|
||||
|
||||
static struct input_keychord *keychords = 0;
|
||||
|
|
|
@ -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
|
|
@ -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
|
|
@ -25,7 +25,7 @@
|
|||
#include <linux/fb.h>
|
||||
#include <linux/kd.h>
|
||||
|
||||
#include "init.h"
|
||||
#include "log.h"
|
||||
|
||||
#ifdef ANDROID
|
||||
#include <cutils/memory.h>
|
||||
|
|
|
@ -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>
|
||||
|
||||
|
|
|
@ -44,6 +44,7 @@
|
|||
#include "property_service.h"
|
||||
#include "init.h"
|
||||
#include "util.h"
|
||||
#include "log.h"
|
||||
|
||||
#define PERSISTENT_PROPERTY_DIR "/data/property"
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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. */
|
||||
|
|
Loading…
Reference in New Issue