mirror of
https://github.com/topjohnwu/Magisk.git
synced 2025-10-15 22:13:11 +00:00
Add new util function
This commit is contained in:
@@ -208,6 +208,7 @@ int parse_int(S __s) { return parse_int(__s.data()); }
|
||||
|
||||
int new_daemon_thread(void *(*start_routine) (void *), void *arg = nullptr,
|
||||
const pthread_attr_t *attr = nullptr);
|
||||
int new_daemon_thread(std::function<void()> &&fn);
|
||||
|
||||
struct exec_t {
|
||||
bool err = false;
|
||||
|
@@ -200,6 +200,17 @@ int new_daemon_thread(void *(*start_routine) (void *), void *arg, const pthread_
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void *proxy_routine(void *fp) {
|
||||
auto fn = reinterpret_cast<std::function<void()>*>(fp);
|
||||
(*fn)();
|
||||
delete fn;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
int new_daemon_thread(std::function<void()> &&fn) {
|
||||
return new_daemon_thread(proxy_routine, new std::function<void()>(std::move(fn)));
|
||||
}
|
||||
|
||||
static char *argv0;
|
||||
static size_t name_len;
|
||||
void init_argv0(int argc, char **argv) {
|
||||
|
Reference in New Issue
Block a user