Cleanup C++ headers

This commit is contained in:
topjohnwu 2025-06-16 02:25:38 -07:00
parent 12340c9bd5
commit 1460317ebd
20 changed files with 14 additions and 48 deletions

View File

@ -291,15 +291,7 @@ def write_if_diff(file_name: Path, text: str):
def dump_flag_header(): def dump_flag_header():
flag_txt = textwrap.dedent( flag_txt = "#pragma once\n"
"""\
#pragma once
#define quote(s) #s
#define str(s) quote(s)
#define MAGISK_FULL_VER MAGISK_VERSION "(" str(MAGISK_VER_CODE) ")"
#define NAME_WITH_VER(name) str(name) " " MAGISK_FULL_VER
"""
)
flag_txt += f'#define MAGISK_VERSION "{config["version"]}"\n' flag_txt += f'#define MAGISK_VERSION "{config["version"]}"\n'
flag_txt += f'#define MAGISK_VER_CODE {config["versionCode"]}\n' flag_txt += f'#define MAGISK_VER_CODE {config["versionCode"]}\n'
flag_txt += f"#define MAGISK_DEBUG {0 if args.release else 1}\n" flag_txt += f"#define MAGISK_DEBUG {0 if args.release else 1}\n"

View File

@ -1,10 +1,8 @@
#include <sys/mman.h> #include <sys/mman.h>
#include <sys/sendfile.h> #include <sys/sendfile.h>
#include <sys/sysmacros.h>
#include <linux/fs.h> #include <linux/fs.h>
#include <fcntl.h> #include <fcntl.h>
#include <unistd.h> #include <unistd.h>
#include <libgen.h>
#include <base.hpp> #include <base.hpp>

View File

@ -1,5 +1,4 @@
#include <cstdio> #include <cstdio>
#include <cstdlib>
#include <android/log.h> #include <android/log.h>

View File

@ -1,9 +1,7 @@
#include <sys/types.h> #include <sys/types.h>
#include <sys/wait.h> #include <sys/wait.h>
#include <sys/prctl.h> #include <sys/prctl.h>
#include <sys/sysmacros.h>
#include <fcntl.h> #include <fcntl.h>
#include <pwd.h>
#include <unistd.h> #include <unistd.h>
#include <syscall.h> #include <syscall.h>
#include <random> #include <random>

View File

