Set continuation indent to 2 tabs

This commit is contained in:
Rodrigo Arias 2022-09-30 10:25:09 +02:00
parent 994f5f2098
commit 99793dba10
27 changed files with 699 additions and 699 deletions

View File

@ -17,7 +17,7 @@ BraceWrapping:
AfterUnion: false
BeforeElse: false
ColumnLimit: 0
ContinuationIndentWidth: 8
ContinuationIndentWidth: 16
IncludeBlocks: Preserve
IndentCaseLabels: true
IndentWidth: 8

View File

@ -40,15 +40,15 @@ mark_dirty(struct ovni_chan *chan, enum chan_dirty dirty)
void
chan_th_init(struct ovni_ethread *th,
struct ovni_chan **update_list,
enum chan id,
enum chan_track track,
int init_st,
int enabled,
int dirty,
int row,
FILE *prv,
int64_t *clock)
struct ovni_chan **update_list,
enum chan id,
enum chan_track track,
int init_st,
int enabled,
int dirty,
int row,
FILE *prv,
int64_t *clock)
{
struct ovni_chan *chan = &th->chan[id];
int prvth = chan_to_prvtype[id];
@ -66,15 +66,15 @@ chan_th_init(struct ovni_ethread *th,
void
chan_cpu_init(struct ovni_cpu *cpu,
struct ovni_chan **update_list,
enum chan id,
enum chan_track track,
int init_st,
int enabled,
int dirty,
int row,
FILE *prv,
int64_t *clock)
struct ovni_chan **update_list,
enum chan id,
enum chan_track track,
int init_st,
int enabled,
int dirty,
int row,
FILE *prv,
int64_t *clock)
{
struct ovni_chan *chan = &cpu->chan[id];
int prvcpu = chan_to_prvtype[id];
@ -120,7 +120,7 @@ chan_enable(struct ovni_chan *chan, int enabled)
mark_dirty(chan, CHAN_DIRTY_ACTIVE);
} else {
dbg("already dirty chan %d: skip update list\n",
chan->id);
chan->id);
chan_dump_update_list(chan);
}
}
@ -155,10 +155,10 @@ chan_set(struct ovni_chan *chan, int st)
* just enabled; it may collide with a new state 0 set via chan_set()
* used by the tracking channels */
if (chan->dirty != CHAN_DIRTY_ACTIVE
&& chan->lastst >= 0
&& chan->lastst == st) {
&& chan->lastst >= 0
&& chan->lastst == st) {
err("chan_set id=%d cannot emit the state %d twice\n",
chan->id, st);
chan->id, st);
abort();
}
@ -173,7 +173,7 @@ chan_set(struct ovni_chan *chan, int st)
mark_dirty(chan, CHAN_DIRTY_VALUE);
} else {
dbg("already dirty chan %d: skip update list\n",
chan->id);
chan->id);
chan_dump_update_list(chan);
}
}
@ -197,7 +197,7 @@ chan_push(struct ovni_chan *chan, int st)
if (chan->lastst >= 0 && chan->lastst == st) {
err("chan_push id=%d cannot emit the state %d twice\n",
chan->id, st);
chan->id, st);
abort();
}
@ -233,7 +233,7 @@ chan_pop(struct ovni_chan *chan, int expected_st)
if (expected_st >= 0 && st != expected_st) {
err("chan_pop: unexpected channel state %d (expected %d)\n",
st, expected_st);
st, expected_st);
abort();
}
@ -250,7 +250,7 @@ chan_pop(struct ovni_chan *chan, int expected_st)
if (chan->lastst >= 0 && chan->lastst == st) {
err("chan_pop id=%d cannot emit the state %d twice\n",
chan->id, st);
chan->id, st);
abort();
}
@ -278,7 +278,7 @@ chan_ev(struct ovni_chan *chan, int ev)
if (chan->lastst >= 0 && chan->lastst == ev)
die("chan_ev id=%d cannot emit the state %d twice\n",
chan->id, ev);
chan->id, ev);
chan->ev = ev;
chan->t = *chan->clock;
@ -311,11 +311,11 @@ emit(struct ovni_chan *chan, int64_t t, int state)
* it has been enabled or disabled. Otherwise is a bug (ie. you have two
* consecutive ovni events?) */
if (chan->lastst != -1
&& chan->dirty == CHAN_DIRTY_VALUE
&& chan->lastst == state) {
&& chan->dirty == CHAN_DIRTY_VALUE
&& chan->lastst == state) {
/* TODO: Print the raw clock of the offending event */
die("emit: chan %d cannot emit the same state %d twice\n",
chan->id, state);
chan->id, state);
}
if (chan->lastst != state) {

View File

@ -8,27 +8,27 @@
void
chan_th_init(struct ovni_ethread *th,
struct ovni_chan **update_list,
enum chan id,
enum chan_track track,
int init_st,
int enabled,
int dirty,
int row,
FILE *prv,
int64_t *clock);
struct ovni_chan **update_list,
enum chan id,
enum chan_track track,
int init_st,
int enabled,
int dirty,
int row,
FILE *prv,
int64_t *clock);
void
chan_cpu_init(struct ovni_cpu *cpu,
struct ovni_chan **update_list,
enum chan id,
enum chan_track track,
int row,
int init_st,
int enabled,
int dirty,
FILE *prv,
int64_t *clock);
struct ovni_chan **update_list,
enum chan id,
enum chan_track track,
int row,
int init_st,
int enabled,
int dirty,
FILE *prv,
int64_t *clock);
void
chan_enable(struct ovni_chan *chan, int enabled);

View File

@ -27,13 +27,13 @@ emit(struct ovni_stream *stream, struct ovni_ev *ev)
uint64_t clock = ovni_ev_get_clock(ev);
printf("%s.%d.%d %ld %c%c%c",
stream->loom->hostname,
stream->proc->pid,
stream->thread->tid,
clock,
ev->header.model,
ev->header.category,
ev->header.value);
stream->loom->hostname,
stream->proc->pid,
stream->thread->tid,
clock,
ev->header.model,
ev->header.category,
ev->header.value);
int payloadsize = ovni_payload_size(ev);
if (payloadsize > 0) {
@ -90,7 +90,7 @@ dump_events(struct ovni_trace *trace)
if (lastclock > ovni_ev_get_clock(stream->cur_ev)) {
fprintf(stdout, "warning: backwards jump in time %lu -> %lu\n",
lastclock, ovni_ev_get_clock(stream->cur_ev));
lastclock, ovni_ev_get_clock(stream->cur_ev));
}
/* Emit current event */

110
src/emu.c
View File

