From 887dfde3082bcb1057a965d365206b2ed3d0263b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20G=C3=B6ttsche?= Date: Tue, 27 Oct 2020 21:26:45 +0100 Subject: [PATCH] Implement Process_getParentPid and Process_isChildOf as functions Make it more readable and fix unenclosed macro arguments --- Process.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Process.h b/Process.h index 2432918f..b2c82080 100644 --- a/Process.h +++ b/Process.h @@ -129,9 +129,13 @@ typedef struct ProcessClass_ { #define As_Process(this_) ((const ProcessClass*)((this_)->super.klass)) -#define Process_getParentPid(process_) (process_->tgid == process_->pid ? process_->ppid : process_->tgid) +static inline pid_t Process_getParentPid(const Process* this) { + return this->tgid == this->pid ? this->ppid : this->tgid; +} -#define Process_isChildOf(process_, pid_) (process_->tgid == pid_ || (process_->tgid == process_->pid && process_->ppid == pid_)) +static inline bool Process_isChildOf(const Process* this, pid_t pid) { + return pid == Process_getParentPid(this); +} #define Process_sortState(state) ((state) == 'I' ? 0x100 : (state))