From 01b21b838b1895cda2c0044ca0d98d0b80aba981 Mon Sep 17 00:00:00 2001 From: ShirkNeko <109797057+ShirkNeko@users.noreply.github.com> Date: Fri, 11 Apr 2025 03:23:45 +0800 Subject: [PATCH] Add a check for atomic functions to the kernel Makefile and update the output with the relevant information --- kernel/Makefile | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/kernel/Makefile b/kernel/Makefile index 26d15911..9970b07c 100644 --- a/kernel/Makefile +++ b/kernel/Makefile @@ -85,6 +85,17 @@ else $(info -- KPM is disabled) endif +# 检查原子函数 +ifeq ($(shell grep -q "atomic_inc_not_zero" $(srctree)/kernel/cred.c; echo $$?),0) +ATOMIC_INC_FUNC = atomic_inc_not_zero +else ifeq ($(shell grep -q "atomic_long_inc_not_zero" $(srctree)/kernel/cred.c; echo $$?),0) +ATOMIC_INC_FUNC = atomic_long_inc_not_zero +else +$(info -- SukiSU: Neither atomic_inc_not_zero nor atomic_long_inc_not_zero found in kernel/cred.c) +endif + +$(info -- SukiSU: Using $(ATOMIC_INC_FUNC) in get_cred_rcu patch.) + ccflags-y += -DEXPECTED_SIZE=$(KSU_EXPECTED_SIZE) ccflags-y += -DEXPECTED_HASH=\"$(KSU_EXPECTED_HASH)\" @@ -133,16 +144,6 @@ ccflags-y += -DKSU_COMPAT_GET_CRED_RCU ccflags-y += -DKSU_UMOUNT endif -ifeq ($(shell grep -q "atomic_inc_not_zero" $(srctree)/kernel/cred.c; echo $$?),0) -ATOMIC_INC_FUNC = atomic_inc_not_zero -else ifeq ($(shell grep -q "atomic_long_inc_not_zero" $(srctree)/kernel/cred.c; echo $$?),0) -ATOMIC_INC_FUNC = atomic_long_inc_not_zero -else -$(info -- SukiSU: Neither atomic_inc_not_zero nor atomic_long_inc_not_zero found in kernel/cred.c) -endif - -$(info -- SukiSU: Using $(ATOMIC_INC_FUNC) in get_cred_rcu patch.) - ifneq ($(shell grep -Eq "^static inline const struct cred \*get_cred_rcu" $(srctree)/include/linux/cred.h; echo $$?),0) $(info -- SukiSU: adding function 'static inline const struct cred *get_cred_rcu(const struct cred *cred);' to $(srctree)/include/linux/cred.h) GET_CRED_RCU = static inline const struct cred *get_cred_rcu(const struct cred *cred)\n\