@ -40,10 +40,10 @@ print_ev(struct ovni_stream *stream, struct ovni_ev *ev)
UNUSED(delta);
dbg(">>> %s.%d.%d %c %c %c % 20ld % 15ld ",
stream->loom->hostname,
stream->proc->pid,
stream->thread->tid,
ev->header.model, ev->header.category, ev->header.value, clock, delta);
stream->loom->hostname,
stream->proc->pid,
stream->thread->tid,
ev->header.model, ev->header.category, ev->header.value, clock, delta);
int payloadsize = ovni_payload_size(ev);
for (int i = 0; i < payloadsize; i++) {
@ -73,7 +73,7 @@ cpu_update_tracking_chan(struct ovni_chan *cpu_chan, struct ovni_ethread *th)
break;
default:
dbg("ignoring thread %d chan %d with track=%d\n",
th->tid, cpu_chan->id, cpu_chan->track);
th->tid, cpu_chan->id, cpu_chan->track);
return;
}
@ -98,9 +98,9 @@ cpu_update_tracking_chan(struct ovni_chan *cpu_chan, struct ovni_ethread *th)
/* Only CPU enabled: is this possible? Set to bad */
chan_set(cpu_chan, ST_BAD);
err("warning: cpu %s chan %d enabled but tracked thread %d chan disabled\n",
cpu_chan->cpu->name,
cpu_chan->id,
th->tid);
cpu_chan->cpu->name,
cpu_chan->id,
th->tid);
} else {
/* Both disabled: disable CPU channel if needed */
if (chan_is_enabled(cpu_chan))
@ -108,9 +108,9 @@ cpu_update_tracking_chan(struct ovni_chan *cpu_chan, struct ovni_ethread *th)
}
dbg("cpu %s chan %d enabled=%d state=%d\n",
cpu_chan->cpu->name, cpu_chan->id,
chan_is_enabled(cpu_chan),
chan_get_st(cpu_chan));
cpu_chan->cpu->name, cpu_chan->id,
chan_is_enabled(cpu_chan),
chan_get_st(cpu_chan));
}
void
@ -132,7 +132,7 @@ emu_cpu_update_chan(struct ovni_cpu *cpu, struct ovni_chan *cpu_chan)
break;
default:
dbg("ignoring %s chan %d with track=%d\n",
cpu->name, cpu_chan->id, cpu_chan->track);
cpu->name, cpu_chan->id, cpu_chan->track);
return;
}
@ -148,7 +148,7 @@ emu_cpu_update_chan(struct ovni_cpu *cpu, struct ovni_chan *cpu_chan)
/* A unique thread found: copy the state */
dbg("cpu_update_chan: unique thread %d found, updating chan %d\n",
th->tid, cpu_chan->id);
th->tid, cpu_chan->id);
cpu_update_tracking_chan(cpu_chan, th);
} else {
@ -186,7 +186,7 @@ propagate_channels(struct ovni_emu *emu)
struct ovni_chan *cpu_chan = &cpu->chan[th_chan->id];
dbg("propagate thread %d chan %d in cpu %s\n",
thread->tid, th_chan->id, cpu->name);
thread->tid, th_chan->id, cpu->name);
emu_cpu_update_chan(cpu, cpu_chan);
}
@ -330,7 +330,7 @@ print_progress(struct ovni_emu *emu)
double written = cpu_written + th_written;
double progress = ((double) emu->global_offset)
/ ((double) emu->global_size);
/ ((double) emu->global_size);
double time_now = get_time();
double time_elapsed = time_now - emu->start_emulation_time;
@ -344,12 +344,12 @@ print_progress(struct ovni_emu *emu)
int sec = (int) ((time_left / 60.0 - tmin) * 60);
err("%.1f%% done at %.0f Kev/s, out %.1f GB CPU / %.1f GB TH at %.1f MB/s (%d min %d s left)\n",
100.0 * progress,
speed_in / 1024.0,
cpu_written / (1024.0 * 1024.0 * 1024.0),
th_written / (1024.0 * 1024.0 * 1024.0),
speed_out / (1024.0 * 1024),
tmin, sec);
100.0 * progress,
speed_in / 1024.0,
cpu_written / (1024.0 * 1024.0 * 1024.0),
th_written / (1024.0 * 1024.0 * 1024.0),
speed_out / (1024.0 * 1024),
tmin, sec);
}
/* Loads the next event and sets the lastclock in the stream.
@ -405,7 +405,7 @@ next_event(struct ovni_emu *emu)
* */
if (emu->lastclock > stream->lastclock) {
err("warning: backwards jump in time %lu -> %lu for tid %d\n",
emu->lastclock, stream->lastclock, stream->tid);
emu->lastclock, stream->lastclock, stream->tid);
if (emu->enable_linter)
abort();
@ -508,11 +508,11 @@ add_new_cpu(struct ovni_emu *emu, struct ovni_loom *loom, int i, int phyid)
if (i < 0 || i >= (int) loom->ncpus)
die("CPU with index %d in loom %s is out of bounds\n",
i, loom->hostname);
i, loom->hostname);
if (cpu->state != CPU_ST_UNKNOWN)
die("new cpu %d in unexpected state in loom %s\n",
i, loom->hostname);
i, loom->hostname);
cpu->state = CPU_ST_READY;
cpu->i = i;
@ -525,8 +525,8 @@ add_new_cpu(struct ovni_emu *emu, struct ovni_loom *loom, int i, int phyid)
static int
proc_load_cpus(struct ovni_emu *emu, struct ovni_loom *loom,
struct ovni_eproc *proc,
struct ovni_eproc *metadata_proc)
struct ovni_eproc *proc,
struct ovni_eproc *metadata_proc)
{
JSON_Object *meta = json_value_get_object(proc->meta);
if (meta == NULL)
@ -540,8 +540,8 @@ proc_load_cpus(struct ovni_emu *emu, struct ovni_loom *loom,
if (metadata_proc)
die("duplicated metadata for proc %d and %d in loom %s\n",
metadata_proc->pid, proc->pid,
loom->hostname);
metadata_proc->pid, proc->pid,
loom->hostname);
if (loom->ncpus != 0)
die("loom %s already has CPUs\n", loom->hostname);
@ -550,7 +550,7 @@ proc_load_cpus(struct ovni_emu *emu, struct ovni_loom *loom,
if (loom->ncpus == 0)
die("loom %s proc %d has metadata but no CPUs\n",
loom->hostname, proc->pid);
loom->hostname, proc->pid);
loom->cpu = calloc(loom->ncpus, sizeof(struct ovni_cpu));
@ -575,7 +575,7 @@ proc_load_cpus(struct ovni_emu *emu, struct ovni_loom *loom,
struct ovni_cpu *vcpu = &loom->vcpu;
if (vcpu->state != CPU_ST_UNKNOWN)
die("unexpected virtual CPU state in loom %s\n",
loom->hostname);
loom->hostname);
vcpu->state = CPU_ST_READY;
vcpu->i = -1;
@ -608,8 +608,8 @@ load_metadata(struct ovni_emu *emu)
if (metadata_proc)
die("duplicated metadata found in pid %d and %d\n",
metadata_proc->pid,
proc->pid);
metadata_proc->pid,
proc->pid);
metadata_proc = proc;
}
@ -656,7 +656,7 @@ open_prvs(struct ovni_emu *emu, char *tracedir)
if (emu->prv_thread == NULL) {
err("error opening thread PRV file %s: %s\n", path,
strerror(errno));
strerror(errno));
exit(EXIT_FAILURE);
}
@ -666,7 +666,7 @@ open_prvs(struct ovni_emu *emu, char *tracedir)
if (emu->prv_cpu == NULL) {
err("error opening cpu PRV file %s: %s\n", path,
strerror(errno));
strerror(errno));
exit(EXIT_FAILURE);
}
@ -785,15 +785,15 @@ load_clock_offsets(struct ovni_emu *emu)
/* If provided by the user, it must exist */
if (f == NULL) {
err("error opening clock offset file %s: %s\n",
emu->clock_offset_file,
strerror(errno));
emu->clock_offset_file,
strerror(errno));
exit(EXIT_FAILURE);
}
} else {
char path[PATH_MAX];
if (snprintf(path, PATH_MAX, "%s/clock-offsets.txt",
emu->tracedir)
>= PATH_MAX) {
emu->tracedir)
>= PATH_MAX) {
die("clock offset path too long\n");
}
@ -830,7 +830,7 @@ load_clock_offsets(struct ovni_emu *emu)
if (ret != 5) {
err("fscanf read %d instead of 5 fields in %s\n",
ret, emu->clock_offset_file);
ret, emu->clock_offset_file);
exit(EXIT_FAILURE);
}
@ -929,7 +929,7 @@ init_threads(struct ovni_emu *emu)
}
emu->global_thread = calloc(emu->total_nthreads,
sizeof(*emu->global_thread));
sizeof(*emu->global_thread));
if (emu->global_thread == NULL) {
perror("calloc failed");
@ -958,7 +958,7 @@ init_cpus(struct ovni_emu *emu)
struct ovni_trace *trace = &emu->trace;
emu->global_cpu = calloc(emu->total_ncpus,
sizeof(*emu->global_cpu));
sizeof(*emu->global_cpu));
if (emu->global_cpu == NULL) {
perror("calloc");
@ -972,7 +972,7 @@ init_cpus(struct ovni_emu *emu)
emu->global_cpu[cpu->gindex] = cpu;
if (snprintf(cpu->name, MAX_CPU_NAME, "CPU %ld.%ld", i, j)
>= MAX_CPU_NAME) {
>= MAX_CPU_NAME) {
err("error cpu %ld.%ld name too long\n", i, j);
exit(EXIT_FAILURE);
}
@ -981,7 +981,7 @@ init_cpus(struct ovni_emu *emu)
emu->global_cpu[loom->vcpu.gindex] = &loom->vcpu;
if (snprintf(loom->vcpu.name, MAX_CPU_NAME, "CPU %ld.*", i)
>= MAX_CPU_NAME) {
>= MAX_CPU_NAME) {
err("error cpu %ld.* name too long\n", i);
exit(EXIT_FAILURE);
}
@ -1041,8 +1041,8 @@ emu_init(struct ovni_emu *emu, int argc, char *argv[])
emu->global_offset = 0;
err("loaded %ld cpus and %ld threads\n",
emu->total_ncpus,
emu->total_nthreads);
emu->total_ncpus,
emu->total_nthreads);
}
static void
@ -1081,11 +1081,11 @@ edie(struct ovni_emu *emu, const char *fmt, ...)
va_end(args);
fprintf(stderr, "fatal: while evaluating the event %c%c%c with clock=%ld in thread=%d\n",
emu->cur_ev->header.model,
emu->cur_ev->header.category,
emu->cur_ev->header.value,
emu->cur_ev->header.clock,
emu->cur_thread->tid);
emu->cur_ev->header.model,
emu->cur_ev->header.category,
emu->cur_ev->header.value,
emu->cur_ev->header.clock,
emu->cur_thread->tid);
abort();
}
@ -1101,11 +1101,11 @@ eerr(struct ovni_emu *emu, const char *fmt, ...)
va_end(args);
fprintf(stderr, "fatal: while evaluating the event %c%c%c with clock=%ld in thread=%d\n",
emu->cur_ev->header.model,
emu->cur_ev->header.category,
emu->cur_ev->header.value,
emu->cur_ev->header.clock,
emu->cur_thread->tid);
emu->cur_ev->header.model,
emu->cur_ev->header.category,
emu->cur_ev->header.value,
emu->cur_ev->header.clock,
emu->cur_thread->tid);
}
int

View File

@ -54,7 +54,7 @@ context_switch(struct ovni_emu *emu)
break;
default:
edie(emu, "unexpected value '%c' (expecting 'O' or 'I')\n",
emu->cur_ev->header.value);
emu->cur_ev->header.value);
}
}
@ -63,7 +63,7 @@ hook_pre_kernel(struct ovni_emu *emu)
{
if (emu->cur_ev->header.model != 'K')
edie(emu, "hook_pre_kernel: unexpected event with model %c\n",
emu->cur_ev->header.model);
emu->cur_ev->header.model);
switch (emu->cur_ev->header.category) {
case 'C':
@ -71,6 +71,6 @@ hook_pre_kernel(struct ovni_emu *emu)
break;
default:
edie(emu, "hook_pre_kernel: unexpected event with category %c\n",
emu->cur_ev->header.category);
emu->cur_ev->header.category);
}
}

View File

@ -89,7 +89,7 @@ chan_task_running(struct ovni_emu *emu, struct task *task)
static void
chan_task_switch(struct ovni_emu *emu,
struct task *prev, struct task *next)
struct task *prev, struct task *next)
{
struct ovni_ethread *th = emu->cur_thread;
@ -177,7 +177,7 @@ expand_transition_value(struct ovni_emu *emu, int was_running, int runs_now)
static void
update_task_channels(struct ovni_emu *emu,
char tr, struct task *prev, struct task *next)
char tr, struct task *prev, struct task *next)
{
switch (tr) {
case 'x':
@ -200,7 +200,7 @@ update_task_channels(struct ovni_emu *emu,
static void
enforce_task_rules(struct ovni_emu *emu,
char tr, struct task *prev, struct task *next)
char tr, struct task *prev, struct task *next)
{
UNUSED(prev);
@ -524,7 +524,7 @@ pre_ss(struct ovni_emu *emu, int st)
break;
default:
edie(emu, "unexpected value '%c' (expecting '[' or ']')\n",
emu->cur_ev->header.value);
emu->cur_ev->header.value);
}
}
@ -552,11 +552,11 @@ hook_pre_nanos6(struct ovni_emu *emu)
{
if (emu->cur_ev->header.model != '6')
edie(emu, "hook_pre_nanos6: unexpected event with model %c\n",
emu->cur_ev->header.model);
emu->cur_ev->header.model);
if (!emu->cur_thread->is_active) {
edie(emu, "hook_pre_nanos6: current thread %d not active\n",
emu->cur_thread->tid);
emu->cur_thread->tid);
}
switch (emu->cur_ev->header.category) {
@ -626,7 +626,7 @@ end_lint(struct ovni_emu *emu)
}
die("thread %d ended with %d extra stacked nanos6 subsystems, top=\"%s\"\n",
th->tid, ch->n - 1, name);
th->tid, ch->n - 1, name);
}
}
}

View File