@ -43,6 +43,11 @@ static size_t restore(int fd, const char *filename) {
return size; return size;
} }
static bool check_env(const char *name) {
const char *val = getenv(name);
return val != nullptr && val == "true"sv;
}
void dyn_img_hdr::print() const { void dyn_img_hdr::print() const {
uint32_t ver = header_version(); uint32_t ver = header_version();
fprintf(stderr, "%-*s [%u]\n", PADDING, "HEADER_VER", ver); fprintf(stderr, "%-*s [%u]\n", PADDING, "HEADER_VER", ver);

View File

@ -1,9 +1,5 @@
#pragma once #pragma once
#include <sys/types.h>
#include <base.hpp>
#define HEADER_FILE "header" #define HEADER_FILE "header"
#define KERNEL_FILE "kernel" #define KERNEL_FILE "kernel"
#define RAMDISK_FILE "ramdisk.cpio" #define RAMDISK_FILE "ramdisk.cpio"
@ -21,10 +17,3 @@ void repack(const char *src_img, const char *out_img, bool skip_comp = false);
int verify(const char *image, const char *cert); int verify(const char *image, const char *cert);
int sign(const char *image, const char *name, const char *cert, const char *key); int sign(const char *image, const char *name, const char *cert, const char *key);
int split_image_dtb(const char *filename, bool skip_decomp = false); int split_image_dtb(const char *filename, bool skip_decomp = false);
int dtb_commands(int argc, char *argv[]);
static inline bool check_env(const char *name) {
using namespace std::string_view_literals;
const char *val = getenv(name);
return val != nullptr && val == "true"sv;
}

View File

@ -1,8 +1,7 @@
#include <sys/wait.h> #include <sys/wait.h>
#include <sys/mount.h> #include <sys/mount.h>
#include <consts.hpp> #include <core.hpp>
#include <base.hpp>
#include "deny.hpp" #include "deny.hpp"

View File

@ -1,12 +1,6 @@
#pragma once #pragma once
#include <pthread.h>
#include <string_view> #include <string_view>
#include <functional>
#include <map>
#include <atomic>
#include <core.hpp>
#define ISOLATED_MAGIC "isolated" #define ISOLATED_MAGIC "isolated"

View File

@ -1,10 +1,9 @@
#include <unistd.h> #include <unistd.h>
#include <string>
#include <cinttypes>
#include <android/log.h> #include <android/log.h>
#include <sys/syscall.h> #include <sys/syscall.h>
#include <string>
#include <base.hpp> #include <core.hpp>
#include "deny.hpp" #include "deny.hpp"

View File

@ -7,7 +7,6 @@
#include <set> #include <set>
#include <consts.hpp> #include <consts.hpp>
#include <base.hpp>
#include <sqlite.hpp> #include <sqlite.hpp>
#include <core.hpp> #include <core.hpp>

View File

@ -1,10 +1,8 @@
#pragma once #pragma once
#include <sys/socket.h> #include <sys/socket.h>
#include <pthread.h>
#include <poll.h> #include <poll.h>
#include <string> #include <string>
#include <limits>
#include <atomic> #include <atomic>
#include <functional> #include <functional>

View File

@ -46,6 +46,9 @@ Available applets:
exit(1); exit(1);
} }
#define quote(s) #s
#define str(s) quote(s)
int magisk_main(int argc, char *argv[]) { int magisk_main(int argc, char *argv[]) {
if (argc < 2) if (argc < 2)
usage(); usage();

View File

@ -1,3 +1,4 @@
#include <sys/mman.h>
#include <sys/mount.h> #include <sys/mount.h>
#include <sys/resource.h> #include <sys/resource.h>
#include <dlfcn.h> #include <dlfcn.h>

View File

@ -1,3 +1,4 @@
#include <sys/mman.h>
#include <android/dlext.h> #include <android/dlext.h>
#include <dlfcn.h> #include <dlfcn.h>

View File

@ -1,7 +1,6 @@
#pragma once #pragma once
#include <regex.h> #include <regex.h>
#include <bitset>
#include <list> #include <list>
#include "api.hpp" #include "api.hpp"

View File

@ -1,9 +1,6 @@
#pragma once #pragma once
#include <sys/mman.h>
#include <stdint.h>
#include <jni.h> #include <jni.h>
#include <vector>
#include <core.hpp> #include <core.hpp>
#if defined(__LP64__) #if defined(__LP64__)

View File

@ -1,6 +1,5 @@
#include <sys/sysmacros.h> #include <sys/sysmacros.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h>
#include <linux/input.h> #include <linux/input.h>
#include <fcntl.h> #include <fcntl.h>
#include <vector> #include <vector>

View File

@ -4,7 +4,6 @@
#include <libgen.h> #include <libgen.h>
#include <base.hpp> #include <base.hpp>
#include <flags.h>
#include <consts.hpp> #include <consts.hpp>
#include "init.hpp" #include "init.hpp"

View File

@ -1,11 +1,9 @@
#include <sys/mount.h> #include <sys/mount.h>
#include <libgen.h> #include <libgen.h>
#include <sys/sysmacros.h>
#include <sepolicy.hpp> #include <sepolicy.hpp>
#include <consts.hpp> #include <consts.hpp>
#include <base.hpp> #include <base.hpp>
#include <flags.h>
#include <xz.h> #include <xz.h>
#include "init.hpp" #include "init.hpp"

View File

@ -2,7 +2,6 @@
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h> #include <unistd.h>
#include <cil/cil.h> #include <cil/cil.h>