mirror of
https://github.com/topjohnwu/Magisk.git
synced 2024-11-23 18:15:30 +00:00
Improve excessive rapid root access performance
This commit is contained in:
parent
70a80090c4
commit
14c5c60863
@ -19,6 +19,7 @@ LOCAL_SRC_FILES := \
|
||||
utils/misc.c \
|
||||
utils/vector.c \
|
||||
utils/xwrap.c \
|
||||
utils/list.c \
|
||||
daemon/daemon.c \
|
||||
daemon/socket_trans.c \
|
||||
daemon/log_monitor.c \
|
||||
@ -40,7 +41,7 @@ LOCAL_SRC_FILES := \
|
||||
su/db.c \
|
||||
su/misc.c \
|
||||
su/pts.c \
|
||||
su/su_client.c \
|
||||
su/su_daemon.c \
|
||||
su/su_socket.c
|
||||
|
||||
LOCAL_CFLAGS := -Wno-implicit-exception-spec-mismatch
|
||||
|
2
jni/su
2
jni/su
@ -1 +1 @@
|
||||
Subproject commit 34fede71678201a0c7a7183d3ac0f8777f9238b2
|
||||
Subproject commit 4f570658cce06f5b07edb8cc4c2cd0f900bfec11
|
38
jni/utils/list.c
Normal file
38
jni/utils/list.c
Normal file
@ -0,0 +1,38 @@
|
||||
/* list.h - Double link list implementation
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "list.h"
|
||||
|
||||
void init_list_head(struct list_head *head) {
|
||||
head->next = head;
|
||||
head->prev = head;
|
||||
}
|
||||
|
||||
void list_insert(struct list_head *pos, struct list_head *node) {
|
||||
// First construct our new node
|
||||
node->next = pos->next;
|
||||
node->prev = pos;
|
||||
// Maintain the list
|
||||
pos->next->prev = node;
|
||||
pos->next = node;
|
||||
}
|
||||
|
||||
void list_insert_end(struct list_head *head, struct list_head *node) {
|
||||
list_insert(head->prev, node);
|
||||
}
|
||||
|
||||
void list_pop(struct list_head *pos) {
|
||||
// Maintain the list
|
||||
pos->prev->next = pos->next;
|
||||
pos->next->prev = pos->prev;
|
||||
// Remove references
|
||||
pos->next = pos;
|
||||
pos->prev = pos;
|
||||
}
|
||||
|
||||
void list_pop_end(struct list_head *head) {
|
||||
return list_pop(head->prev);
|
||||
}
|
30
jni/utils/list.h
Normal file
30
jni/utils/list.h
Normal file
@ -0,0 +1,30 @@
|
||||
/* list.h - Double link list implementation
|
||||
*/
|
||||
|
||||
#ifndef _LIST_H_
|
||||
#define _LIST_H_
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
struct list_head {
|
||||
struct list_head *next;
|
||||
struct list_head *prev;
|
||||
};
|
||||
|
||||
void init_list_head(struct list_head *head);
|
||||
void list_insert(struct list_head *pos, struct list_head *node);
|
||||
void list_insert_end(struct list_head *head, struct list_head *node);
|
||||
void list_pop(struct list_head *pos);
|
||||
void list_pop_end(struct list_head *head);
|
||||
|
||||
#define list_entry(ptr, type, member) ({ \
|
||||
const typeof( ((type *)0)->member ) *__mptr = (ptr); \
|
||||
(type *)( (char *)__mptr - offsetof(type,member) );})
|
||||
|
||||
#define list_for_each(pos, head) \
|
||||
for (pos = (head)->next; pos != (head); pos = pos->next)
|
||||
|
||||
#define list_for_each_r(pos, head) \
|
||||
for (pos = (head)->prev; pos != (head); pos = pos->prev)
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user