@ -53,7 +53,7 @@ pre_subsystem(struct ovni_emu *emu, int st)
break;
default:
edie(emu, "unexpected value '%c' (expecting '[' or ']')\n",
emu->cur_ev->header.value);
emu->cur_ev->header.value);
}
}
@ -62,11 +62,11 @@ hook_pre_nodes(struct ovni_emu *emu)
{
if (emu->cur_ev->header.model != 'D')
edie(emu, "hook_pre_nodes: unexpected event with model %c\n",
emu->cur_ev->header.model);
emu->cur_ev->header.model);
if (!emu->cur_thread->is_running)
edie(emu, "hook_pre_nodes: current thread %d not running\n",
emu->cur_thread->tid);
emu->cur_thread->tid);
switch (emu->cur_ev->header.category) {
case 'R':

View File

@ -103,7 +103,7 @@ chan_task_running(struct ovni_emu *emu, struct task *task)
static void
chan_task_switch(struct ovni_emu *emu,
struct task *prev, struct task *next)
struct task *prev, struct task *next)
{
struct ovni_ethread *th = emu->cur_thread;
@ -168,7 +168,7 @@ update_task_state(struct ovni_emu *emu)
break;
default:
edie(emu, "unexpected Nanos6 task event value %c\n",
emu->cur_ev->header.value);
emu->cur_ev->header.value);
}
}
@ -192,7 +192,7 @@ expand_transition_value(struct ovni_emu *emu, int was_running, int runs_now)
static void
update_task_channels(struct ovni_emu *emu,
char tr, struct task *prev, struct task *next)
char tr, struct task *prev, struct task *next)
{
switch (tr) {
case 'x':
@ -269,7 +269,7 @@ pre_task(struct ovni_emu *emu)
break;
default:
edie(emu, "unexpected task event value %c\n",
emu->cur_ev->header.value);
emu->cur_ev->header.value);
}
}
@ -278,7 +278,7 @@ pre_type(struct ovni_emu *emu)
{
if (emu->cur_ev->header.value != 'c')
edie(emu, "unexpected event value %c\n",
emu->cur_ev->header.value);
emu->cur_ev->header.value);
if ((emu->cur_ev->header.flags & OVNI_EV_JUMBO) == 0)
edie(emu, "expecting a jumbo event\n");
@ -440,7 +440,7 @@ pre_ss(struct ovni_emu *emu, int st)
break;
default:
err("unexpected value '%c' (expecting '[' or ']')\n",
emu->cur_ev->header.value);
emu->cur_ev->header.value);
abort();
}
}
@ -459,7 +459,7 @@ check_affinity(struct ovni_emu *emu)
if (cpu->nrunning_threads > 1) {
edie(emu, "cpu %s has more than one thread running\n",
cpu->name);
cpu->name);
}
}
@ -468,11 +468,11 @@ hook_pre_nosv(struct ovni_emu *emu)
{
if (emu->cur_ev->header.model != 'V')
edie(emu, "hook_pre_nosv: unexpected event with model %c\n",
emu->cur_ev->header.model);
emu->cur_ev->header.model);
if (!emu->cur_thread->is_active)
edie(emu, "hook_pre_nosv: current thread %d not active\n",
emu->cur_thread->tid);
emu->cur_thread->tid);
switch (emu->cur_ev->header.category) {
case 'T':

View File

@ -53,7 +53,7 @@ pre_mode(struct ovni_emu *emu, int st)
break;
default:
err("unexpected value '%c' (expecting '[' or ']')\n",
emu->cur_ev->header.value);
emu->cur_ev->header.value);
abort();
}
}
@ -63,11 +63,11 @@ hook_pre_openmp(struct ovni_emu *emu)
{
if (emu->cur_ev->header.model != 'M')
die("hook_pre_openmp: unexpected event with model %c\n",
emu->cur_ev->header.model);
emu->cur_ev->header.model);
if (!emu->cur_thread->is_active)
die("hook_pre_openmp: current thread %d not active\n",
emu->cur_thread->tid);
emu->cur_thread->tid);
switch (emu->cur_ev->header.category) {
case 'T':

View File

@ -65,7 +65,7 @@ chan_tracking_update(struct ovni_chan *chan, struct ovni_ethread *th)
break;
default:
dbg("ignoring thread %d chan %d with track=%d\n",
th->tid, chan->id, chan->track);
th->tid, chan->id, chan->track);
return;
}
@ -74,7 +74,7 @@ chan_tracking_update(struct ovni_chan *chan, struct ovni_ethread *th)
return;
dbg("thread %d changes state to %d: chan %d enabled=%d\n",
th->tid, th->state, chan->id, enabled);
th->tid, th->state, chan->id, enabled);
chan_enable(chan, enabled);
}
@ -86,20 +86,20 @@ thread_set_state(struct ovni_ethread *th, enum ethread_state state)
/* The state must be updated when a cpu is set */
if (th->cpu == NULL)
die("thread_set_state: thread %d doesn't have a CPU\n",
th->tid);
th->tid);
dbg("thread_set_state: setting thread %d state %d\n",
th->tid, state);
th->tid, state);
th->state = state;
th->is_running = (state == TH_ST_RUNNING) ? 1 : 0;
th->is_active = (state == TH_ST_RUNNING
|| state == TH_ST_COOLING
|| state == TH_ST_WARMING)
? 1
: 0;
|| state == TH_ST_COOLING
|| state == TH_ST_WARMING)
? 1
: 0;
chan_set(&th->chan[CHAN_OVNI_STATE], th->state);
@ -190,7 +190,7 @@ cpu_add_thread(struct ovni_cpu *cpu, struct ovni_ethread *thread)
/* Found, abort */
if (emu_cpu_find_thread(cpu, thread) != NULL) {
err("The thread %d is already assigned to %s\n",
thread->tid, cpu->name);
thread->tid, cpu->name);
abort();
}
@ -208,7 +208,7 @@ cpu_remove_thread(struct ovni_cpu *cpu, struct ovni_ethread *thread)
/* Not found, abort */
if (p == NULL) {
err("cannot remove missing thread %d from cpu %s\n",
thread->tid, cpu->name);
thread->tid, cpu->name);
abort();
}
@ -220,8 +220,8 @@ cpu_remove_thread(struct ovni_cpu *cpu, struct ovni_ethread *thread)
static void
cpu_migrate_thread(struct ovni_cpu *cpu,
struct ovni_ethread *thread,
struct ovni_cpu *newcpu)
struct ovni_ethread *thread,
struct ovni_cpu *newcpu)
{
cpu_remove_thread(cpu, thread);
cpu_add_thread(newcpu, thread);
@ -234,10 +234,10 @@ thread_set_cpu(struct ovni_ethread *th, struct ovni_cpu *cpu)
{
if (th->cpu != NULL)
die("thread_set_cpu: thread %d already has a CPU\n",
th->tid);
th->tid);
dbg("thread_set_cpu: setting thread %d cpu to %s\n",
th->tid, cpu->name);
th->tid, cpu->name);
th->cpu = cpu;
chan_enable(&th->chan[CHAN_OVNI_CPU], 1);
@ -251,7 +251,7 @@ thread_unset_cpu(struct ovni_ethread *th)
{
if (th->cpu == NULL)
die("thread_unset_cpu: thread %d doesn't have a CPU\n",
th->tid);
th->tid);
th->cpu = NULL;
@ -265,7 +265,7 @@ thread_migrate_cpu(struct ovni_ethread *th, struct ovni_cpu *cpu)
{
if (th->cpu == NULL)
die("thread_migrate_cpu: thread %d doesn't have a CPU\n",
th->tid);
th->tid);
th->cpu = cpu;
chan_set(&th->chan[CHAN_OVNI_CPU], cpu->gindex + 1);
@ -277,7 +277,7 @@ pre_thread_execute(struct ovni_emu *emu, struct ovni_ethread *th)
/* The thread cannot be already running */
if (th->state == TH_ST_RUNNING)
edie(emu, "pre_thread_execute: thread %d already running\n",
th->tid);
th->tid);
int cpuid = emu->cur_ev->payload.i32[0];
@ -300,11 +300,11 @@ pre_thread_end(struct ovni_ethread *th)
{
if (th->state != TH_ST_RUNNING && th->state != TH_ST_COOLING)
die("pre_thread_end: thread %d not running or cooling\n",
th->tid);
th->tid);
if (th->cpu == NULL)
die("pre_thread_end: thread %d doesn't have a CPU\n",
th->tid);
th->tid);
/* First update the thread state */
thread_set_state(th, TH_ST_DEAD);
@ -320,11 +320,11 @@ pre_thread_pause(struct ovni_ethread *th)
{
if (th->state != TH_ST_RUNNING && th->state != TH_ST_COOLING)
die("pre_thread_pause: thread %d not running or cooling\n",
th->tid);
th->tid);
if (th->cpu == NULL)
die("pre_thread_pause: thread %d doesn't have a CPU\n",
th->tid);
th->tid);
thread_set_state(th, TH_ST_PAUSED);
update_cpu(th->cpu);
@ -335,11 +335,11 @@ pre_thread_resume(struct ovni_ethread *th)
{
if (th->state != TH_ST_PAUSED && th->state != TH_ST_WARMING)
die("pre_thread_resume: thread %d not paused or warming\n",
th->tid);
th->tid);
if (th->cpu == NULL)
die("pre_thread_resume: thread %d doesn't have a CPU\n",
th->tid);
th->tid);
thread_set_state(th, TH_ST_RUNNING);
update_cpu(th->cpu);
@ -350,11 +350,11 @@ pre_thread_cool(struct ovni_ethread *th)
{
if (th->state != TH_ST_RUNNING)
die("pre_thread_cool: thread %d not running\n",
th->tid);
th->tid);
if (th->cpu == NULL)
die("pre_thread_cool: thread %d doesn't have a CPU\n",
th->tid);
th->tid);
thread_set_state(th, TH_ST_COOLING);
update_cpu(th->cpu);
@ -365,11 +365,11 @@ pre_thread_warm(struct ovni_ethread *th)
{
if (th->state != TH_ST_PAUSED)
die("pre_thread_warm: thread %d not paused\n",
th->tid);
th->tid);
if (th->cpu == NULL)
die("pre_thread_warm: thread %d doesn't have a CPU\n",
th->tid);
th->tid);
thread_set_state(th, TH_ST_WARMING);
update_cpu(th->cpu);
@ -384,10 +384,10 @@ pre_thread(struct ovni_emu *emu)
switch (ev->header.value) {
case 'C': /* create */
dbg("thread %d creates a new thread at cpu=%d with args=%x %x\n",
th->tid,
ev->payload.u32[0],
ev->payload.u32[1],
ev->payload.u32[2]);
th->tid,
ev->payload.u32[0],
ev->payload.u32[1],
ev->payload.u32[2]);
break;
case 'x':
@ -410,7 +410,7 @@ pre_thread(struct ovni_emu *emu)
break;
default:
err("unknown thread event value %c\n",
ev->header.value);
ev->header.value);
exit(EXIT_FAILURE);
}
}
@ -423,11 +423,11 @@ pre_affinity_set(struct ovni_emu *emu)
if (th->cpu == NULL)
edie(emu, "pre_affinity_set: thread %d doesn't have a CPU\n",
th->tid);
th->tid);
if (!th->is_active)
edie(emu, "pre_affinity_set: thread %d is not active\n",
th->tid);
th->tid);
/* Migrate current cpu to the one at cpuid */
struct ovni_cpu *newcpu = emu_get_cpu(emu->cur_loom, cpuid);
@ -470,7 +470,7 @@ pre_affinity_remote(struct ovni_emu *emu)
if (remote_th == NULL) {
err("thread tid %d not found: cannot set affinity remotely\n",
tid);
tid);
abort();
}
}
@ -478,16 +478,16 @@ pre_affinity_remote(struct ovni_emu *emu)
/* The remote_th cannot be in states dead or unknown */
if (remote_th->state == TH_ST_DEAD)
edie(emu, "pre_affinity_remote: remote thread %d in state DEAD\n",
remote_th->tid);
remote_th->tid);
if (remote_th->state == TH_ST_UNKNOWN)
edie(emu, "pre_affinity_remote: remote thread %d in state UNKNOWN\n",
remote_th->tid);
remote_th->tid);
/* It must have an assigned CPU */
if (remote_th->cpu == NULL)
edie(emu, "pre_affinity_remote: remote thread %d has no CPU\n",
remote_th->tid);
remote_th->tid);
/* Migrate current cpu to the one at cpuid */
struct ovni_cpu *newcpu = emu_get_cpu(emu->cur_loom, cpuid);
@ -512,7 +512,7 @@ pre_affinity(struct ovni_emu *emu)
break;
default:
dbg("unknown affinity event value %c\n",
emu->cur_ev->header.value);
emu->cur_ev->header.value);
break;
}
}
@ -565,7 +565,7 @@ pre_flush(struct ovni_emu *emu)
break;
default:
err("unexpected value '%c' (expecting '[' or ']')\n",
emu->cur_ev->header.value);
emu->cur_ev->header.value);
abort();
}
}
@ -591,7 +591,7 @@ hook_pre_ovni(struct ovni_emu *emu)
break;
default:
dbg("unknown ovni event category %c\n",
emu->cur_ev->header.category);
emu->cur_ev->header.category);
break;
}
}

View File

