From 97f7c7a5499a5264561a200e8b9ffb68034c23c0 Mon Sep 17 00:00:00 2001 From: Jim Warner Date: Fri, 27 Sep 2019 00:00:00 -0500 Subject: [PATCH] library: removed that 'SIGNAL_STRING' conditional code No libprocps user expects signal values to be returned as 'long long' quantities. More importantly the api only returns a 'str' result for signal categories. So this patch eliminates all the conditional code that depends on the absence of the #define 'SIGNAL_STRING'. Signed-off-by: Jim Warner --- proc/readproc.c | 39 --------------------------------------- proc/readproc.h | 11 ----------- 2 files changed, 50 deletions(-) diff --git a/proc/readproc.c b/proc/readproc.c index 39667c16..9f492c52 100644 --- a/proc/readproc.c +++ b/proc/readproc.c @@ -69,21 +69,6 @@ struct utlbuf_s { int siz; // current len of the above } utlbuf_s; -#ifndef SIGNAL_STRING -// convert hex string to unsigned long long -static unsigned long long unhex(const char *restrict cp){ - unsigned long long ull = 0; - for(;;){ - char c = *cp++; - if(!( (c >= '0' && c <= '9') || - (c >= 'A' && c <= 'F') || - (c >= 'a' && c <= 'f') )) break; - ull = (ull<<4) | (c - (c >= 'a' ? 'a'-10 : c >= 'A' ? 'A'-10 : '0')); - } - return ull; -} -#endif - static int task_dir_missing; @@ -295,7 +280,6 @@ ENTER(0x220); S--; // put back the '\n' or '\0' continue; } -#ifdef SIGNAL_STRING case_ShdPnd: memcpy(P->signal, S, 16); P->signal[16] = '\0'; @@ -316,23 +300,6 @@ ENTER(0x220); memcpy(P->_sigpnd, S, 16); P->_sigpnd[16] = '\0'; continue; -#else - case_ShdPnd: - P->signal = unhex(S); - continue; - case_SigBlk: - P->blocked = unhex(S); - continue; - case_SigCgt: - P->sigcatch = unhex(S); - continue; - case_SigIgn: - P->sigignore = unhex(S); - continue; - case_SigPnd: - P->_sigpnd = unhex(S); - continue; -#endif case_State: P->state = *S; continue; @@ -437,16 +404,10 @@ ENTER(0x220); #endif // recent kernels supply per-tgid pending signals -#ifdef SIGNAL_STRING if(!is_proc || !P->signal[0]){ memcpy(P->signal, P->_sigpnd, 16); P->signal[16] = '\0'; } -#else - if(!is_proc){ - P->signal = P->_sigpnd; - } -#endif // Linux 2.4.13-pre1 to max 2.4.xx have a useless "Tgid" // that is not initialized for built-in kernel tasks. diff --git a/proc/readproc.h b/proc/readproc.h index 94400962..d6e30fab 100644 --- a/proc/readproc.h +++ b/proc/readproc.h @@ -15,7 +15,6 @@ #include #include -#define SIGNAL_STRING // the following is development only, forcing display of "[ duplicate ENUM ]" strings // #define FALSE_THREADS /* set most child string fields to NULL */ @@ -56,7 +55,6 @@ typedef struct proc_t { pcpu, // stat (special) elapsed tics for %CPU usage calculation maj_delta, // stat (special) major page faults since last update min_delta; // stat (special) minor page faults since last update -#ifdef SIGNAL_STRING char // Linux 2.1.7x and up have 64 signals. Allow 64, plus '\0' and padding. signal[18], // status mask of pending signals @@ -64,15 +62,6 @@ typedef struct proc_t { sigignore[18], // status mask of ignored signals sigcatch[18], // status mask of caught signals _sigpnd[18]; // status mask of PER TASK pending signals -#else - long long - // Linux 2.1.7x and up have 64 signals. - signal, // status mask of pending signals - blocked, // status mask of blocked signals - sigignore, // status mask of ignored signals - sigcatch, // status mask of caught signals - _sigpnd; // status mask of PER TASK pending signals -#endif unsigned long start_code, // stat address of beginning of code segment end_code, // stat address of end of code segment