mirror of https://github.com/xzeldon/htop.git
Resolve DEBUG compilation issues
Use NDEBUG conditional instead of DEBUG. Do not call static functions in extern inline ones. Vector.c:67:11: error: static function 'Vector_isConsistent' is used in an inline function with external linkage [-Werror,-Wstatic-in-inline]
This commit is contained in:
parent
b7f63292e5
commit
d69585b82a
4
CRT.c
4
CRT.c
|
@ -631,13 +631,13 @@ void CRT_init(int delay, int colorScheme, bool allowUnicode) {
|
||||||
define_key(sequence, KEY_ALT('A' + (c - 'a')));
|
define_key(sequence, KEY_ALT('A' + (c - 'a')));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#ifndef DEBUG
|
|
||||||
struct sigaction act;
|
struct sigaction act;
|
||||||
sigemptyset (&act.sa_mask);
|
sigemptyset (&act.sa_mask);
|
||||||
act.sa_flags = (int)SA_RESETHAND;
|
act.sa_flags = (int)SA_RESETHAND;
|
||||||
act.sa_handler = CRT_handleSIGSEGV;
|
act.sa_handler = CRT_handleSIGSEGV;
|
||||||
sigaction (SIGSEGV, &act, &old_sigsegv_handler);
|
sigaction (SIGSEGV, &act, &old_sigsegv_handler);
|
||||||
#endif
|
|
||||||
signal(SIGTERM, CRT_handleSIGTERM);
|
signal(SIGTERM, CRT_handleSIGTERM);
|
||||||
signal(SIGQUIT, CRT_handleSIGTERM);
|
signal(SIGQUIT, CRT_handleSIGTERM);
|
||||||
use_default_colors();
|
use_default_colors();
|
||||||
|
|
|
@ -12,7 +12,7 @@ in the source distribution for its full text.
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifndef NDEBUG
|
||||||
|
|
||||||
static bool Hashtable_isConsistent(Hashtable* this) {
|
static bool Hashtable_isConsistent(Hashtable* this) {
|
||||||
int items = 0;
|
int items = 0;
|
||||||
|
@ -39,7 +39,7 @@ int Hashtable_count(Hashtable* this) {
|
||||||
return items;
|
return items;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif /* NDEBUG */
|
||||||
|
|
||||||
static HashtableItem* HashtableItem_new(unsigned int key, void* value) {
|
static HashtableItem* HashtableItem_new(unsigned int key, void* value) {
|
||||||
HashtableItem* this;
|
HashtableItem* this;
|
||||||
|
@ -124,7 +124,7 @@ void* Hashtable_remove(Hashtable* this, unsigned int key) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void* Hashtable_get(Hashtable* this, unsigned int key) {
|
void* Hashtable_get(Hashtable* this, unsigned int key) {
|
||||||
unsigned int index = key % this->size;
|
unsigned int index = key % this->size;
|
||||||
HashtableItem* bucketPtr = this->buckets[index];
|
HashtableItem* bucketPtr = this->buckets[index];
|
||||||
while (true) {
|
while (true) {
|
||||||
|
|
|
@ -26,11 +26,11 @@ struct Hashtable_ {
|
||||||
bool owner;
|
bool owner;
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifndef NDEBUG
|
||||||
|
|
||||||
int Hashtable_count(Hashtable* this);
|
int Hashtable_count(Hashtable* this);
|
||||||
|
|
||||||
#endif
|
#endif /* NDEBUG */
|
||||||
|
|
||||||
Hashtable* Hashtable_new(int size, bool owner);
|
Hashtable* Hashtable_new(int size, bool owner);
|
||||||
|
|
||||||
|
|
4
Object.c
4
Object.c
|
@ -12,7 +12,7 @@ ObjectClass Object_class = {
|
||||||
.extends = NULL
|
.extends = NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifndef NDEBUG
|
||||||
|
|
||||||
bool Object_isA(Object* o, const ObjectClass* klass) {
|
bool Object_isA(Object* o, const ObjectClass* klass) {
|
||||||
if (!o)
|
if (!o)
|
||||||
|
@ -26,4 +26,4 @@ bool Object_isA(Object* o, const ObjectClass* klass) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif /* NDEBUG */
|
||||||
|
|
4
Object.h
4
Object.h
|
@ -48,10 +48,10 @@ typedef union {
|
||||||
|
|
||||||
extern ObjectClass Object_class;
|
extern ObjectClass Object_class;
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifndef NDEBUG
|
||||||
|
|
||||||
bool Object_isA(Object* o, const ObjectClass* klass);
|
bool Object_isA(Object* o, const ObjectClass* klass);
|
||||||
|
|
||||||
#endif
|
#endif /* NDEBUG */
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
46
Vector.c
46
Vector.c
|
@ -38,9 +38,9 @@ void Vector_delete(Vector* this) {
|
||||||
free(this);
|
free(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifndef NDEBUG
|
||||||
|
|
||||||
static inline bool Vector_isConsistent(Vector* this) {
|
static bool Vector_isConsistent(Vector* this) {
|
||||||
assert(this->items <= this->arraySize);
|
assert(this->items <= this->arraySize);
|
||||||
if (this->owner) {
|
if (this->owner) {
|
||||||
for (int i = 0; i < this->items; i++)
|
for (int i = 0; i < this->items; i++)
|
||||||
|
@ -62,7 +62,18 @@ int Vector_count(Vector* this) {
|
||||||
return items;
|
return items;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
Object* Vector_get(Vector* this, int idx) {
|
||||||
|
assert(idx < this->items);
|
||||||
|
assert(Vector_isConsistent(this));
|
||||||
|
return this->array[idx];
|
||||||
|
}
|
||||||
|
|
||||||
|
int Vector_size(Vector* this) {
|
||||||
|
assert(Vector_isConsistent(this));
|
||||||
|
return this->items;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* NDEBUG */
|
||||||
|
|
||||||
void Vector_prune(Vector* this) {
|
void Vector_prune(Vector* this) {
|
||||||
assert(Vector_isConsistent(this));
|
assert(Vector_isConsistent(this));
|
||||||
|
@ -251,33 +262,6 @@ void Vector_set(Vector* this, int idx, void* data_) {
|
||||||
assert(Vector_isConsistent(this));
|
assert(Vector_isConsistent(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DEBUG
|
|
||||||
|
|
||||||
inline Object* Vector_get(Vector* this, int idx) {
|
|
||||||
assert(idx < this->items);
|
|
||||||
assert(Vector_isConsistent(this));
|
|
||||||
return this->array[idx];
|
|
||||||
}
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
// In this case, Vector_get is defined as a macro in vector.h
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef DEBUG
|
|
||||||
|
|
||||||
inline int Vector_size(Vector* this) {
|
|
||||||
assert(Vector_isConsistent(this));
|
|
||||||
return this->items;
|
|
||||||
}
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
// In this case, Vector_size is defined as a macro in vector.h
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
||||||
static void Vector_merge(Vector* this, Vector* v2) {
|
static void Vector_merge(Vector* this, Vector* v2) {
|
||||||
|
@ -303,7 +287,7 @@ void Vector_add(Vector* this, void* data_) {
|
||||||
assert(Vector_isConsistent(this));
|
assert(Vector_isConsistent(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
inline int Vector_indexOf(Vector* this, void* search_, Object_Compare compare) {
|
int Vector_indexOf(Vector* this, void* search_, Object_Compare compare) {
|
||||||
Object* search = search_;
|
Object* search = search_;
|
||||||
assert(Object_isA((Object*)search, this->type));
|
assert(Object_isA((Object*)search, this->type));
|
||||||
assert(compare);
|
assert(compare);
|
||||||
|
|
23
Vector.h
23
Vector.h
|
@ -28,12 +28,6 @@ Vector* Vector_new(ObjectClass* type, bool owner, int size);
|
||||||
|
|
||||||
void Vector_delete(Vector* this);
|
void Vector_delete(Vector* this);
|
||||||
|
|
||||||
#ifdef DEBUG
|
|
||||||
|
|
||||||
int Vector_count(Vector* this);
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void Vector_prune(Vector* this);
|
void Vector_prune(Vector* this);
|
||||||
|
|
||||||
void Vector_quickSort(Vector* this);
|
void Vector_quickSort(Vector* this);
|
||||||
|
@ -52,25 +46,18 @@ void Vector_moveDown(Vector* this, int idx);
|
||||||
|
|
||||||
void Vector_set(Vector* this, int idx, void* data_);
|
void Vector_set(Vector* this, int idx, void* data_);
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifndef NDEBUG
|
||||||
|
|
||||||
Object* Vector_get(Vector* this, int idx);
|
Object* Vector_get(Vector* this, int idx);
|
||||||
|
int Vector_size(Vector* this);
|
||||||
|
int Vector_count(Vector* this);
|
||||||
|
|
||||||
#else
|
#else /* NDEBUG */
|
||||||
|
|
||||||
#define Vector_get(v_, idx_) ((v_)->array[idx_])
|
#define Vector_get(v_, idx_) ((v_)->array[idx_])
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef DEBUG
|
|
||||||
|
|
||||||
int Vector_size(Vector* this);
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
#define Vector_size(v_) ((v_)->items)
|
#define Vector_size(v_) ((v_)->items)
|
||||||
|
|
||||||
#endif
|
#endif /* NDEBUG */
|
||||||
|
|
||||||
void Vector_add(Vector* this, void* data_);
|
void Vector_add(Vector* this, void* data_);
|
||||||
|
|
||||||
|
|
|
@ -670,7 +670,7 @@ static int handleNetlinkMsg(struct nl_msg *nlmsg, void *linuxProcess) {
|
||||||
|
|
||||||
if ((nlattr = nlattrs[TASKSTATS_TYPE_AGGR_PID]) || (nlattr = nlattrs[TASKSTATS_TYPE_NULL])) {
|
if ((nlattr = nlattrs[TASKSTATS_TYPE_AGGR_PID]) || (nlattr = nlattrs[TASKSTATS_TYPE_NULL])) {
|
||||||
stats = nla_data(nla_next(nla_data(nlattr), &rem));
|
stats = nla_data(nla_next(nla_data(nlattr), &rem));
|
||||||
assert(lp->super.pid == stats->ac_pid);
|
assert(lp->super.pid == (pid_t)stats->ac_pid);
|
||||||
timeDelta = (stats->ac_etime*1000 - lp->delay_read_time);
|
timeDelta = (stats->ac_etime*1000 - lp->delay_read_time);
|
||||||
#define BOUNDS(x) isnan(x) ? 0.0 : (x > 100) ? 100.0 : x;
|
#define BOUNDS(x) isnan(x) ? 0.0 : (x > 100) ? 100.0 : x;
|
||||||
#define DELTAPERC(x,y) BOUNDS((float) (x - y) / timeDelta * 100);
|
#define DELTAPERC(x,y) BOUNDS((float) (x - y) / timeDelta * 100);
|
||||||
|
|
Loading…
Reference in New Issue