@ -52,7 +52,7 @@ pre_tampi_mode(struct ovni_emu *emu, int state)
break;
default:
edie(emu, "unexpected event value %c for tampi mode\n",
emu->cur_ev->header.value);
emu->cur_ev->header.value);
}
}
@ -61,7 +61,7 @@ hook_pre_tampi(struct ovni_emu *emu)
{
if (emu->cur_ev->header.model != 'T')
edie(emu, "hook_pre_tampi: unexpected event with model %c\n",
emu->cur_ev->header.model);
emu->cur_ev->header.model);
switch (emu->cur_ev->header.category) {
case 'S':

View File

@ -30,12 +30,12 @@ task_type_find(struct task_type *types, uint32_t type_id)
void
task_create(struct ovni_emu *emu, struct task_info *info,
uint32_t type_id, uint32_t task_id)
uint32_t type_id, uint32_t task_id)
{
/* Ensure the task id is new */
if (task_find(info->tasks, task_id) != NULL)
edie(emu, "cannot create task: task_id %u already exists\n",
task_id);
task_id);
/* Ensure the type exists */
struct task_type *type = task_type_find(info->types, type_id);
@ -60,7 +60,7 @@ task_create(struct ovni_emu *emu, struct task_info *info,
void
task_execute(struct ovni_emu *emu,
struct task_stack *stack, struct task *task)
struct task_stack *stack, struct task *task)
{
if (task == NULL)
edie(emu, "cannot execute: task is NULL\n");
@ -90,7 +90,7 @@ task_execute(struct ovni_emu *emu,
void
task_pause(struct ovni_emu *emu,
struct task_stack *stack, struct task *task)
struct task_stack *stack, struct task *task)
{
if (task == NULL)
edie(emu, "cannot pause: task is NULL\n");
@ -117,7 +117,7 @@ task_pause(struct ovni_emu *emu,
void
task_resume(struct ovni_emu *emu,
struct task_stack *stack, struct task *task)
struct task_stack *stack, struct task *task)
{
if (task == NULL)
edie(emu, "cannot resume: task is NULL\n");
@ -144,7 +144,7 @@ task_resume(struct ovni_emu *emu,
void
task_end(struct ovni_emu *emu,
struct task_stack *stack, struct task *task)
struct task_stack *stack, struct task *task)
{
if (task == NULL)
edie(emu, "cannot end: task is NULL\n");
@ -222,7 +222,7 @@ task_type_create(struct task_info *info, uint32_t type_id, const char *label)
HASH_ADD_INT(info->types, id, type);
dbg("new task type created id=%d label=%s\n", type->id,
type->label);
type->label);
}
void

View File

@ -120,7 +120,7 @@ heap_get_move(size_t *node /*out*/)
// Round to previous po2
size_t base = (1ULL) << (sizeof(size_t) * 8
- __builtin_clzll(aux_node) - 1);
- __builtin_clzll(aux_node) - 1);
aux_node -= base / 2;

View File

@ -30,11 +30,11 @@ create_trace_stream(void)
char path[PATH_MAX];
int written = snprintf(path, PATH_MAX, "%s/thread.%d",
rproc.procdir, rthread.tid);
rproc.procdir, rthread.tid);
if (written >= PATH_MAX)
die("thread trace path too long: %s/thread.%d\n",
rproc.procdir, rthread.tid);
rproc.procdir, rthread.tid);
rthread.streamfd = open(path, O_WRONLY | O_CREAT, 0644);
@ -61,7 +61,7 @@ proc_metadata_store(JSON_Value *meta, const char *procdir)
if (snprintf(path, PATH_MAX, "%s/metadata.json", procdir) >= PATH_MAX)
die("metadata path too long: %s/metadata.json\n",
procdir);
procdir);
if (json_serialize_to_file_pretty(meta, path) != JSONSuccess)
die("failed to write process metadata\n");
@ -293,20 +293,20 @@ move_procdir_to_final(const char *procdir, const char *procdir_final)
char thread[PATH_MAX];
if (snprintf(thread, PATH_MAX, "%s/%s", procdir,
dirent->d_name)
>= PATH_MAX) {
dirent->d_name)
>= PATH_MAX) {
err("snprintf: path too large: %s/%s\n", procdir,
dirent->d_name);
dirent->d_name);
err = 1;
continue;
}
char thread_final[PATH_MAX];
if (snprintf(thread_final, PATH_MAX, "%s/%s", procdir_final,
dirent->d_name)
>= PATH_MAX) {
dirent->d_name)
>= PATH_MAX) {
err("snprintf: path too large: %s/%s\n", procdir_final,
dirent->d_name);
dirent->d_name);
err = 1;
continue;
}
@ -370,7 +370,7 @@ static void
write_stream_header(void)
{
struct ovni_stream_header *h =
(struct ovni_stream_header *) rthread.evbuf;
(struct ovni_stream_header *) rthread.evbuf;
memcpy(h->magic, OVNI_STREAM_MAGIC, 4);
h->version = OVNI_STREAM_VERSION;

View File

@ -91,7 +91,7 @@ usage(void)
fprintf(stderr, "%s: clock synchronization utility\n", progname);
fprintf(stderr, "\n");
fprintf(stderr, "Usage: %s [-o outfile] [-d ndrift_samples] [-v] [-n nsamples] [-w drift_delay]\n",
progname);
progname);
exit(EXIT_FAILURE);
}
@ -229,9 +229,9 @@ offset_compute_delta(struct offset *ref, struct offset *cur, int nsamples, int v
delta[i] = ref->clock_sample[i] - cur->clock_sample[i];
if (verbose) {
printf("rank=%d sample=%d delta=%f ref=%f cur=%f\n",
cur->rank, i, delta[i],
ref->clock_sample[i],
cur->clock_sample[i]);
cur->rank, i, delta[i],
ref->clock_sample[i],
cur->clock_sample[i]);
}
}
@ -325,14 +325,14 @@ build_offset_table(int nsamples, int rank, int verbose)
/* Then collect all the offsets into the rank 0 */
MPI_Gather(sendbuf, offset_size(nsamples), MPI_CHAR,
offset, offset_size(nsamples), MPI_CHAR,
0, MPI_COMM_WORLD);
offset, offset_size(nsamples), MPI_CHAR,
0, MPI_COMM_WORLD);
/* Finish the offsets by computing the deltas on rank 0 */
if (rank == 0) {
for (int i = 0; i < table->nprocs; i++) {
offset_compute_delta(offset, table->offset[i],
nsamples, verbose);
nsamples, verbose);
}
}
@ -369,13 +369,13 @@ static void
print_table_detailed(FILE *out, struct offset_table *table)
{
fprintf(out, "%-10s %-20s %-20s %-20s %-20s\n",
"rank", "hostname", "offset_median", "offset_mean", "offset_std");
"rank", "hostname", "offset_median", "offset_mean", "offset_std");
for (int i = 0; i < table->nprocs; i++) {
struct offset *offset = table->offset[i];
fprintf(out, "%-10d %-20s %-20ld %-20f %-20f\n",
i, offset->hostname, offset->offset,
offset->delta_mean, offset->delta_std);
i, offset->hostname, offset->offset,
offset->delta_mean, offset->delta_std);
}
}
@ -389,14 +389,14 @@ do_work(struct options *options, int rank)
if (rank == 0) {
if (mkpath(options->outpath, 0755) != 0) {
fprintf(stderr, "mkpath(%s) failed: %s\n",
options->outpath, strerror(errno));
options->outpath, strerror(errno));
exit(EXIT_FAILURE);
}
out = fopen(options->outpath, "w");
if (out == NULL) {
fprintf(stderr, "fopen(%s) failed: %s\n",
options->outpath, strerror(errno));
options->outpath, strerror(errno));
exit(EXIT_FAILURE);
}
}

View File

@ -859,7 +859,7 @@ parse_object_value(const char **string, size_t nesting)
}
SKIP_WHITESPACES(string);
if (**string != '}' || /* Trim object after parsing is over */
json_object_resize(output_object, json_object_get_count(output_object)) == JSONFailure) {
json_object_resize(output_object, json_object_get_count(output_object)) == JSONFailure) {
json_value_free(output_value);
return NULL;
}
@ -907,7 +907,7 @@ parse_array_value(const char **string, size_t nesting)
}
SKIP_WHITESPACES(string);
if (**string != ']' || /* Trim array after parsing is over */
json_array_resize(output_array, json_array_get_count(output_array)) == JSONFailure) {
json_array_resize(output_array, json_array_get_count(output_array)) == JSONFailure) {
json_value_free(output_value);
return NULL;
}
@ -2470,7 +2470,7 @@ json_value_equals(const JSON_Value *a, const JSON_Value *b)
}
for (i = 0; i < a_count; i++) {
if (!json_value_equals(json_array_get_value(a_array, i),
json_array_get_value(b_array, i))) {
json_array_get_value(b_array, i))) {
return 0;
}
}
@ -2486,7 +2486,7 @@ json_value_equals(const JSON_Value *a, const JSON_Value *b)
for (i = 0; i < a_count; i++) {
key = json_object_get_name(a_object, i);
if (!json_value_equals(json_object_get_value(a_object, key),
json_object_get_value(b_object, key))) {
json_object_get_value(b_object, key))) {
return 0;
}
}

View File

@ -378,7 +378,7 @@ create_type(struct pcf_file *pcf, enum chan c)
char label[MAX_PCF_LABEL];
int ret = snprintf(label, MAX_PCF_LABEL, "%s %s",
prefix, suffix);
prefix, suffix);
if (ret >= MAX_PCF_LABEL)
die("computed type label too long\n");
@ -399,7 +399,7 @@ pcf_open(struct pcf_file *pcf, char *path, int chantype)
if (pcf->f == NULL) {
die("cannot open PCF file '%s': %s\n",
path, strerror(errno));
path, strerror(errno));
}
/* Create default types and values */

View File

@ -53,10 +53,10 @@ void pcf_close(struct pcf_file *pcf);
struct pcf_type *pcf_find_type(struct pcf_file *pcf, int type_id);
struct pcf_type *pcf_add_type(struct pcf_file *pcf, int type_id,
const char *label);
const char *label);
struct pcf_value *pcf_add_value(struct pcf_type *type, int value,
const char *label);
const char *label);
struct pcf_value *pcf_find_value(struct pcf_type *type, int value);

View File

@ -96,7 +96,7 @@ find_destination(struct ring *r, uint64_t clock)
for (ssize_t i = start; i != end; i = i - 1 < 0 ? r->size - 1 : i - 1) {
if (r->ev[i]->header.clock < clock) {
dbg("found suitable position %ld events backwards\n",
nback);
nback);
return i;
}
nback++;
@ -121,7 +121,7 @@ ends_unsorted_region(struct ovni_ev *ev)
static void
sort_buf(uint8_t *src, uint8_t *buf, int64_t bufsize,
uint8_t *srcbad, uint8_t *srcnext)
uint8_t *srcbad, uint8_t *srcnext)
{
int64_t injected = 0;
@ -190,7 +190,7 @@ execute_sort_plan(struct sortplan *sp)
int64_t i0 = find_destination(sp->r, sp->bad0->header.clock);
if (i0 < 0) {
err("cannot find destination for region starting at clock %ld\n",
sp->bad0->header.clock);
sp->bad0->header.clock);
return -1;
}
@ -209,7 +209,7 @@ execute_sort_plan(struct sortplan *sp)
die("malloc failed: %s\n", strerror(errno));
sort_buf((uint8_t *) first, buf, bufsize,
(uint8_t *) sp->bad0, (uint8_t *) sp->next);
(uint8_t *) sp->bad0, (uint8_t *) sp->next);
/* Copy the sorted events back into the stream buffer */
memcpy(first, buf, bufsize);
@ -264,7 +264,7 @@ stream_winsort(struct ovni_stream *stream, struct ring *r)
dbg("executing sort plan for stream tid=%d\n", stream->tid);
if (execute_sort_plan(&sp) < 0) {
err("sort failed for stream tid=%d\n",
stream->tid);
stream->tid);
return -1;
}
@ -281,7 +281,7 @@ stream_winsort(struct ovni_stream *stream, struct ring *r)
if (empty_regions > 0)
err("warning: stream %d contains %ld empty sort regions\n",
stream->tid, empty_regions);
stream->tid, empty_regions);
if (updated && fdatasync(fd) < 0)
die("fdatasync %s failed: %s\n", fn, strerror(errno));
@ -308,7 +308,7 @@ stream_check(struct ovni_stream *stream)
if (cur_clock < last_clock) {
err("backwards jump in time %ld -> %ld for stream tid=%d\n",
last_clock, cur_clock, stream->tid);
last_clock, cur_clock, stream->tid);
ret = -1;
}
@ -372,7 +372,7 @@ usage(void)
err("tracedir, so they are suitable for the emulator ovniemu.\n");
err("Only the events enclosed by OU[ OU] are sorted. At most a\n");
err("total of %ld events are looked back to insert the unsorted\n",
max_look_back);
max_look_back);
err("events, so the sort procedure can fail with an error.\n");
err("\n");
err("Options:\n");

View File

