Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactoring conditional directives. #378

Open
wants to merge 1 commit into
base: 3.x
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 13 additions & 9 deletions galerautils/src/gu_dbug.c
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ struct state_map {
static struct state_map *_gu_db_state_map[_GU_DB_STATE_MAP_BUCKETS];

/*
* This hash is probably good enough. Golden ratio 2654435761U from
* This hash is probably good enough. Golden ratio 2654435761U from
* http://www.concentric.net/~Ttwang/tech/inthash.htm
*
* UPDATE: it is good enough for input with significant variation in
Expand Down Expand Up @@ -429,9 +429,9 @@ void state_map_insert(const pthread_t th, CODE_STATE *state)

unsigned int key;
struct state_map *sm;

assert(state_map_find(th) == NULL);

key = pt_hash(th);


Expand All @@ -440,13 +440,13 @@ void state_map_insert(const pthread_t th, CODE_STATE *state)
sm->th = th;

pthread_mutex_lock(&_gu_db_mutex);

sm->prev = NULL;
sm->next = _gu_db_state_map[key];
if (sm->next)
sm->next->prev = sm;
_gu_db_state_map[key] = sm;

pthread_mutex_unlock(&_gu_db_mutex);
}

Expand Down Expand Up @@ -500,7 +500,7 @@ static void code_state_cleanup(CODE_STATE *state)
static void _gu_db_init()
{
if (!_gu_db_fp_)
_gu_db_fp_ = stderr; /* Output stream, default stderr */
_gu_db_fp_ = stderr; /* Output stream, default stderr */
memset(_gu_db_state_map, 0, sizeof(_gu_db_state_map));
}

Expand Down Expand Up @@ -2016,10 +2016,13 @@ Delay(int ticks)
static void
dbug_flush(CODE_STATE * state)
{
int check_gu_flags = 1;
int no_check_gu_flags = 1;
#ifndef THREAD
if (_gu_db_stack->flags & FLUSH_ON_WRITE)
check_gu_flags = (_gu_db_stack->flags & FLUSH_ON_WRITE);
no_check_gu_flags = !(_gu_db_stack->flags & FLUSH_ON_WRITE);
#endif
{
if (check_gu_flags) {
#if defined(MSDOS) || defined(__WIN__)
if (_gu_db_fp_ != stdout && _gu_db_fp_ != stderr) {
if (!(freopen(_gu_db_stack->name, "a", _gu_db_fp_))) {
Expand All @@ -2029,8 +2032,9 @@ dbug_flush(CODE_STATE * state)
_gu_db_stack->out_file = _gu_db_fp_;
_gu_db_stack->flags |= FLUSH_ON_WRITE;
}
} else
}
#endif
if (no_check_gu_flags)
{
(void) fflush(_gu_db_fp_);
if (_gu_db_stack->delay)
Expand Down