@ -127,29 +127,29 @@ check_metadata_version(struct ovni_eproc *proc)
JSON_Value *version_val = json_object_get_value(meta, "version");
if (version_val == NULL) {
die("process %d is missing attribute \"version\" in metadata\n",
proc->pid);
proc->pid);
}
int version = (int) json_number(version_val);
if (version != OVNI_METADATA_VERSION) {
die("pid %d: metadata version mismatch %d (expected %d)\n",
proc->pid, version,
OVNI_METADATA_VERSION);
proc->pid, version,
OVNI_METADATA_VERSION);
}
JSON_Value *mversion_val = json_object_get_value(meta, "model_version");
if (mversion_val == NULL) {
die("process %d is missing attribute \"model_version\" in metadata\n",
proc->pid);
proc->pid);
}
const char *mversion = json_string(mversion_val);
if (strcmp(mversion, OVNI_MODEL_VERSION) != 0) {
die("pid %d: metadata model version mismatch '%s' (expected '%s')\n",
proc->pid, mversion,
OVNI_MODEL_VERSION);
proc->pid, mversion,
OVNI_MODEL_VERSION);
}
}
@ -197,7 +197,7 @@ load_proc(struct ovni_eproc *proc, struct ovni_loom *loom, int index, int pid, c
DIR *dir;
if ((dir = opendir(procdir)) == NULL) {
fprintf(stderr, "opendir %s failed: %s\n",
procdir, strerror(errno));
procdir, strerror(errno));
return -1;
}
@ -205,7 +205,7 @@ load_proc(struct ovni_eproc *proc, struct ovni_loom *loom, int index, int pid, c
if (proc->nthreads <= 0) {
err("cannot find any thread for process %d\n",
proc->pid);
proc->pid);
return -1;
}
@ -270,7 +270,7 @@ load_loom(struct ovni_loom *loom, char *loomdir)
if ((dir = opendir(loomdir)) == NULL) {
fprintf(stderr, "opendir %s failed: %s\n",
loomdir, strerror(errno));
loomdir, strerror(errno));
return -1;
}
@ -279,7 +279,7 @@ load_loom(struct ovni_loom *loom, char *loomdir)
if (loom->nprocs <= 0) {
err("cannot find any process directory in loom %s\n",
loom->hostname);
loom->hostname);
return -1;
}
@ -326,7 +326,7 @@ load_loom(struct ovni_loom *loom, char *loomdir)
struct ovni_eproc *proc = &loom->proc[i];
if (proc->rank < 0) {
die("process %d is missing the rank\n",
proc->pid);
proc->pid);
}
}
}
@ -415,7 +415,7 @@ ovni_load_trace(struct ovni_trace *trace, char *tracedir)
/* Sort the looms, so we get the hostnames in alphanumeric order */
qsort(trace->loom, trace->nlooms, sizeof(struct ovni_loom),
compare_looms);
compare_looms);
for (size_t i = 0; i < trace->nlooms; i++) {
struct ovni_loom *loom = &trace->loom[i];
@ -429,10 +429,10 @@ ovni_load_trace(struct ovni_trace *trace, char *tracedir)
loom_to_host(name, loom->hostname, sizeof(loom->hostname));
if (snprintf(loom->path, PATH_MAX, "%s/%s",
tracedir, loom->dname)
>= PATH_MAX) {
tracedir, loom->dname)
>= PATH_MAX) {
err("error: loom path %s/%s too long\n",
tracedir, loom->dname);
tracedir, loom->dname);
return -1;
}
@ -450,25 +450,25 @@ check_stream_header(struct ovni_stream *stream)
if (stream->size < sizeof(struct ovni_stream_header)) {
err("stream %d: incomplete stream header\n",
stream->tid);
stream->tid);
return -1;
}
struct ovni_stream_header *h =
(struct ovni_stream_header *) stream->buf;
(struct ovni_stream_header *) stream->buf;
if (memcmp(h->magic, OVNI_STREAM_MAGIC, 4) != 0) {
char magic[5];
memcpy(magic, h->magic, 4);
magic[4] = '\0';
err("stream %d: wrong stream magic '%s' (expected '%s')\n",
stream->tid, magic, OVNI_STREAM_MAGIC);
stream->tid, magic, OVNI_STREAM_MAGIC);
ret = -1;
}
if (h->version != OVNI_STREAM_VERSION) {
err("stream %d: stream version mismatch %u (expected %u)\n",
stream->tid, h->version, OVNI_STREAM_VERSION);
stream->tid, h->version, OVNI_STREAM_VERSION);
ret = -1;
}

View File

@ -222,35 +222,35 @@ typedef unsigned char uint8_t;
#define HASH_BLOOM_BYTELEN 0U
#endif
#define HASH_MAKE_TABLE(hh, head, oomed) \
do { \
(head)->hh.tbl = (UT_hash_table *) uthash_malloc(sizeof(UT_hash_table)); \
if (!(head)->hh.tbl) { \
HASH_RECORD_OOM(oomed); \
} else { \
uthash_bzero((head)->hh.tbl, sizeof(UT_hash_table)); \
(head)->hh.tbl->tail = &((head)->hh); \
(head)->hh.tbl->num_buckets = HASH_INITIAL_NUM_BUCKETS; \
(head)->hh.tbl->log2_num_buckets = HASH_INITIAL_NUM_BUCKETS_LOG2; \
(head)->hh.tbl->hho = (char *) (&(head)->hh) - (char *) (head); \
(head)->hh.tbl->buckets = (UT_hash_bucket *) uthash_malloc( \
HASH_INITIAL_NUM_BUCKETS * sizeof(struct UT_hash_bucket)); \
(head)->hh.tbl->signature = HASH_SIGNATURE; \
if (!(head)->hh.tbl->buckets) { \
HASH_RECORD_OOM(oomed); \
uthash_free((head)->hh.tbl, sizeof(UT_hash_table)); \
} else { \
uthash_bzero((head)->hh.tbl->buckets, \
HASH_INITIAL_NUM_BUCKETS * sizeof(struct UT_hash_bucket)); \
HASH_BLOOM_MAKE((head)->hh.tbl, oomed); \
IF_HASH_NONFATAL_OOM( \
if (oomed) { \
uthash_free((head)->hh.tbl->buckets, \
HASH_INITIAL_NUM_BUCKETS * sizeof(struct UT_hash_bucket)); \
uthash_free((head)->hh.tbl, sizeof(UT_hash_table)); \
}) \
} \
} \
#define HASH_MAKE_TABLE(hh, head, oomed) \
do { \
(head)->hh.tbl = (UT_hash_table *) uthash_malloc(sizeof(UT_hash_table)); \
if (!(head)->hh.tbl) { \
HASH_RECORD_OOM(oomed); \
} else { \
uthash_bzero((head)->hh.tbl, sizeof(UT_hash_table)); \
(head)->hh.tbl->tail = &((head)->hh); \
(head)->hh.tbl->num_buckets = HASH_INITIAL_NUM_BUCKETS; \
(head)->hh.tbl->log2_num_buckets = HASH_INITIAL_NUM_BUCKETS_LOG2; \
(head)->hh.tbl->hho = (char *) (&(head)->hh) - (char *) (head); \
(head)->hh.tbl->buckets = (UT_hash_bucket *) uthash_malloc( \
HASH_INITIAL_NUM_BUCKETS * sizeof(struct UT_hash_bucket)); \
(head)->hh.tbl->signature = HASH_SIGNATURE; \
if (!(head)->hh.tbl->buckets) { \
HASH_RECORD_OOM(oomed); \
uthash_free((head)->hh.tbl, sizeof(UT_hash_table)); \
} else { \
uthash_bzero((head)->hh.tbl->buckets, \
HASH_INITIAL_NUM_BUCKETS * sizeof(struct UT_hash_bucket)); \
HASH_BLOOM_MAKE((head)->hh.tbl, oomed); \
IF_HASH_NONFATAL_OOM( \
if (oomed) { \
uthash_free((head)->hh.tbl->buckets, \
HASH_INITIAL_NUM_BUCKETS * sizeof(struct UT_hash_bucket)); \
uthash_free((head)->hh.tbl, sizeof(UT_hash_table)); \
}) \
} \
} \
} while (0)
#define HASH_REPLACE_BYHASHVALUE_INORDER(hh, head, fieldname, keylen_in, hashval, add, replaced, cmpfcn) \
@ -465,7 +465,7 @@ typedef unsigned char uint8_t;
if ((_hd_hh_del->prev == NULL) && (_hd_hh_del->next == NULL)) { \
HASH_BLOOM_FREE((head)->hh.tbl); \
uthash_free((head)->hh.tbl->buckets, \
(head)->hh.tbl->num_buckets * sizeof(struct UT_hash_bucket)); \
(head)->hh.tbl->num_buckets * sizeof(struct UT_hash_bucket)); \
uthash_free((head)->hh.tbl, sizeof(UT_hash_table)); \
(head) = NULL; \
} else { \
@ -528,53 +528,53 @@ typedef unsigned char uint8_t;
fprintf(stderr, __VA_ARGS__); \
exit(-1); \
} while (0)
#define HASH_FSCK(hh, head, where) \
do { \
struct UT_hash_handle *_thh; \
if (head) { \
unsigned _bkt_i; \
unsigned _count = 0; \
char *_prev; \
for (_bkt_i = 0; _bkt_i < (head)->hh.tbl->num_buckets; ++_bkt_i) { \
unsigned _bkt_count = 0; \
_thh = (head)->hh.tbl->buckets[_bkt_i].hh_head; \
_prev = NULL; \
while (_thh) { \
if (_prev != (char *) (_thh->hh_prev)) { \
HASH_OOPS("%s: invalid hh_prev %p, actual %p\n", \
(where), (void *) _thh->hh_prev, (void *) _prev); \
} \
_bkt_count++; \
_prev = (char *) (_thh); \
_thh = _thh->hh_next; \
} \
_count += _bkt_count; \
if ((head)->hh.tbl->buckets[_bkt_i].count != _bkt_count) { \
HASH_OOPS("%s: invalid bucket count %u, actual %u\n", \
(where), (head)->hh.tbl->buckets[_bkt_i].count, _bkt_count); \
} \
} \
if (_count != (head)->hh.tbl->num_items) { \
HASH_OOPS("%s: invalid hh item count %u, actual %u\n", \
(where), (head)->hh.tbl->num_items, _count); \
} \
_count = 0; \
_prev = NULL; \
_thh = &(head)->hh; \
while (_thh) { \
_count++; \
if (_prev != (char *) _thh->prev) { \
HASH_OOPS("%s: invalid prev %p, actual %p\n", \
(where), (void *) _thh->prev, (void *) _prev); \
} \
_prev = (char *) ELMT_FROM_HH((head)->hh.tbl, _thh); \
_thh = (_thh->next ? HH_FROM_ELMT((head)->hh.tbl, _thh->next) : NULL); \
} \
if (_count != (head)->hh.tbl->num_items) { \
HASH_OOPS("%s: invalid app item count %u, actual %u\n", \
(where), (head)->hh.tbl->num_items, _count); \
} \
} \
#define HASH_FSCK(hh, head, where) \
do { \
struct UT_hash_handle *_thh; \
if (head) { \
unsigned _bkt_i; \
unsigned _count = 0; \
char *_prev; \
for (_bkt_i = 0; _bkt_i < (head)->hh.tbl->num_buckets; ++_bkt_i) { \
unsigned _bkt_count = 0; \
_thh = (head)->hh.tbl->buckets[_bkt_i].hh_head; \
_prev = NULL; \
while (_thh) { \
if (_prev != (char *) (_thh->hh_prev)) { \
HASH_OOPS("%s: invalid hh_prev %p, actual %p\n", \
(where), (void *) _thh->hh_prev, (void *) _prev); \
} \
_bkt_count++; \
_prev = (char *) (_thh); \
_thh = _thh->hh_next; \
} \
_count += _bkt_count; \
if ((head)->hh.tbl->buckets[_bkt_i].count != _bkt_count) { \
HASH_OOPS("%s: invalid bucket count %u, actual %u\n", \
(where), (head)->hh.tbl->buckets[_bkt_i].count, _bkt_count); \
} \
} \
if (_count != (head)->hh.tbl->num_items) { \
HASH_OOPS("%s: invalid hh item count %u, actual %u\n", \
(where), (head)->hh.tbl->num_items, _count); \
} \
_count = 0; \
_prev = NULL; \
_thh = &(head)->hh; \
while (_thh) { \
_count++; \
if (_prev != (char *) _thh->prev) { \
HASH_OOPS("%s: invalid prev %p, actual %p\n", \
(where), (void *) _thh->prev, (void *) _prev); \
} \
_prev = (char *) ELMT_FROM_HH((head)->hh.tbl, _thh); \
_thh = (_thh->next ? HH_FROM_ELMT((head)->hh.tbl, _thh->next) : NULL); \
} \
if (_count != (head)->hh.tbl->num_items) { \
HASH_OOPS("%s: invalid app item count %u, actual %u\n", \
(where), (head)->hh.tbl->num_items, _count); \
} \
} \
} while (0)
#else
#define HASH_FSCK(hh, head, where)
@ -691,14 +691,14 @@ typedef unsigned char uint8_t;
_hj_k = (unsigned) (keylen); \
while (_hj_k >= 12U) { \
_hj_i += (_hj_key[0] + ((unsigned) _hj_key[1] << 8) \
+ ((unsigned) _hj_key[2] << 16) \
+ ((unsigned) _hj_key[3] << 24)); \
+ ((unsigned) _hj_key[2] << 16) \
+ ((unsigned) _hj_key[3] << 24)); \
_hj_j += (_hj_key[4] + ((unsigned) _hj_key[5] << 8) \
+ ((unsigned) _hj_key[6] << 16) \
+ ((unsigned) _hj_key[7] << 24)); \
+ ((unsigned) _hj_key[6] << 16) \
+ ((unsigned) _hj_key[7] << 24)); \
hashv += (_hj_key[8] + ((unsigned) _hj_key[9] << 8) \
+ ((unsigned) _hj_key[10] << 16) \
+ ((unsigned) _hj_key[11] << 24)); \
+ ((unsigned) _hj_key[10] << 16) \
+ ((unsigned) _hj_key[11] << 24)); \
\
HASH_JEN_MIX(_hj_i, _hj_j, hashv); \
\
@ -736,7 +736,7 @@ typedef unsigned char uint8_t;
/* The Paul Hsieh hash function */
#undef get16bits
#if (defined(__GNUC__) && defined(__i386__)) || defined(__WATCOMC__) \
|| defined(_MSC_VER) || defined(__BORLANDC__) || defined(__TURBOC__)
|| defined(_MSC_VER) || defined(__BORLANDC__) || defined(__TURBOC__)
#define get16bits(d) (*((const uint16_t *) (d)))
#endif
@ -906,12 +906,12 @@ typedef unsigned char uint8_t;
} \
_ha_head->hh_head = (addhh); \
if ((_ha_head->count >= ((_ha_head->expand_mult + 1U) * HASH_BKT_CAPACITY_THRESH)) \
&& !(addhh)->tbl->noexpand) { \
&& !(addhh)->tbl->noexpand) { \
HASH_EXPAND_BUCKETS(addhh, (addhh)->tbl, oomed); \
IF_HASH_NONFATAL_OOM( \
if (oomed) { \
HASH_DEL_IN_BKT(head, addhh); \
}) \
if (oomed) { \
HASH_DEL_IN_BKT(head, addhh); \
}) \
} \
} while (0)
@ -960,54 +960,54 @@ typedef unsigned char uint8_t;
* ceil(n/b) = (n>>lb) + ( (n & (b-1)) ? 1:0)
*
*/
#define HASH_EXPAND_BUCKETS(hh, tbl, oomed) \
do { \
unsigned _he_bkt; \
unsigned _he_bkt_i; \
struct UT_hash_handle *_he_thh, *_he_hh_nxt; \
UT_hash_bucket *_he_new_buckets, *_he_newbkt; \
_he_new_buckets = (UT_hash_bucket *) uthash_malloc( \
2UL * (tbl)->num_buckets * sizeof(struct UT_hash_bucket)); \
if (!_he_new_buckets) { \
HASH_RECORD_OOM(oomed); \
} else { \
uthash_bzero(_he_new_buckets, \
2UL * (tbl)->num_buckets * sizeof(struct UT_hash_bucket)); \
(tbl)->ideal_chain_maxlen = \
((tbl)->num_items >> ((tbl)->log2_num_buckets + 1U)) + ((((tbl)->num_items & (((tbl)->num_buckets * 2U) - 1U)) != 0U) ? 1U : 0U); \
(tbl)->nonideal_items = 0; \
for (_he_bkt_i = 0; _he_bkt_i < (tbl)->num_buckets; _he_bkt_i++) { \
_he_thh = (tbl)->buckets[_he_bkt_i].hh_head; \
while (_he_thh != NULL) { \
_he_hh_nxt = _he_thh->hh_next; \
HASH_TO_BKT(_he_thh->hashv, (tbl)->num_buckets * 2U, _he_bkt); \
_he_newbkt = &(_he_new_buckets[_he_bkt]); \
if (++(_he_newbkt->count) > (tbl)->ideal_chain_maxlen) { \
(tbl)->nonideal_items++; \
if (_he_newbkt->count > _he_newbkt->expand_mult * (tbl)->ideal_chain_maxlen) { \
_he_newbkt->expand_mult++; \
} \
} \
_he_thh->hh_prev = NULL; \
_he_thh->hh_next = _he_newbkt->hh_head; \
if (_he_newbkt->hh_head != NULL) { \
_he_newbkt->hh_head->hh_prev = _he_thh; \
} \
_he_newbkt->hh_head = _he_thh; \
_he_thh = _he_hh_nxt; \
} \
} \
uthash_free((tbl)->buckets, (tbl)->num_buckets * sizeof(struct UT_hash_bucket)); \
(tbl)->num_buckets *= 2U; \
(tbl)->log2_num_buckets++; \
(tbl)->buckets = _he_new_buckets; \
(tbl)->ineff_expands = ((tbl)->nonideal_items > ((tbl)->num_items >> 1)) ? ((tbl)->ineff_expands + 1U) : 0U; \
if ((tbl)->ineff_expands > 1U) { \
(tbl)->noexpand = 1; \
uthash_noexpand_fyi(tbl); \
} \
uthash_expand_fyi(tbl); \
} \
#define HASH_EXPAND_BUCKETS(hh, tbl, oomed) \
do { \
unsigned _he_bkt; \
unsigned _he_bkt_i; \
struct UT_hash_handle *_he_thh, *_he_hh_nxt; \
UT_hash_bucket *_he_new_buckets, *_he_newbkt; \
_he_new_buckets = (UT_hash_bucket *) uthash_malloc( \
2UL * (tbl)->num_buckets * sizeof(struct UT_hash_bucket)); \
if (!_he_new_buckets) { \
HASH_RECORD_OOM(oomed); \
} else { \
uthash_bzero(_he_new_buckets, \
2UL * (tbl)->num_buckets * sizeof(struct UT_hash_bucket)); \
(tbl)->ideal_chain_maxlen = \
((tbl)->num_items >> ((tbl)->log2_num_buckets + 1U)) + ((((tbl)->num_items & (((tbl)->num_buckets * 2U) - 1U)) != 0U) ? 1U : 0U); \
(tbl)->nonideal_items = 0; \
for (_he_bkt_i = 0; _he_bkt_i < (tbl)->num_buckets; _he_bkt_i++) { \
_he_thh = (tbl)->buckets[_he_bkt_i].hh_head; \
while (_he_thh != NULL) { \
_he_hh_nxt = _he_thh->hh_next; \
HASH_TO_BKT(_he_thh->hashv, (tbl)->num_buckets * 2U, _he_bkt); \
_he_newbkt = &(_he_new_buckets[_he_bkt]); \
if (++(_he_newbkt->count) > (tbl)->ideal_chain_maxlen) { \
(tbl)->nonideal_items++; \
if (_he_newbkt->count > _he_newbkt->expand_mult * (tbl)->ideal_chain_maxlen) { \
_he_newbkt->expand_mult++; \
} \
} \
_he_thh->hh_prev = NULL; \
_he_thh->hh_next = _he_newbkt->hh_head; \
if (_he_newbkt->hh_head != NULL) { \
_he_newbkt->hh_head->hh_prev = _he_thh; \
} \
_he_newbkt->hh_head = _he_thh; \
_he_thh = _he_hh_nxt; \
} \
} \
uthash_free((tbl)->buckets, (tbl)->num_buckets * sizeof(struct UT_hash_bucket)); \
(tbl)->num_buckets *= 2U; \
(tbl)->log2_num_buckets++; \
(tbl)->buckets = _he_new_buckets; \
(tbl)->ineff_expands = ((tbl)->nonideal_items > ((tbl)->num_items >> 1)) ? ((tbl)->ineff_expands + 1U) : 0U; \
if ((tbl)->ineff_expands > 1U) { \
(tbl)->noexpand = 1; \
uthash_noexpand_fyi(tbl); \
} \
uthash_expand_fyi(tbl); \
} \
} while (0)
@ -1053,9 +1053,9 @@ typedef unsigned char uint8_t;
} \
_hs_psize--; \
} else if ((cmpfcn( \
DECLTYPE(head)(ELMT_FROM_HH((head)->hh.tbl, _hs_p)), \
DECLTYPE(head)(ELMT_FROM_HH((head)->hh.tbl, _hs_q)))) \
<= 0) { \
DECLTYPE(head)(ELMT_FROM_HH((head)->hh.tbl, _hs_p)), \
DECLTYPE(head)(ELMT_FROM_HH((head)->hh.tbl, _hs_q)))) \
<= 0) { \
_hs_e = _hs_p; \
if (_hs_p != NULL) { \
_hs_p = ((_hs_p->next != NULL) ? HH_FROM_ELMT((head)->hh.tbl, _hs_p->next) : NULL); \
@ -1106,8 +1106,8 @@ typedef unsigned char uint8_t;
if ((src) != NULL) { \
for (_src_bkt = 0; _src_bkt < (src)->hh_src.tbl->num_buckets; _src_bkt++) { \
for (_src_hh = (src)->hh_src.tbl->buckets[_src_bkt].hh_head; \
_src_hh != NULL; \
_src_hh = _src_hh->hh_next) { \
_src_hh != NULL; \
_src_hh = _src_hh->hh_next) { \
_elt = ELMT_FROM_HH((src)->hh_src.tbl, _src_hh); \
if (cond(_elt)) { \
IF_HASH_NONFATAL_OOM(int _hs_oomed = 0;) \
@ -1124,11 +1124,11 @@ typedef unsigned char uint8_t;
DECLTYPE_ASSIGN(dst, _elt); \
HASH_MAKE_TABLE(hh_dst, dst, _hs_oomed); \
IF_HASH_NONFATAL_OOM( \
if (_hs_oomed) { \
uthash_nonfatal_oom(_elt); \
(dst) = NULL; \
continue; \
}) \
if (_hs_oomed) { \
uthash_nonfatal_oom(_elt); \
(dst) = NULL; \
continue; \
}) \
} else { \
_dst_hh->tbl = (dst)->hh_dst.tbl; \
} \
@ -1136,13 +1136,13 @@ typedef unsigned char uint8_t;
HASH_ADD_TO_BKT(_dst_hh->tbl->buckets[_dst_bkt], hh_dst, _dst_hh, _hs_oomed); \
(dst)->hh_dst.tbl->num_items++; \
IF_HASH_NONFATAL_OOM( \
if (_hs_oomed) { \
HASH_ROLLBACK_BKT(hh_dst, dst, _dst_hh); \
HASH_DELETE_HH(hh_dst, dst, _dst_hh); \
_dst_hh->tbl = NULL; \
uthash_nonfatal_oom(_elt); \
continue; \
}) \
if (_hs_oomed) { \
HASH_ROLLBACK_BKT(hh_dst, dst, _dst_hh); \
HASH_DELETE_HH(hh_dst, dst, _dst_hh); \
_dst_hh->tbl = NULL; \
uthash_nonfatal_oom(_elt); \
continue; \
}) \
HASH_BLOOM_ADD(_dst_hh->tbl, _dst_hh->hashv); \
_last_elt = _elt; \
_last_elt_hh = _dst_hh; \
@ -1153,30 +1153,30 @@ typedef unsigned char uint8_t;
HASH_FSCK(hh_dst, dst, "HASH_SELECT"); \
} while (0)
#define HASH_CLEAR(hh, head) \
do { \
if ((head) != NULL) { \
HASH_BLOOM_FREE((head)->hh.tbl); \
uthash_free((head)->hh.tbl->buckets, \
(head)->hh.tbl->num_buckets * sizeof(struct UT_hash_bucket)); \
uthash_free((head)->hh.tbl, sizeof(UT_hash_table)); \
(head) = NULL; \
} \
#define HASH_CLEAR(hh, head) \
do { \
if ((head) != NULL) { \
HASH_BLOOM_FREE((head)->hh.tbl); \
uthash_free((head)->hh.tbl->buckets, \
(head)->hh.tbl->num_buckets * sizeof(struct UT_hash_bucket)); \
uthash_free((head)->hh.tbl, sizeof(UT_hash_table)); \
(head) = NULL; \
} \
} while (0)
#define HASH_OVERHEAD(hh, head) \
(((head) != NULL) ? ( \
(size_t) (((head)->hh.tbl->num_items * sizeof(UT_hash_handle)) + ((head)->hh.tbl->num_buckets * sizeof(UT_hash_bucket)) + sizeof(UT_hash_table) + (HASH_BLOOM_BYTELEN))) \
#define HASH_OVERHEAD(hh, head) \
(((head) != NULL) ? ( \
(size_t) (((head)->hh.tbl->num_items * sizeof(UT_hash_handle)) + ((head)->hh.tbl->num_buckets * sizeof(UT_hash_bucket)) + sizeof(UT_hash_table) + (HASH_BLOOM_BYTELEN))) \
: 0U)
#ifdef NO_DECLTYPE
#define HASH_ITER(hh, head, el, tmp) \
for (((el) = (head)), ((*(char **) (&(tmp))) = (char *) ((head != NULL) ? (head)->hh.next : NULL)); \
(el) != NULL; ((el) = (tmp)), ((*(char **) (&(tmp))) = (char *) ((tmp != NULL) ? (tmp)->hh.next : NULL)))
(el) != NULL; ((el) = (tmp)), ((*(char **) (&(tmp))) = (char *) ((tmp != NULL) ? (tmp)->hh.next : NULL)))
#else
#define HASH_ITER(hh, head, el, tmp) \
for (((el) = (head)), ((tmp) = DECLTYPE(el)((head != NULL) ? (head)->hh.next : NULL)); \
(el) != NULL; ((el) = (tmp)), ((tmp) = DECLTYPE(el)((tmp != NULL) ? (tmp)->hh.next : NULL)))
(el) != NULL; ((el) = (tmp)), ((tmp) = DECLTYPE(el)((tmp != NULL) ? (tmp)->hh.next : NULL)))
#endif
/* obtain a count of items in the hash */

View File

@ -127,297 +127,297 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#define LL_SORT(list, cmp) \
LL_SORT2(list, cmp, next)
#define LL_SORT2(list, cmp, next) \
do { \
LDECLTYPE(list) \
_ls_p; \
LDECLTYPE(list) \
_ls_q; \
LDECLTYPE(list) \
_ls_e; \
LDECLTYPE(list) \
_ls_tail; \
IF_NO_DECLTYPE(LDECLTYPE(list) _tmp;) \
int _ls_insize, _ls_nmerges, _ls_psize, _ls_qsize, _ls_i, _ls_looping; \
if (list) { \
_ls_insize = 1; \
_ls_looping = 1; \
while (_ls_looping) { \
UTLIST_CASTASGN(_ls_p, list); \
(list) = NULL; \
_ls_tail = NULL; \
_ls_nmerges = 0; \
while (_ls_p) { \
_ls_nmerges++; \
_ls_q = _ls_p; \
_ls_psize = 0; \
for (_ls_i = 0; _ls_i < _ls_insize; _ls_i++) { \
_ls_psize++; \
UTLIST_SV(_ls_q, list); \
_ls_q = UTLIST_NEXT(_ls_q, list, next); \
UTLIST_RS(list); \
if (!_ls_q) \
break; \
} \
_ls_qsize = _ls_insize; \
while (_ls_psize > 0 || (_ls_qsize > 0 && _ls_q)) { \
if (_ls_psize == 0) { \
_ls_e = _ls_q; \
UTLIST_SV(_ls_q, list); \
_ls_q = \
UTLIST_NEXT(_ls_q, list, next); \
UTLIST_RS(list); \
_ls_qsize--; \
} else if (_ls_qsize == 0 || !_ls_q) { \
_ls_e = _ls_p; \
UTLIST_SV(_ls_p, list); \
_ls_p = \
UTLIST_NEXT(_ls_p, list, next); \
UTLIST_RS(list); \
_ls_psize--; \
} else if (cmp(_ls_p, _ls_q) <= 0) { \
_ls_e = _ls_p; \
UTLIST_SV(_ls_p, list); \
_ls_p = \
UTLIST_NEXT(_ls_p, list, next); \
UTLIST_RS(list); \
_ls_psize--; \
} else { \
_ls_e = _ls_q; \
UTLIST_SV(_ls_q, list); \
_ls_q = \
UTLIST_NEXT(_ls_q, list, next); \
UTLIST_RS(list); \
_ls_qsize--; \
} \
if (_ls_tail) { \
UTLIST_SV(_ls_tail, list); \
UTLIST_NEXTASGN(_ls_tail, list, _ls_e, next); \
UTLIST_RS(list); \
} else { \
UTLIST_CASTASGN(list, _ls_e); \
} \
_ls_tail = _ls_e; \
} \
_ls_p = _ls_q; \
} \
if (_ls_tail) { \
UTLIST_SV(_ls_tail, list); \
UTLIST_NEXTASGN(_ls_tail, list, NULL, next); \
UTLIST_RS(list); \
} \
if (_ls_nmerges <= 1) { \
_ls_looping = 0; \
} \
_ls_insize *= 2; \
} \
} \
#define LL_SORT2(list, cmp, next) \
do { \
LDECLTYPE(list) \
_ls_p; \
LDECLTYPE(list) \
_ls_q; \
LDECLTYPE(list) \
_ls_e; \
LDECLTYPE(list) \
_ls_tail; \
IF_NO_DECLTYPE(LDECLTYPE(list) _tmp;) \
int _ls_insize, _ls_nmerges, _ls_psize, _ls_qsize, _ls_i, _ls_looping; \
if (list) { \
_ls_insize = 1; \
_ls_looping = 1; \
while (_ls_looping) { \
UTLIST_CASTASGN(_ls_p, list); \
(list) = NULL; \
_ls_tail = NULL; \
_ls_nmerges = 0; \
while (_ls_p) { \
_ls_nmerges++; \
_ls_q = _ls_p; \
_ls_psize = 0; \
for (_ls_i = 0; _ls_i < _ls_insize; _ls_i++) { \
_ls_psize++; \
UTLIST_SV(_ls_q, list); \
_ls_q = UTLIST_NEXT(_ls_q, list, next); \
UTLIST_RS(list); \
if (!_ls_q) \
break; \
} \
_ls_qsize = _ls_insize; \
while (_ls_psize > 0 || (_ls_qsize > 0 && _ls_q)) { \
if (_ls_psize == 0) { \
_ls_e = _ls_q; \
UTLIST_SV(_ls_q, list); \
_ls_q = \
UTLIST_NEXT(_ls_q, list, next); \
UTLIST_RS(list); \
_ls_qsize--; \
} else if (_ls_qsize == 0 || !_ls_q) { \
_ls_e = _ls_p; \
UTLIST_SV(_ls_p, list); \
_ls_p = \
UTLIST_NEXT(_ls_p, list, next); \
UTLIST_RS(list); \
_ls_psize--; \
} else if (cmp(_ls_p, _ls_q) <= 0) { \
_ls_e = _ls_p; \
UTLIST_SV(_ls_p, list); \
_ls_p = \
UTLIST_NEXT(_ls_p, list, next); \
UTLIST_RS(list); \
_ls_psize--; \
} else { \
_ls_e = _ls_q; \
UTLIST_SV(_ls_q, list); \
_ls_q = \
UTLIST_NEXT(_ls_q, list, next); \
UTLIST_RS(list); \
_ls_qsize--; \
} \
if (_ls_tail) { \
UTLIST_SV(_ls_tail, list); \
UTLIST_NEXTASGN(_ls_tail, list, _ls_e, next); \
UTLIST_RS(list); \
} else { \
UTLIST_CASTASGN(list, _ls_e); \
} \
_ls_tail = _ls_e; \
} \
_ls_p = _ls_q; \
} \
if (_ls_tail) { \
UTLIST_SV(_ls_tail, list); \
UTLIST_NEXTASGN(_ls_tail, list, NULL, next); \
UTLIST_RS(list); \
} \
if (_ls_nmerges <= 1) { \
_ls_looping = 0; \
} \
_ls_insize *= 2; \
} \
} \
} while (0)
#define DL_SORT(list, cmp) \
DL_SORT2(list, cmp, prev, next)
#define DL_SORT2(list, cmp, prev, next) \
do { \
LDECLTYPE(list) \
_ls_p; \
LDECLTYPE(list) \
_ls_q; \
LDECLTYPE(list) \
_ls_e; \
LDECLTYPE(list) \
_ls_tail; \
IF_NO_DECLTYPE(LDECLTYPE(list) _tmp;) \
int _ls_insize, _ls_nmerges, _ls_psize, _ls_qsize, _ls_i, _ls_looping; \
if (list) { \
_ls_insize = 1; \
_ls_looping = 1; \
while (_ls_looping) { \
UTLIST_CASTASGN(_ls_p, list); \
(list) = NULL; \
_ls_tail = NULL; \
_ls_nmerges = 0; \
while (_ls_p) { \
_ls_nmerges++; \
_ls_q = _ls_p; \
_ls_psize = 0; \
for (_ls_i = 0; _ls_i < _ls_insize; _ls_i++) { \
_ls_psize++; \
UTLIST_SV(_ls_q, list); \
_ls_q = UTLIST_NEXT(_ls_q, list, next); \
UTLIST_RS(list); \
if (!_ls_q) \
break; \
} \
_ls_qsize = _ls_insize; \
while ((_ls_psize > 0) || ((_ls_qsize > 0) && _ls_q)) { \
if (_ls_psize == 0) { \
_ls_e = _ls_q; \
UTLIST_SV(_ls_q, list); \
_ls_q = \
UTLIST_NEXT(_ls_q, list, next); \
UTLIST_RS(list); \
_ls_qsize--; \
} else if ((_ls_qsize == 0) || (!_ls_q)) { \
_ls_e = _ls_p; \
UTLIST_SV(_ls_p, list); \
_ls_p = \
UTLIST_NEXT(_ls_p, list, next); \
UTLIST_RS(list); \
_ls_psize--; \
} else if (cmp(_ls_p, _ls_q) <= 0) { \
_ls_e = _ls_p; \
UTLIST_SV(_ls_p, list); \
_ls_p = \
UTLIST_NEXT(_ls_p, list, next); \
UTLIST_RS(list); \
_ls_psize--; \
} else { \
_ls_e = _ls_q; \
UTLIST_SV(_ls_q, list); \
_ls_q = \
UTLIST_NEXT(_ls_q, list, next); \
UTLIST_RS(list); \
_ls_qsize--; \
} \
if (_ls_tail) { \
UTLIST_SV(_ls_tail, list); \
UTLIST_NEXTASGN(_ls_tail, list, _ls_e, next); \
UTLIST_RS(list); \
} else { \
UTLIST_CASTASGN(list, _ls_e); \
} \
UTLIST_SV(_ls_e, list); \
UTLIST_PREVASGN(_ls_e, list, _ls_tail, prev); \
UTLIST_RS(list); \
_ls_tail = _ls_e; \
} \
_ls_p = _ls_q; \
} \
UTLIST_CASTASGN((list)->prev, _ls_tail); \
UTLIST_SV(_ls_tail, list); \
UTLIST_NEXTASGN(_ls_tail, list, NULL, next); \
UTLIST_RS(list); \
if (_ls_nmerges <= 1) { \
_ls_looping = 0; \
} \
_ls_insize *= 2; \
} \
} \
#define DL_SORT2(list, cmp, prev, next) \
do { \
LDECLTYPE(list) \
_ls_p; \
LDECLTYPE(list) \
_ls_q; \
LDECLTYPE(list) \
_ls_e; \
LDECLTYPE(list) \
_ls_tail; \
IF_NO_DECLTYPE(LDECLTYPE(list) _tmp;) \
int _ls_insize, _ls_nmerges, _ls_psize, _ls_qsize, _ls_i, _ls_looping; \
if (list) { \
_ls_insize = 1; \
_ls_looping = 1; \
while (_ls_looping) { \
UTLIST_CASTASGN(_ls_p, list); \
(list) = NULL; \
_ls_tail = NULL; \
_ls_nmerges = 0; \
while (_ls_p) { \
_ls_nmerges++; \
_ls_q = _ls_p; \
_ls_psize = 0; \
for (_ls_i = 0; _ls_i < _ls_insize; _ls_i++) { \
_ls_psize++; \
UTLIST_SV(_ls_q, list); \
_ls_q = UTLIST_NEXT(_ls_q, list, next); \
UTLIST_RS(list); \
if (!_ls_q) \
break; \
} \
_ls_qsize = _ls_insize; \
while ((_ls_psize > 0) || ((_ls_qsize > 0) && _ls_q)) { \
if (_ls_psize == 0) { \
_ls_e = _ls_q; \
UTLIST_SV(_ls_q, list); \
_ls_q = \
UTLIST_NEXT(_ls_q, list, next); \
UTLIST_RS(list); \
_ls_qsize--; \
} else if ((_ls_qsize == 0) || (!_ls_q)) { \
_ls_e = _ls_p; \
UTLIST_SV(_ls_p, list); \
_ls_p = \
UTLIST_NEXT(_ls_p, list, next); \
UTLIST_RS(list); \
_ls_psize--; \
} else if (cmp(_ls_p, _ls_q) <= 0) { \
_ls_e = _ls_p; \
UTLIST_SV(_ls_p, list); \
_ls_p = \
UTLIST_NEXT(_ls_p, list, next); \
UTLIST_RS(list); \
_ls_psize--; \
} else { \
_ls_e = _ls_q; \
UTLIST_SV(_ls_q, list); \
_ls_q = \
UTLIST_NEXT(_ls_q, list, next); \
UTLIST_RS(list); \
_ls_qsize--; \
} \
if (_ls_tail) { \
UTLIST_SV(_ls_tail, list); \
UTLIST_NEXTASGN(_ls_tail, list, _ls_e, next); \
UTLIST_RS(list); \
} else { \
UTLIST_CASTASGN(list, _ls_e); \
} \
UTLIST_SV(_ls_e, list); \
UTLIST_PREVASGN(_ls_e, list, _ls_tail, prev); \
UTLIST_RS(list); \
_ls_tail = _ls_e; \
} \
_ls_p = _ls_q; \
} \
UTLIST_CASTASGN((list)->prev, _ls_tail); \
UTLIST_SV(_ls_tail, list); \
UTLIST_NEXTASGN(_ls_tail, list, NULL, next); \
UTLIST_RS(list); \
if (_ls_nmerges <= 1) { \
_ls_looping = 0; \
} \
_ls_insize *= 2; \
} \
} \
} while (0)
#define CDL_SORT(list, cmp) \
CDL_SORT2(list, cmp, prev, next)
#define CDL_SORT2(list, cmp, prev, next) \
do { \
LDECLTYPE(list) \
_ls_p; \
LDECLTYPE(list) \
_ls_q; \
LDECLTYPE(list) \
_ls_e; \
LDECLTYPE(list) \
_ls_tail; \
LDECLTYPE(list) \
_ls_oldhead; \
LDECLTYPE(list) \
_tmp; \
int _ls_insize, _ls_nmerges, _ls_psize, _ls_qsize, _ls_i, _ls_looping; \
if (list) { \
_ls_insize = 1; \
_ls_looping = 1; \
while (_ls_looping) { \
UTLIST_CASTASGN(_ls_p, list); \
UTLIST_CASTASGN(_ls_oldhead, list); \
(list) = NULL; \
_ls_tail = NULL; \
_ls_nmerges = 0; \
while (_ls_p) { \
_ls_nmerges++; \
_ls_q = _ls_p; \
_ls_psize = 0; \
for (_ls_i = 0; _ls_i < _ls_insize; _ls_i++) { \
_ls_psize++; \
UTLIST_SV(_ls_q, list); \
if (UTLIST_NEXT(_ls_q, list, next) == _ls_oldhead) { \
_ls_q = NULL; \
} else { \
_ls_q = UTLIST_NEXT(_ls_q, list, next); \
} \
UTLIST_RS(list); \
if (!_ls_q) \
break; \
} \
_ls_qsize = _ls_insize; \
while (_ls_psize > 0 || (_ls_qsize > 0 && _ls_q)) { \
if (_ls_psize == 0) { \
_ls_e = _ls_q; \
UTLIST_SV(_ls_q, list); \
_ls_q = \
UTLIST_NEXT(_ls_q, list, next); \
UTLIST_RS(list); \
_ls_qsize--; \
if (_ls_q == _ls_oldhead) { \
_ls_q = NULL; \
} \
} else if (_ls_qsize == 0 || !_ls_q) { \
_ls_e = _ls_p; \
UTLIST_SV(_ls_p, list); \
_ls_p = \
UTLIST_NEXT(_ls_p, list, next); \
UTLIST_RS(list); \
_ls_psize--; \
if (_ls_p == _ls_oldhead) { \
_ls_p = NULL; \
} \
} else if (cmp(_ls_p, _ls_q) <= 0) { \
_ls_e = _ls_p; \
UTLIST_SV(_ls_p, list); \
_ls_p = \
UTLIST_NEXT(_ls_p, list, next); \
UTLIST_RS(list); \
_ls_psize--; \
if (_ls_p == _ls_oldhead) { \
_ls_p = NULL; \
} \
} else { \
_ls_e = _ls_q; \
UTLIST_SV(_ls_q, list); \
_ls_q = \
UTLIST_NEXT(_ls_q, list, next); \
UTLIST_RS(list); \
_ls_qsize--; \
if (_ls_q == _ls_oldhead) { \
_ls_q = NULL; \
} \
} \
if (_ls_tail) { \
UTLIST_SV(_ls_tail, list); \
UTLIST_NEXTASGN(_ls_tail, list, _ls_e, next); \
UTLIST_RS(list); \
} else { \
UTLIST_CASTASGN(list, _ls_e); \
} \
UTLIST_SV(_ls_e, list); \
UTLIST_PREVASGN(_ls_e, list, _ls_tail, prev); \
UTLIST_RS(list); \
_ls_tail = _ls_e; \
} \
_ls_p = _ls_q; \
} \
UTLIST_CASTASGN((list)->prev, _ls_tail); \
UTLIST_CASTASGN(_tmp, list); \
UTLIST_SV(_ls_tail, list); \
UTLIST_NEXTASGN(_ls_tail, list, _tmp, next); \
UTLIST_RS(list); \
if (_ls_nmerges <= 1) { \
_ls_looping = 0; \
} \
_ls_insize *= 2; \
} \
} \
#define CDL_SORT2(list, cmp, prev, next) \
do { \
LDECLTYPE(list) \
_ls_p; \
LDECLTYPE(list) \
_ls_q; \
LDECLTYPE(list) \
_ls_e; \
LDECLTYPE(list) \
_ls_tail; \
LDECLTYPE(list) \
_ls_oldhead; \
LDECLTYPE(list) \
_tmp; \
int _ls_insize, _ls_nmerges, _ls_psize, _ls_qsize, _ls_i, _ls_looping; \
if (list) { \
_ls_insize = 1; \
_ls_looping = 1; \
while (_ls_looping) { \
UTLIST_CASTASGN(_ls_p, list); \
UTLIST_CASTASGN(_ls_oldhead, list); \
(list) = NULL; \
_ls_tail = NULL; \
_ls_nmerges = 0; \
while (_ls_p) { \
_ls_nmerges++; \
_ls_q = _ls_p; \
_ls_psize = 0; \
for (_ls_i = 0; _ls_i < _ls_insize; _ls_i++) { \
_ls_psize++; \
UTLIST_SV(_ls_q, list); \
if (UTLIST_NEXT(_ls_q, list, next) == _ls_oldhead) { \
_ls_q = NULL; \
} else { \
_ls_q = UTLIST_NEXT(_ls_q, list, next); \
} \
UTLIST_RS(list); \
if (!_ls_q) \
break; \
} \
_ls_qsize = _ls_insize; \
while (_ls_psize > 0 || (_ls_qsize > 0 && _ls_q)) { \
if (_ls_psize == 0) { \
_ls_e = _ls_q; \
UTLIST_SV(_ls_q, list); \
_ls_q = \
UTLIST_NEXT(_ls_q, list, next); \
UTLIST_RS(list); \
_ls_qsize--; \
if (_ls_q == _ls_oldhead) { \
_ls_q = NULL; \
} \
} else if (_ls_qsize == 0 || !_ls_q) { \
_ls_e = _ls_p; \
UTLIST_SV(_ls_p, list); \
_ls_p = \
UTLIST_NEXT(_ls_p, list, next); \
UTLIST_RS(list); \
_ls_psize--; \
if (_ls_p == _ls_oldhead) { \
_ls_p = NULL; \
} \
} else if (cmp(_ls_p, _ls_q) <= 0) { \
_ls_e = _ls_p; \
UTLIST_SV(_ls_p, list); \
_ls_p = \
UTLIST_NEXT(_ls_p, list, next); \
UTLIST_RS(list); \
_ls_psize--; \
if (_ls_p == _ls_oldhead) { \
_ls_p = NULL; \
} \
} else { \
_ls_e = _ls_q; \
UTLIST_SV(_ls_q, list); \
_ls_q = \
UTLIST_NEXT(_ls_q, list, next); \
UTLIST_RS(list); \
_ls_qsize--; \
if (_ls_q == _ls_oldhead) { \
_ls_q = NULL; \
} \
} \
if (_ls_tail) { \
UTLIST_SV(_ls_tail, list); \
UTLIST_NEXTASGN(_ls_tail, list, _ls_e, next); \
UTLIST_RS(list); \
} else { \
UTLIST_CASTASGN(list, _ls_e); \
} \
UTLIST_SV(_ls_e, list); \
UTLIST_PREVASGN(_ls_e, list, _ls_tail, prev); \
UTLIST_RS(list); \
_ls_tail = _ls_e; \
} \
_ls_p = _ls_q; \
} \
UTLIST_CASTASGN((list)->prev, _ls_tail); \
UTLIST_CASTASGN(_tmp, list); \
UTLIST_SV(_ls_tail, list); \
UTLIST_NEXTASGN(_ls_tail, list, _tmp, next); \
UTLIST_RS(list); \
if (_ls_nmerges <= 1) { \
_ls_looping = 0; \
} \
_ls_insize *= 2; \
} \
} \
} while (0)
/******************************************************************************
@ -1079,8 +1079,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#define CDL_FOREACH_SAFE2(head, el, tmp1, tmp2, prev, next) \
for ((el) = (head), (tmp1) = (head) ? (head)->prev : NULL; \
(el) && ((tmp2) = (el)->next, 1); \
(el) = ((el) == (tmp1) ? NULL : (tmp2)))
(el) && ((tmp2) = (el)->next, 1); \
(el) = ((el) == (tmp1) ? NULL : (tmp2)))
#define CDL_SEARCH_SCALAR(head, out, field, val) \
CDL_SEARCH_SCALAR2(head, out, field, val, next)

View File

@ -97,7 +97,7 @@ instr_start(int rank, int nranks)
int curcpu = rank;
dbg("thread %d has cpu %d (ncpus=%d)\n",
gettid(), curcpu, nranks);
gettid(), curcpu, nranks);
instr_thread_execute(curcpu, -1, 0);
}

View File

@ -73,7 +73,7 @@ instr_start(int rank, int nranks)
int curcpu = rank;
fprintf(stderr, "thread %d has cpu %d (ncpus=%d)\n",
gettid(), curcpu, nranks);
gettid(), curcpu, nranks);
instr_thread_execute(curcpu, -1, 0);
}

View File

@ -85,7 +85,7 @@ instr_start(int rank)
curcpu = -1;
fprintf(stderr, "thread %d has cpu %d (ncpus=%d)\n",
gettid(), curcpu, CPU_COUNT(&mask));
gettid(), curcpu, CPU_COUNT(&mask));
instr_thread_execute(curcpu, -1, 0);
}

View File

@ -15,8 +15,8 @@ main(void)
nosv_task_type_t type;
if (nosv_type_init(&type, NULL, NULL, NULL, "adopted", NULL,
NULL, NOSV_TYPE_INIT_EXTERNAL)
!= 0)
NULL, NOSV_TYPE_INIT_EXTERNAL)
!= 0)
die("nosv_type_init failed\n");
nosv_task_t task;