Set continuation indent to 2 tabs
This commit is contained in:
parent
994f5f2098
commit
99793dba10
@ -17,7 +17,7 @@ BraceWrapping:
|
|||||||
AfterUnion: false
|
AfterUnion: false
|
||||||
BeforeElse: false
|
BeforeElse: false
|
||||||
ColumnLimit: 0
|
ColumnLimit: 0
|
||||||
ContinuationIndentWidth: 8
|
ContinuationIndentWidth: 16
|
||||||
IncludeBlocks: Preserve
|
IncludeBlocks: Preserve
|
||||||
IndentCaseLabels: true
|
IndentCaseLabels: true
|
||||||
IndentWidth: 8
|
IndentWidth: 8
|
||||||
|
60
src/chan.c
60
src/chan.c
@ -40,15 +40,15 @@ mark_dirty(struct ovni_chan *chan, enum chan_dirty dirty)
|
|||||||
|
|
||||||
void
|
void
|
||||||
chan_th_init(struct ovni_ethread *th,
|
chan_th_init(struct ovni_ethread *th,
|
||||||
struct ovni_chan **update_list,
|
struct ovni_chan **update_list,
|
||||||
enum chan id,
|
enum chan id,
|
||||||
enum chan_track track,
|
enum chan_track track,
|
||||||
int init_st,
|
int init_st,
|
||||||
int enabled,
|
int enabled,
|
||||||
int dirty,
|
int dirty,
|
||||||
int row,
|
int row,
|
||||||
FILE *prv,
|
FILE *prv,
|
||||||
int64_t *clock)
|
int64_t *clock)
|
||||||
{
|
{
|
||||||
struct ovni_chan *chan = &th->chan[id];
|
struct ovni_chan *chan = &th->chan[id];
|
||||||
int prvth = chan_to_prvtype[id];
|
int prvth = chan_to_prvtype[id];
|
||||||
@ -66,15 +66,15 @@ chan_th_init(struct ovni_ethread *th,
|
|||||||
|
|
||||||
void
|
void
|
||||||
chan_cpu_init(struct ovni_cpu *cpu,
|
chan_cpu_init(struct ovni_cpu *cpu,
|
||||||
struct ovni_chan **update_list,
|
struct ovni_chan **update_list,
|
||||||
enum chan id,
|
enum chan id,
|
||||||
enum chan_track track,
|
enum chan_track track,
|
||||||
int init_st,
|
int init_st,
|
||||||
int enabled,
|
int enabled,
|
||||||
int dirty,
|
int dirty,
|
||||||
int row,
|
int row,
|
||||||
FILE *prv,
|
FILE *prv,
|
||||||
int64_t *clock)
|
int64_t *clock)
|
||||||
{
|
{
|
||||||
struct ovni_chan *chan = &cpu->chan[id];
|
struct ovni_chan *chan = &cpu->chan[id];
|
||||||
int prvcpu = chan_to_prvtype[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);
|
mark_dirty(chan, CHAN_DIRTY_ACTIVE);
|
||||||
} else {
|
} else {
|
||||||
dbg("already dirty chan %d: skip update list\n",
|
dbg("already dirty chan %d: skip update list\n",
|
||||||
chan->id);
|
chan->id);
|
||||||
chan_dump_update_list(chan);
|
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()
|
* just enabled; it may collide with a new state 0 set via chan_set()
|
||||||
* used by the tracking channels */
|
* used by the tracking channels */
|
||||||
if (chan->dirty != CHAN_DIRTY_ACTIVE
|
if (chan->dirty != CHAN_DIRTY_ACTIVE
|
||||||
&& chan->lastst >= 0
|
&& chan->lastst >= 0
|
||||||
&& chan->lastst == st) {
|
&& chan->lastst == st) {
|
||||||
err("chan_set id=%d cannot emit the state %d twice\n",
|
err("chan_set id=%d cannot emit the state %d twice\n",
|
||||||
chan->id, st);
|
chan->id, st);
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -173,7 +173,7 @@ chan_set(struct ovni_chan *chan, int st)
|
|||||||
mark_dirty(chan, CHAN_DIRTY_VALUE);
|
mark_dirty(chan, CHAN_DIRTY_VALUE);
|
||||||
} else {
|
} else {
|
||||||
dbg("already dirty chan %d: skip update list\n",
|
dbg("already dirty chan %d: skip update list\n",
|
||||||
chan->id);
|
chan->id);
|
||||||
chan_dump_update_list(chan);
|
chan_dump_update_list(chan);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -197,7 +197,7 @@ chan_push(struct ovni_chan *chan, int st)
|
|||||||
|
|
||||||
if (chan->lastst >= 0 && chan->lastst == st) {
|
if (chan->lastst >= 0 && chan->lastst == st) {
|
||||||
err("chan_push id=%d cannot emit the state %d twice\n",
|
err("chan_push id=%d cannot emit the state %d twice\n",
|
||||||
chan->id, st);
|
chan->id, st);
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -233,7 +233,7 @@ chan_pop(struct ovni_chan *chan, int expected_st)
|
|||||||
|
|
||||||
if (expected_st >= 0 && st != expected_st) {
|
if (expected_st >= 0 && st != expected_st) {
|
||||||
err("chan_pop: unexpected channel state %d (expected %d)\n",
|
err("chan_pop: unexpected channel state %d (expected %d)\n",
|
||||||
st, expected_st);
|
st, expected_st);
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -250,7 +250,7 @@ chan_pop(struct ovni_chan *chan, int expected_st)
|
|||||||
|
|
||||||
if (chan->lastst >= 0 && chan->lastst == st) {
|
if (chan->lastst >= 0 && chan->lastst == st) {
|
||||||
err("chan_pop id=%d cannot emit the state %d twice\n",
|
err("chan_pop id=%d cannot emit the state %d twice\n",
|
||||||
chan->id, st);
|
chan->id, st);
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -278,7 +278,7 @@ chan_ev(struct ovni_chan *chan, int ev)
|
|||||||
|
|
||||||
if (chan->lastst >= 0 && chan->lastst == ev)
|
if (chan->lastst >= 0 && chan->lastst == ev)
|
||||||
die("chan_ev id=%d cannot emit the state %d twice\n",
|
die("chan_ev id=%d cannot emit the state %d twice\n",
|
||||||
chan->id, ev);
|
chan->id, ev);
|
||||||
|
|
||||||
chan->ev = ev;
|
chan->ev = ev;
|
||||||
chan->t = *chan->clock;
|
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
|
* it has been enabled or disabled. Otherwise is a bug (ie. you have two
|
||||||
* consecutive ovni events?) */
|
* consecutive ovni events?) */
|
||||||
if (chan->lastst != -1
|
if (chan->lastst != -1
|
||||||
&& chan->dirty == CHAN_DIRTY_VALUE
|
&& chan->dirty == CHAN_DIRTY_VALUE
|
||||||
&& chan->lastst == state) {
|
&& chan->lastst == state) {
|
||||||
/* TODO: Print the raw clock of the offending event */
|
/* TODO: Print the raw clock of the offending event */
|
||||||
die("emit: chan %d cannot emit the same state %d twice\n",
|
die("emit: chan %d cannot emit the same state %d twice\n",
|
||||||
chan->id, state);
|
chan->id, state);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (chan->lastst != state) {
|
if (chan->lastst != state) {
|
||||||
|
36
src/chan.h
36
src/chan.h
@ -8,27 +8,27 @@
|
|||||||
|
|
||||||
void
|
void
|
||||||
chan_th_init(struct ovni_ethread *th,
|
chan_th_init(struct ovni_ethread *th,
|
||||||
struct ovni_chan **update_list,
|
struct ovni_chan **update_list,
|
||||||
enum chan id,
|
enum chan id,
|
||||||
enum chan_track track,
|
enum chan_track track,
|
||||||
int init_st,
|
int init_st,
|
||||||
int enabled,
|
int enabled,
|
||||||
int dirty,
|
int dirty,
|
||||||
int row,
|
int row,
|
||||||
FILE *prv,
|
FILE *prv,
|
||||||
int64_t *clock);
|
int64_t *clock);
|
||||||
|
|
||||||
void
|
void
|
||||||
chan_cpu_init(struct ovni_cpu *cpu,
|
chan_cpu_init(struct ovni_cpu *cpu,
|
||||||
struct ovni_chan **update_list,
|
struct ovni_chan **update_list,
|
||||||
enum chan id,
|
enum chan id,
|
||||||
enum chan_track track,
|
enum chan_track track,
|
||||||
int row,
|
int row,
|
||||||
int init_st,
|
int init_st,
|
||||||
int enabled,
|
int enabled,
|
||||||
int dirty,
|
int dirty,
|
||||||
FILE *prv,
|
FILE *prv,
|
||||||
int64_t *clock);
|
int64_t *clock);
|
||||||
|
|
||||||
void
|
void
|
||||||
chan_enable(struct ovni_chan *chan, int enabled);
|
chan_enable(struct ovni_chan *chan, int enabled);
|
||||||
|
16
src/dump.c
16
src/dump.c
@ -27,13 +27,13 @@ emit(struct ovni_stream *stream, struct ovni_ev *ev)
|
|||||||
uint64_t clock = ovni_ev_get_clock(ev);
|
uint64_t clock = ovni_ev_get_clock(ev);
|
||||||
|
|
||||||
printf("%s.%d.%d %ld %c%c%c",
|
printf("%s.%d.%d %ld %c%c%c",
|
||||||
stream->loom->hostname,
|
stream->loom->hostname,
|
||||||
stream->proc->pid,
|
stream->proc->pid,
|
||||||
stream->thread->tid,
|
stream->thread->tid,
|
||||||
clock,
|
clock,
|
||||||
ev->header.model,
|
ev->header.model,
|
||||||
ev->header.category,
|
ev->header.category,
|
||||||
ev->header.value);
|
ev->header.value);
|
||||||
|
|
||||||
int payloadsize = ovni_payload_size(ev);
|
int payloadsize = ovni_payload_size(ev);
|
||||||
if (payloadsize > 0) {
|
if (payloadsize > 0) {
|
||||||
@ -90,7 +90,7 @@ dump_events(struct ovni_trace *trace)
|
|||||||
|
|
||||||
if (lastclock > ovni_ev_get_clock(stream->cur_ev)) {
|
if (lastclock > ovni_ev_get_clock(stream->cur_ev)) {
|
||||||
fprintf(stdout, "warning: backwards jump in time %lu -> %lu\n",
|
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 */
|
/* Emit current event */
|
||||||
|
110
src/emu.c
110
src/emu.c
@ -40,10 +40,10 @@ print_ev(struct ovni_stream *stream, struct ovni_ev *ev)
|
|||||||
UNUSED(delta);
|
UNUSED(delta);
|
||||||
|
|
||||||
dbg(">>> %s.%d.%d %c %c %c % 20ld % 15ld ",
|
dbg(">>> %s.%d.%d %c %c %c % 20ld % 15ld ",
|
||||||
stream->loom->hostname,
|
stream->loom->hostname,
|
||||||
stream->proc->pid,
|
stream->proc->pid,
|
||||||
stream->thread->tid,
|
stream->thread->tid,
|
||||||
ev->header.model, ev->header.category, ev->header.value, clock, delta);
|
ev->header.model, ev->header.category, ev->header.value, clock, delta);
|
||||||
|
|
||||||
int payloadsize = ovni_payload_size(ev);
|
int payloadsize = ovni_payload_size(ev);
|
||||||
for (int i = 0; i < payloadsize; i++) {
|
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;
|
break;
|
||||||
default:
|
default:
|
||||||
dbg("ignoring thread %d chan %d with track=%d\n",
|
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;
|
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 */
|
/* Only CPU enabled: is this possible? Set to bad */
|
||||||
chan_set(cpu_chan, ST_BAD);
|
chan_set(cpu_chan, ST_BAD);
|
||||||
err("warning: cpu %s chan %d enabled but tracked thread %d chan disabled\n",
|
err("warning: cpu %s chan %d enabled but tracked thread %d chan disabled\n",
|
||||||
cpu_chan->cpu->name,
|
cpu_chan->cpu->name,
|
||||||
cpu_chan->id,
|
cpu_chan->id,
|
||||||
th->tid);
|
th->tid);
|
||||||
} else {
|
} else {
|
||||||
/* Both disabled: disable CPU channel if needed */
|
/* Both disabled: disable CPU channel if needed */
|
||||||
if (chan_is_enabled(cpu_chan))
|
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",
|
dbg("cpu %s chan %d enabled=%d state=%d\n",
|
||||||
cpu_chan->cpu->name, cpu_chan->id,
|
cpu_chan->cpu->name, cpu_chan->id,
|
||||||
chan_is_enabled(cpu_chan),
|
chan_is_enabled(cpu_chan),
|
||||||
chan_get_st(cpu_chan));
|
chan_get_st(cpu_chan));
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -132,7 +132,7 @@ emu_cpu_update_chan(struct ovni_cpu *cpu, struct ovni_chan *cpu_chan)
|
|||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
dbg("ignoring %s chan %d with track=%d\n",
|
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;
|
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 */
|
/* A unique thread found: copy the state */
|
||||||
dbg("cpu_update_chan: unique thread %d found, updating chan %d\n",
|
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);
|
cpu_update_tracking_chan(cpu_chan, th);
|
||||||
} else {
|
} else {
|
||||||
@ -186,7 +186,7 @@ propagate_channels(struct ovni_emu *emu)
|
|||||||
struct ovni_chan *cpu_chan = &cpu->chan[th_chan->id];
|
struct ovni_chan *cpu_chan = &cpu->chan[th_chan->id];
|
||||||
|
|
||||||
dbg("propagate thread %d chan %d in cpu %s\n",
|
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);
|
emu_cpu_update_chan(cpu, cpu_chan);
|
||||||
}
|
}
|
||||||
@ -330,7 +330,7 @@ print_progress(struct ovni_emu *emu)
|
|||||||
double written = cpu_written + th_written;
|
double written = cpu_written + th_written;
|
||||||
|
|
||||||
double progress = ((double) emu->global_offset)
|
double progress = ((double) emu->global_offset)
|
||||||
/ ((double) emu->global_size);
|
/ ((double) emu->global_size);
|
||||||
|
|
||||||
double time_now = get_time();
|
double time_now = get_time();
|
||||||
double time_elapsed = time_now - emu->start_emulation_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);
|
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",
|
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,
|
100.0 * progress,
|
||||||
speed_in / 1024.0,
|
speed_in / 1024.0,
|
||||||
cpu_written / (1024.0 * 1024.0 * 1024.0),
|
cpu_written / (1024.0 * 1024.0 * 1024.0),
|
||||||
th_written / (1024.0 * 1024.0 * 1024.0),
|
th_written / (1024.0 * 1024.0 * 1024.0),
|
||||||
speed_out / (1024.0 * 1024),
|
speed_out / (1024.0 * 1024),
|
||||||
tmin, sec);
|
tmin, sec);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Loads the next event and sets the lastclock in the stream.
|
/* 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) {
|
if (emu->lastclock > stream->lastclock) {
|
||||||
err("warning: backwards jump in time %lu -> %lu for tid %d\n",
|
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)
|
if (emu->enable_linter)
|
||||||
abort();
|
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)
|
if (i < 0 || i >= (int) loom->ncpus)
|
||||||
die("CPU with index %d in loom %s is out of bounds\n",
|
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)
|
if (cpu->state != CPU_ST_UNKNOWN)
|
||||||
die("new cpu %d in unexpected state in loom %s\n",
|
die("new cpu %d in unexpected state in loom %s\n",
|
||||||
i, loom->hostname);
|
i, loom->hostname);
|
||||||
|
|
||||||
cpu->state = CPU_ST_READY;
|
cpu->state = CPU_ST_READY;
|
||||||
cpu->i = i;
|
cpu->i = i;
|
||||||
@ -525,8 +525,8 @@ add_new_cpu(struct ovni_emu *emu, struct ovni_loom *loom, int i, int phyid)
|
|||||||
|
|
||||||
static int
|
static int
|
||||||
proc_load_cpus(struct ovni_emu *emu, struct ovni_loom *loom,
|
proc_load_cpus(struct ovni_emu *emu, struct ovni_loom *loom,
|
||||||
struct ovni_eproc *proc,
|
struct ovni_eproc *proc,
|
||||||
struct ovni_eproc *metadata_proc)
|
struct ovni_eproc *metadata_proc)
|
||||||
{
|
{
|
||||||
JSON_Object *meta = json_value_get_object(proc->meta);
|
JSON_Object *meta = json_value_get_object(proc->meta);
|
||||||
if (meta == NULL)
|
if (meta == NULL)
|
||||||
@ -540,8 +540,8 @@ proc_load_cpus(struct ovni_emu *emu, struct ovni_loom *loom,
|
|||||||
|
|
||||||
if (metadata_proc)
|
if (metadata_proc)
|
||||||
die("duplicated metadata for proc %d and %d in loom %s\n",
|
die("duplicated metadata for proc %d and %d in loom %s\n",
|
||||||
metadata_proc->pid, proc->pid,
|
metadata_proc->pid, proc->pid,
|
||||||
loom->hostname);
|
loom->hostname);
|
||||||
|
|
||||||
if (loom->ncpus != 0)
|
if (loom->ncpus != 0)
|
||||||
die("loom %s already has CPUs\n", loom->hostname);
|
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)
|
if (loom->ncpus == 0)
|
||||||
die("loom %s proc %d has metadata but no CPUs\n",
|
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));
|
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;
|
struct ovni_cpu *vcpu = &loom->vcpu;
|
||||||
if (vcpu->state != CPU_ST_UNKNOWN)
|
if (vcpu->state != CPU_ST_UNKNOWN)
|
||||||
die("unexpected virtual CPU state in loom %s\n",
|
die("unexpected virtual CPU state in loom %s\n",
|
||||||
loom->hostname);
|
loom->hostname);
|
||||||
|
|
||||||
vcpu->state = CPU_ST_READY;
|
vcpu->state = CPU_ST_READY;
|
||||||
vcpu->i = -1;
|
vcpu->i = -1;
|
||||||
@ -608,8 +608,8 @@ load_metadata(struct ovni_emu *emu)
|
|||||||
|
|
||||||
if (metadata_proc)
|
if (metadata_proc)
|
||||||
die("duplicated metadata found in pid %d and %d\n",
|
die("duplicated metadata found in pid %d and %d\n",
|
||||||
metadata_proc->pid,
|
metadata_proc->pid,
|
||||||
proc->pid);
|
proc->pid);
|
||||||
|
|
||||||
metadata_proc = proc;
|
metadata_proc = proc;
|
||||||
}
|
}
|
||||||
@ -656,7 +656,7 @@ open_prvs(struct ovni_emu *emu, char *tracedir)
|
|||||||
|
|
||||||
if (emu->prv_thread == NULL) {
|
if (emu->prv_thread == NULL) {
|
||||||
err("error opening thread PRV file %s: %s\n", path,
|
err("error opening thread PRV file %s: %s\n", path,
|
||||||
strerror(errno));
|
strerror(errno));
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -666,7 +666,7 @@ open_prvs(struct ovni_emu *emu, char *tracedir)
|
|||||||
|
|
||||||
if (emu->prv_cpu == NULL) {
|
if (emu->prv_cpu == NULL) {
|
||||||
err("error opening cpu PRV file %s: %s\n", path,
|
err("error opening cpu PRV file %s: %s\n", path,
|
||||||
strerror(errno));
|
strerror(errno));
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -785,15 +785,15 @@ load_clock_offsets(struct ovni_emu *emu)
|
|||||||
/* If provided by the user, it must exist */
|
/* If provided by the user, it must exist */
|
||||||
if (f == NULL) {
|
if (f == NULL) {
|
||||||
err("error opening clock offset file %s: %s\n",
|
err("error opening clock offset file %s: %s\n",
|
||||||
emu->clock_offset_file,
|
emu->clock_offset_file,
|
||||||
strerror(errno));
|
strerror(errno));
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
char path[PATH_MAX];
|
char path[PATH_MAX];
|
||||||
if (snprintf(path, PATH_MAX, "%s/clock-offsets.txt",
|
if (snprintf(path, PATH_MAX, "%s/clock-offsets.txt",
|
||||||
emu->tracedir)
|
emu->tracedir)
|
||||||
>= PATH_MAX) {
|
>= PATH_MAX) {
|
||||||
die("clock offset path too long\n");
|
die("clock offset path too long\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -830,7 +830,7 @@ load_clock_offsets(struct ovni_emu *emu)
|
|||||||
|
|
||||||
if (ret != 5) {
|
if (ret != 5) {
|
||||||
err("fscanf read %d instead of 5 fields in %s\n",
|
err("fscanf read %d instead of 5 fields in %s\n",
|
||||||
ret, emu->clock_offset_file);
|
ret, emu->clock_offset_file);
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -929,7 +929,7 @@ init_threads(struct ovni_emu *emu)
|
|||||||
}
|
}
|
||||||
|
|
||||||
emu->global_thread = calloc(emu->total_nthreads,
|
emu->global_thread = calloc(emu->total_nthreads,
|
||||||
sizeof(*emu->global_thread));
|
sizeof(*emu->global_thread));
|
||||||
|
|
||||||
if (emu->global_thread == NULL) {
|
if (emu->global_thread == NULL) {
|
||||||
perror("calloc failed");
|
perror("calloc failed");
|
||||||
@ -958,7 +958,7 @@ init_cpus(struct ovni_emu *emu)
|
|||||||
struct ovni_trace *trace = &emu->trace;
|
struct ovni_trace *trace = &emu->trace;
|
||||||
|
|
||||||
emu->global_cpu = calloc(emu->total_ncpus,
|
emu->global_cpu = calloc(emu->total_ncpus,
|
||||||
sizeof(*emu->global_cpu));
|
sizeof(*emu->global_cpu));
|
||||||
|
|
||||||
if (emu->global_cpu == NULL) {
|
if (emu->global_cpu == NULL) {
|
||||||
perror("calloc");
|
perror("calloc");
|
||||||
@ -972,7 +972,7 @@ init_cpus(struct ovni_emu *emu)
|
|||||||
emu->global_cpu[cpu->gindex] = cpu;
|
emu->global_cpu[cpu->gindex] = cpu;
|
||||||
|
|
||||||
if (snprintf(cpu->name, MAX_CPU_NAME, "CPU %ld.%ld", i, j)
|
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);
|
err("error cpu %ld.%ld name too long\n", i, j);
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
@ -981,7 +981,7 @@ init_cpus(struct ovni_emu *emu)
|
|||||||
|
|
||||||
emu->global_cpu[loom->vcpu.gindex] = &loom->vcpu;
|
emu->global_cpu[loom->vcpu.gindex] = &loom->vcpu;
|
||||||
if (snprintf(loom->vcpu.name, MAX_CPU_NAME, "CPU %ld.*", i)
|
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);
|
err("error cpu %ld.* name too long\n", i);
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
@ -1041,8 +1041,8 @@ emu_init(struct ovni_emu *emu, int argc, char *argv[])
|
|||||||
emu->global_offset = 0;
|
emu->global_offset = 0;
|
||||||
|
|
||||||
err("loaded %ld cpus and %ld threads\n",
|
err("loaded %ld cpus and %ld threads\n",
|
||||||
emu->total_ncpus,
|
emu->total_ncpus,
|
||||||
emu->total_nthreads);
|
emu->total_nthreads);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -1081,11 +1081,11 @@ edie(struct ovni_emu *emu, const char *fmt, ...)
|
|||||||
va_end(args);
|
va_end(args);
|
||||||
|
|
||||||
fprintf(stderr, "fatal: while evaluating the event %c%c%c with clock=%ld in thread=%d\n",
|
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.model,
|
||||||
emu->cur_ev->header.category,
|
emu->cur_ev->header.category,
|
||||||
emu->cur_ev->header.value,
|
emu->cur_ev->header.value,
|
||||||
emu->cur_ev->header.clock,
|
emu->cur_ev->header.clock,
|
||||||
emu->cur_thread->tid);
|
emu->cur_thread->tid);
|
||||||
|
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
@ -1101,11 +1101,11 @@ eerr(struct ovni_emu *emu, const char *fmt, ...)
|
|||||||
va_end(args);
|
va_end(args);
|
||||||
|
|
||||||
fprintf(stderr, "fatal: while evaluating the event %c%c%c with clock=%ld in thread=%d\n",
|
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.model,
|
||||||
emu->cur_ev->header.category,
|
emu->cur_ev->header.category,
|
||||||
emu->cur_ev->header.value,
|
emu->cur_ev->header.value,
|
||||||
emu->cur_ev->header.clock,
|
emu->cur_ev->header.clock,
|
||||||
emu->cur_thread->tid);
|
emu->cur_thread->tid);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
@ -54,7 +54,7 @@ context_switch(struct ovni_emu *emu)
|
|||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
edie(emu, "unexpected value '%c' (expecting 'O' or 'I')\n",
|
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')
|
if (emu->cur_ev->header.model != 'K')
|
||||||
edie(emu, "hook_pre_kernel: unexpected event with model %c\n",
|
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) {
|
switch (emu->cur_ev->header.category) {
|
||||||
case 'C':
|
case 'C':
|
||||||
@ -71,6 +71,6 @@ hook_pre_kernel(struct ovni_emu *emu)
|
|||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
edie(emu, "hook_pre_kernel: unexpected event with category %c\n",
|
edie(emu, "hook_pre_kernel: unexpected event with category %c\n",
|
||||||
emu->cur_ev->header.category);
|
emu->cur_ev->header.category);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -89,7 +89,7 @@ chan_task_running(struct ovni_emu *emu, struct task *task)
|
|||||||
|
|
||||||
static void
|
static void
|
||||||
chan_task_switch(struct ovni_emu *emu,
|
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;
|
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
|
static void
|
||||||
update_task_channels(struct ovni_emu *emu,
|
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) {
|
switch (tr) {
|
||||||
case 'x':
|
case 'x':
|
||||||
@ -200,7 +200,7 @@ update_task_channels(struct ovni_emu *emu,
|
|||||||
|
|
||||||
static void
|
static void
|
||||||
enforce_task_rules(struct ovni_emu *emu,
|
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);
|
UNUSED(prev);
|
||||||
@ -524,7 +524,7 @@ pre_ss(struct ovni_emu *emu, int st)
|
|||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
edie(emu, "unexpected value '%c' (expecting '[' or ']')\n",
|
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')
|
if (emu->cur_ev->header.model != '6')
|
||||||
edie(emu, "hook_pre_nanos6: unexpected event with model %c\n",
|
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) {
|
if (!emu->cur_thread->is_active) {
|
||||||
edie(emu, "hook_pre_nanos6: current thread %d not active\n",
|
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) {
|
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",
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -53,7 +53,7 @@ pre_subsystem(struct ovni_emu *emu, int st)
|
|||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
edie(emu, "unexpected value '%c' (expecting '[' or ']')\n",
|
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')
|
if (emu->cur_ev->header.model != 'D')
|
||||||
edie(emu, "hook_pre_nodes: unexpected event with model %c\n",
|
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)
|
if (!emu->cur_thread->is_running)
|
||||||
edie(emu, "hook_pre_nodes: current thread %d not running\n",
|
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) {
|
switch (emu->cur_ev->header.category) {
|
||||||
case 'R':
|
case 'R':
|
||||||
|
@ -103,7 +103,7 @@ chan_task_running(struct ovni_emu *emu, struct task *task)
|
|||||||
|
|
||||||
static void
|
static void
|
||||||
chan_task_switch(struct ovni_emu *emu,
|
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;
|
struct ovni_ethread *th = emu->cur_thread;
|
||||||
|
|
||||||
@ -168,7 +168,7 @@ update_task_state(struct ovni_emu *emu)
|
|||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
edie(emu, "unexpected Nanos6 task event value %c\n",
|
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
|
static void
|
||||||
update_task_channels(struct ovni_emu *emu,
|
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) {
|
switch (tr) {
|
||||||
case 'x':
|
case 'x':
|
||||||
@ -269,7 +269,7 @@ pre_task(struct ovni_emu *emu)
|
|||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
edie(emu, "unexpected task event value %c\n",
|
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')
|
if (emu->cur_ev->header.value != 'c')
|
||||||
edie(emu, "unexpected event value %c\n",
|
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)
|
if ((emu->cur_ev->header.flags & OVNI_EV_JUMBO) == 0)
|
||||||
edie(emu, "expecting a jumbo event\n");
|
edie(emu, "expecting a jumbo event\n");
|
||||||
@ -440,7 +440,7 @@ pre_ss(struct ovni_emu *emu, int st)
|
|||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
err("unexpected value '%c' (expecting '[' or ']')\n",
|
err("unexpected value '%c' (expecting '[' or ']')\n",
|
||||||
emu->cur_ev->header.value);
|
emu->cur_ev->header.value);
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -459,7 +459,7 @@ check_affinity(struct ovni_emu *emu)
|
|||||||
|
|
||||||
if (cpu->nrunning_threads > 1) {
|
if (cpu->nrunning_threads > 1) {
|
||||||
edie(emu, "cpu %s has more than one thread running\n",
|
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')
|
if (emu->cur_ev->header.model != 'V')
|
||||||
edie(emu, "hook_pre_nosv: unexpected event with model %c\n",
|
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)
|
if (!emu->cur_thread->is_active)
|
||||||
edie(emu, "hook_pre_nosv: current thread %d not active\n",
|
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) {
|
switch (emu->cur_ev->header.category) {
|
||||||
case 'T':
|
case 'T':
|
||||||
|
@ -53,7 +53,7 @@ pre_mode(struct ovni_emu *emu, int st)
|
|||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
err("unexpected value '%c' (expecting '[' or ']')\n",
|
err("unexpected value '%c' (expecting '[' or ']')\n",
|
||||||
emu->cur_ev->header.value);
|
emu->cur_ev->header.value);
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -63,11 +63,11 @@ hook_pre_openmp(struct ovni_emu *emu)
|
|||||||
{
|
{
|
||||||
if (emu->cur_ev->header.model != 'M')
|
if (emu->cur_ev->header.model != 'M')
|
||||||
die("hook_pre_openmp: unexpected event with model %c\n",
|
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)
|
if (!emu->cur_thread->is_active)
|
||||||
die("hook_pre_openmp: current thread %d not active\n",
|
die("hook_pre_openmp: current thread %d not active\n",
|
||||||
emu->cur_thread->tid);
|
emu->cur_thread->tid);
|
||||||
|
|
||||||
switch (emu->cur_ev->header.category) {
|
switch (emu->cur_ev->header.category) {
|
||||||
case 'T':
|
case 'T':
|
||||||
|
@ -65,7 +65,7 @@ chan_tracking_update(struct ovni_chan *chan, struct ovni_ethread *th)
|
|||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
dbg("ignoring thread %d chan %d with track=%d\n",
|
dbg("ignoring thread %d chan %d with track=%d\n",
|
||||||
th->tid, chan->id, chan->track);
|
th->tid, chan->id, chan->track);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -74,7 +74,7 @@ chan_tracking_update(struct ovni_chan *chan, struct ovni_ethread *th)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
dbg("thread %d changes state to %d: chan %d enabled=%d\n",
|
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);
|
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 */
|
/* The state must be updated when a cpu is set */
|
||||||
if (th->cpu == NULL)
|
if (th->cpu == NULL)
|
||||||
die("thread_set_state: thread %d doesn't have a CPU\n",
|
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",
|
dbg("thread_set_state: setting thread %d state %d\n",
|
||||||
th->tid, state);
|
th->tid, state);
|
||||||
|
|
||||||
th->state = state;
|
th->state = state;
|
||||||
|
|
||||||
th->is_running = (state == TH_ST_RUNNING) ? 1 : 0;
|
th->is_running = (state == TH_ST_RUNNING) ? 1 : 0;
|
||||||
|
|
||||||
th->is_active = (state == TH_ST_RUNNING
|
th->is_active = (state == TH_ST_RUNNING
|
||||||
|| state == TH_ST_COOLING
|
|| state == TH_ST_COOLING
|
||||||
|| state == TH_ST_WARMING)
|
|| state == TH_ST_WARMING)
|
||||||
? 1
|
? 1
|
||||||
: 0;
|
: 0;
|
||||||
|
|
||||||
chan_set(&th->chan[CHAN_OVNI_STATE], th->state);
|
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 */
|
/* Found, abort */
|
||||||
if (emu_cpu_find_thread(cpu, thread) != NULL) {
|
if (emu_cpu_find_thread(cpu, thread) != NULL) {
|
||||||
err("The thread %d is already assigned to %s\n",
|
err("The thread %d is already assigned to %s\n",
|
||||||
thread->tid, cpu->name);
|
thread->tid, cpu->name);
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -208,7 +208,7 @@ cpu_remove_thread(struct ovni_cpu *cpu, struct ovni_ethread *thread)
|
|||||||
/* Not found, abort */
|
/* Not found, abort */
|
||||||
if (p == NULL) {
|
if (p == NULL) {
|
||||||
err("cannot remove missing thread %d from cpu %s\n",
|
err("cannot remove missing thread %d from cpu %s\n",
|
||||||
thread->tid, cpu->name);
|
thread->tid, cpu->name);
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -220,8 +220,8 @@ cpu_remove_thread(struct ovni_cpu *cpu, struct ovni_ethread *thread)
|
|||||||
|
|
||||||
static void
|
static void
|
||||||
cpu_migrate_thread(struct ovni_cpu *cpu,
|
cpu_migrate_thread(struct ovni_cpu *cpu,
|
||||||
struct ovni_ethread *thread,
|
struct ovni_ethread *thread,
|
||||||
struct ovni_cpu *newcpu)
|
struct ovni_cpu *newcpu)
|
||||||
{
|
{
|
||||||
cpu_remove_thread(cpu, thread);
|
cpu_remove_thread(cpu, thread);
|
||||||
cpu_add_thread(newcpu, 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)
|
if (th->cpu != NULL)
|
||||||
die("thread_set_cpu: thread %d already has a CPU\n",
|
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",
|
dbg("thread_set_cpu: setting thread %d cpu to %s\n",
|
||||||
th->tid, cpu->name);
|
th->tid, cpu->name);
|
||||||
th->cpu = cpu;
|
th->cpu = cpu;
|
||||||
|
|
||||||
chan_enable(&th->chan[CHAN_OVNI_CPU], 1);
|
chan_enable(&th->chan[CHAN_OVNI_CPU], 1);
|
||||||
@ -251,7 +251,7 @@ thread_unset_cpu(struct ovni_ethread *th)
|
|||||||
{
|
{
|
||||||
if (th->cpu == NULL)
|
if (th->cpu == NULL)
|
||||||
die("thread_unset_cpu: thread %d doesn't have a CPU\n",
|
die("thread_unset_cpu: thread %d doesn't have a CPU\n",
|
||||||
th->tid);
|
th->tid);
|
||||||
|
|
||||||
th->cpu = NULL;
|
th->cpu = NULL;
|
||||||
|
|
||||||
@ -265,7 +265,7 @@ thread_migrate_cpu(struct ovni_ethread *th, struct ovni_cpu *cpu)
|
|||||||
{
|
{
|
||||||
if (th->cpu == NULL)
|
if (th->cpu == NULL)
|
||||||
die("thread_migrate_cpu: thread %d doesn't have a CPU\n",
|
die("thread_migrate_cpu: thread %d doesn't have a CPU\n",
|
||||||
th->tid);
|
th->tid);
|
||||||
th->cpu = cpu;
|
th->cpu = cpu;
|
||||||
|
|
||||||
chan_set(&th->chan[CHAN_OVNI_CPU], cpu->gindex + 1);
|
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 */
|
/* The thread cannot be already running */
|
||||||
if (th->state == TH_ST_RUNNING)
|
if (th->state == TH_ST_RUNNING)
|
||||||
edie(emu, "pre_thread_execute: thread %d already running\n",
|
edie(emu, "pre_thread_execute: thread %d already running\n",
|
||||||
th->tid);
|
th->tid);
|
||||||
|
|
||||||
int cpuid = emu->cur_ev->payload.i32[0];
|
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)
|
if (th->state != TH_ST_RUNNING && th->state != TH_ST_COOLING)
|
||||||
die("pre_thread_end: thread %d not running or cooling\n",
|
die("pre_thread_end: thread %d not running or cooling\n",
|
||||||
th->tid);
|
th->tid);
|
||||||
|
|
||||||
if (th->cpu == NULL)
|
if (th->cpu == NULL)
|
||||||
die("pre_thread_end: thread %d doesn't have a CPU\n",
|
die("pre_thread_end: thread %d doesn't have a CPU\n",
|
||||||
th->tid);
|
th->tid);
|
||||||
|
|
||||||
/* First update the thread state */
|
/* First update the thread state */
|
||||||
thread_set_state(th, TH_ST_DEAD);
|
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)
|
if (th->state != TH_ST_RUNNING && th->state != TH_ST_COOLING)
|
||||||
die("pre_thread_pause: thread %d not running or cooling\n",
|
die("pre_thread_pause: thread %d not running or cooling\n",
|
||||||
th->tid);
|
th->tid);
|
||||||
|
|
||||||
if (th->cpu == NULL)
|
if (th->cpu == NULL)
|
||||||
die("pre_thread_pause: thread %d doesn't have a CPU\n",
|
die("pre_thread_pause: thread %d doesn't have a CPU\n",
|
||||||
th->tid);
|
th->tid);
|
||||||
|
|
||||||
thread_set_state(th, TH_ST_PAUSED);
|
thread_set_state(th, TH_ST_PAUSED);
|
||||||
update_cpu(th->cpu);
|
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)
|
if (th->state != TH_ST_PAUSED && th->state != TH_ST_WARMING)
|
||||||
die("pre_thread_resume: thread %d not paused or warming\n",
|
die("pre_thread_resume: thread %d not paused or warming\n",
|
||||||
th->tid);
|
th->tid);
|
||||||
|
|
||||||
if (th->cpu == NULL)
|
if (th->cpu == NULL)
|
||||||
die("pre_thread_resume: thread %d doesn't have a CPU\n",
|
die("pre_thread_resume: thread %d doesn't have a CPU\n",
|
||||||
th->tid);
|
th->tid);
|
||||||
|
|
||||||
thread_set_state(th, TH_ST_RUNNING);
|
thread_set_state(th, TH_ST_RUNNING);
|
||||||
update_cpu(th->cpu);
|
update_cpu(th->cpu);
|
||||||
@ -350,11 +350,11 @@ pre_thread_cool(struct ovni_ethread *th)
|
|||||||
{
|
{
|
||||||
if (th->state != TH_ST_RUNNING)
|
if (th->state != TH_ST_RUNNING)
|
||||||
die("pre_thread_cool: thread %d not running\n",
|
die("pre_thread_cool: thread %d not running\n",
|
||||||
th->tid);
|
th->tid);
|
||||||
|
|
||||||
if (th->cpu == NULL)
|
if (th->cpu == NULL)
|
||||||
die("pre_thread_cool: thread %d doesn't have a CPU\n",
|
die("pre_thread_cool: thread %d doesn't have a CPU\n",
|
||||||
th->tid);
|
th->tid);
|
||||||
|
|
||||||
thread_set_state(th, TH_ST_COOLING);
|
thread_set_state(th, TH_ST_COOLING);
|
||||||
update_cpu(th->cpu);
|
update_cpu(th->cpu);
|
||||||
@ -365,11 +365,11 @@ pre_thread_warm(struct ovni_ethread *th)
|
|||||||
{
|
{
|
||||||
if (th->state != TH_ST_PAUSED)
|
if (th->state != TH_ST_PAUSED)
|
||||||
die("pre_thread_warm: thread %d not paused\n",
|
die("pre_thread_warm: thread %d not paused\n",
|
||||||
th->tid);
|
th->tid);
|
||||||
|
|
||||||
if (th->cpu == NULL)
|
if (th->cpu == NULL)
|
||||||
die("pre_thread_warm: thread %d doesn't have a CPU\n",
|
die("pre_thread_warm: thread %d doesn't have a CPU\n",
|
||||||
th->tid);
|
th->tid);
|
||||||
|
|
||||||
thread_set_state(th, TH_ST_WARMING);
|
thread_set_state(th, TH_ST_WARMING);
|
||||||
update_cpu(th->cpu);
|
update_cpu(th->cpu);
|
||||||
@ -384,10 +384,10 @@ pre_thread(struct ovni_emu *emu)
|
|||||||
switch (ev->header.value) {
|
switch (ev->header.value) {
|
||||||
case 'C': /* create */
|
case 'C': /* create */
|
||||||
dbg("thread %d creates a new thread at cpu=%d with args=%x %x\n",
|
dbg("thread %d creates a new thread at cpu=%d with args=%x %x\n",
|
||||||
th->tid,
|
th->tid,
|
||||||
ev->payload.u32[0],
|
ev->payload.u32[0],
|
||||||
ev->payload.u32[1],
|
ev->payload.u32[1],
|
||||||
ev->payload.u32[2]);
|
ev->payload.u32[2]);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case 'x':
|
case 'x':
|
||||||
@ -410,7 +410,7 @@ pre_thread(struct ovni_emu *emu)
|
|||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
err("unknown thread event value %c\n",
|
err("unknown thread event value %c\n",
|
||||||
ev->header.value);
|
ev->header.value);
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -423,11 +423,11 @@ pre_affinity_set(struct ovni_emu *emu)
|
|||||||
|
|
||||||
if (th->cpu == NULL)
|
if (th->cpu == NULL)
|
||||||
edie(emu, "pre_affinity_set: thread %d doesn't have a CPU\n",
|
edie(emu, "pre_affinity_set: thread %d doesn't have a CPU\n",
|
||||||
th->tid);
|
th->tid);
|
||||||
|
|
||||||
if (!th->is_active)
|
if (!th->is_active)
|
||||||
edie(emu, "pre_affinity_set: thread %d is not active\n",
|
edie(emu, "pre_affinity_set: thread %d is not active\n",
|
||||||
th->tid);
|
th->tid);
|
||||||
|
|
||||||
/* Migrate current cpu to the one at cpuid */
|
/* Migrate current cpu to the one at cpuid */
|
||||||
struct ovni_cpu *newcpu = emu_get_cpu(emu->cur_loom, 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) {
|
if (remote_th == NULL) {
|
||||||
err("thread tid %d not found: cannot set affinity remotely\n",
|
err("thread tid %d not found: cannot set affinity remotely\n",
|
||||||
tid);
|
tid);
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -478,16 +478,16 @@ pre_affinity_remote(struct ovni_emu *emu)
|
|||||||
/* The remote_th cannot be in states dead or unknown */
|
/* The remote_th cannot be in states dead or unknown */
|
||||||
if (remote_th->state == TH_ST_DEAD)
|
if (remote_th->state == TH_ST_DEAD)
|
||||||
edie(emu, "pre_affinity_remote: remote thread %d in state DEAD\n",
|
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)
|
if (remote_th->state == TH_ST_UNKNOWN)
|
||||||
edie(emu, "pre_affinity_remote: remote thread %d in state UNKNOWN\n",
|
edie(emu, "pre_affinity_remote: remote thread %d in state UNKNOWN\n",
|
||||||
remote_th->tid);
|
remote_th->tid);
|
||||||
|
|
||||||
/* It must have an assigned CPU */
|
/* It must have an assigned CPU */
|
||||||
if (remote_th->cpu == NULL)
|
if (remote_th->cpu == NULL)
|
||||||
edie(emu, "pre_affinity_remote: remote thread %d has no CPU\n",
|
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 */
|
/* Migrate current cpu to the one at cpuid */
|
||||||
struct ovni_cpu *newcpu = emu_get_cpu(emu->cur_loom, cpuid);
|
struct ovni_cpu *newcpu = emu_get_cpu(emu->cur_loom, cpuid);
|
||||||
@ -512,7 +512,7 @@ pre_affinity(struct ovni_emu *emu)
|
|||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
dbg("unknown affinity event value %c\n",
|
dbg("unknown affinity event value %c\n",
|
||||||
emu->cur_ev->header.value);
|
emu->cur_ev->header.value);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -565,7 +565,7 @@ pre_flush(struct ovni_emu *emu)
|
|||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
err("unexpected value '%c' (expecting '[' or ']')\n",
|
err("unexpected value '%c' (expecting '[' or ']')\n",
|
||||||
emu->cur_ev->header.value);
|
emu->cur_ev->header.value);
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -591,7 +591,7 @@ hook_pre_ovni(struct ovni_emu *emu)
|
|||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
dbg("unknown ovni event category %c\n",
|
dbg("unknown ovni event category %c\n",
|
||||||
emu->cur_ev->header.category);
|
emu->cur_ev->header.category);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -52,7 +52,7 @@ pre_tampi_mode(struct ovni_emu *emu, int state)
|
|||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
edie(emu, "unexpected event value %c for tampi mode\n",
|
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')
|
if (emu->cur_ev->header.model != 'T')
|
||||||
edie(emu, "hook_pre_tampi: unexpected event with model %c\n",
|
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) {
|
switch (emu->cur_ev->header.category) {
|
||||||
case 'S':
|
case 'S':
|
||||||
|
@ -30,12 +30,12 @@ task_type_find(struct task_type *types, uint32_t type_id)
|
|||||||
|
|
||||||
void
|
void
|
||||||
task_create(struct ovni_emu *emu, struct task_info *info,
|
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 */
|
/* Ensure the task id is new */
|
||||||
if (task_find(info->tasks, task_id) != NULL)
|
if (task_find(info->tasks, task_id) != NULL)
|
||||||
edie(emu, "cannot create task: task_id %u already exists\n",
|
edie(emu, "cannot create task: task_id %u already exists\n",
|
||||||
task_id);
|
task_id);
|
||||||
|
|
||||||
/* Ensure the type exists */
|
/* Ensure the type exists */
|
||||||
struct task_type *type = task_type_find(info->types, type_id);
|
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
|
void
|
||||||
task_execute(struct ovni_emu *emu,
|
task_execute(struct ovni_emu *emu,
|
||||||
struct task_stack *stack, struct task *task)
|
struct task_stack *stack, struct task *task)
|
||||||
{
|
{
|
||||||
if (task == NULL)
|
if (task == NULL)
|
||||||
edie(emu, "cannot execute: task is NULL\n");
|
edie(emu, "cannot execute: task is NULL\n");
|
||||||
@ -90,7 +90,7 @@ task_execute(struct ovni_emu *emu,
|
|||||||
|
|
||||||
void
|
void
|
||||||
task_pause(struct ovni_emu *emu,
|
task_pause(struct ovni_emu *emu,
|
||||||
struct task_stack *stack, struct task *task)
|
struct task_stack *stack, struct task *task)
|
||||||
{
|
{
|
||||||
if (task == NULL)
|
if (task == NULL)
|
||||||
edie(emu, "cannot pause: task is NULL\n");
|
edie(emu, "cannot pause: task is NULL\n");
|
||||||
@ -117,7 +117,7 @@ task_pause(struct ovni_emu *emu,
|
|||||||
|
|
||||||
void
|
void
|
||||||
task_resume(struct ovni_emu *emu,
|
task_resume(struct ovni_emu *emu,
|
||||||
struct task_stack *stack, struct task *task)
|
struct task_stack *stack, struct task *task)
|
||||||
{
|
{
|
||||||
if (task == NULL)
|
if (task == NULL)
|
||||||
edie(emu, "cannot resume: task is NULL\n");
|
edie(emu, "cannot resume: task is NULL\n");
|
||||||
@ -144,7 +144,7 @@ task_resume(struct ovni_emu *emu,
|
|||||||
|
|
||||||
void
|
void
|
||||||
task_end(struct ovni_emu *emu,
|
task_end(struct ovni_emu *emu,
|
||||||
struct task_stack *stack, struct task *task)
|
struct task_stack *stack, struct task *task)
|
||||||
{
|
{
|
||||||
if (task == NULL)
|
if (task == NULL)
|
||||||
edie(emu, "cannot end: task is NULL\n");
|
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);
|
HASH_ADD_INT(info->types, id, type);
|
||||||
|
|
||||||
dbg("new task type created id=%d label=%s\n", type->id,
|
dbg("new task type created id=%d label=%s\n", type->id,
|
||||||
type->label);
|
type->label);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -120,7 +120,7 @@ heap_get_move(size_t *node /*out*/)
|
|||||||
|
|
||||||
// Round to previous po2
|
// Round to previous po2
|
||||||
size_t base = (1ULL) << (sizeof(size_t) * 8
|
size_t base = (1ULL) << (sizeof(size_t) * 8
|
||||||
- __builtin_clzll(aux_node) - 1);
|
- __builtin_clzll(aux_node) - 1);
|
||||||
|
|
||||||
aux_node -= base / 2;
|
aux_node -= base / 2;
|
||||||
|
|
||||||
|
20
src/ovni.c
20
src/ovni.c
@ -30,11 +30,11 @@ create_trace_stream(void)
|
|||||||
char path[PATH_MAX];
|
char path[PATH_MAX];
|
||||||
|
|
||||||
int written = snprintf(path, PATH_MAX, "%s/thread.%d",
|
int written = snprintf(path, PATH_MAX, "%s/thread.%d",
|
||||||
rproc.procdir, rthread.tid);
|
rproc.procdir, rthread.tid);
|
||||||
|
|
||||||
if (written >= PATH_MAX)
|
if (written >= PATH_MAX)
|
||||||
die("thread trace path too long: %s/thread.%d\n",
|
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);
|
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)
|
if (snprintf(path, PATH_MAX, "%s/metadata.json", procdir) >= PATH_MAX)
|
||||||
die("metadata path too long: %s/metadata.json\n",
|
die("metadata path too long: %s/metadata.json\n",
|
||||||
procdir);
|
procdir);
|
||||||
|
|
||||||
if (json_serialize_to_file_pretty(meta, path) != JSONSuccess)
|
if (json_serialize_to_file_pretty(meta, path) != JSONSuccess)
|
||||||
die("failed to write process metadata\n");
|
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];
|
char thread[PATH_MAX];
|
||||||
if (snprintf(thread, PATH_MAX, "%s/%s", procdir,
|
if (snprintf(thread, PATH_MAX, "%s/%s", procdir,
|
||||||
dirent->d_name)
|
dirent->d_name)
|
||||||
>= PATH_MAX) {
|
>= PATH_MAX) {
|
||||||
err("snprintf: path too large: %s/%s\n", procdir,
|
err("snprintf: path too large: %s/%s\n", procdir,
|
||||||
dirent->d_name);
|
dirent->d_name);
|
||||||
err = 1;
|
err = 1;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
char thread_final[PATH_MAX];
|
char thread_final[PATH_MAX];
|
||||||
if (snprintf(thread_final, PATH_MAX, "%s/%s", procdir_final,
|
if (snprintf(thread_final, PATH_MAX, "%s/%s", procdir_final,
|
||||||
dirent->d_name)
|
dirent->d_name)
|
||||||
>= PATH_MAX) {
|
>= PATH_MAX) {
|
||||||
err("snprintf: path too large: %s/%s\n", procdir_final,
|
err("snprintf: path too large: %s/%s\n", procdir_final,
|
||||||
dirent->d_name);
|
dirent->d_name);
|
||||||
err = 1;
|
err = 1;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -370,7 +370,7 @@ static void
|
|||||||
write_stream_header(void)
|
write_stream_header(void)
|
||||||
{
|
{
|
||||||
struct ovni_stream_header *h =
|
struct ovni_stream_header *h =
|
||||||
(struct ovni_stream_header *) rthread.evbuf;
|
(struct ovni_stream_header *) rthread.evbuf;
|
||||||
|
|
||||||
memcpy(h->magic, OVNI_STREAM_MAGIC, 4);
|
memcpy(h->magic, OVNI_STREAM_MAGIC, 4);
|
||||||
h->version = OVNI_STREAM_VERSION;
|
h->version = OVNI_STREAM_VERSION;
|
||||||
|
@ -91,7 +91,7 @@ usage(void)
|
|||||||
fprintf(stderr, "%s: clock synchronization utility\n", progname);
|
fprintf(stderr, "%s: clock synchronization utility\n", progname);
|
||||||
fprintf(stderr, "\n");
|
fprintf(stderr, "\n");
|
||||||
fprintf(stderr, "Usage: %s [-o outfile] [-d ndrift_samples] [-v] [-n nsamples] [-w drift_delay]\n",
|
fprintf(stderr, "Usage: %s [-o outfile] [-d ndrift_samples] [-v] [-n nsamples] [-w drift_delay]\n",
|
||||||
progname);
|
progname);
|
||||||
exit(EXIT_FAILURE);
|
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];
|
delta[i] = ref->clock_sample[i] - cur->clock_sample[i];
|
||||||
if (verbose) {
|
if (verbose) {
|
||||||
printf("rank=%d sample=%d delta=%f ref=%f cur=%f\n",
|
printf("rank=%d sample=%d delta=%f ref=%f cur=%f\n",
|
||||||
cur->rank, i, delta[i],
|
cur->rank, i, delta[i],
|
||||||
ref->clock_sample[i],
|
ref->clock_sample[i],
|
||||||
cur->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 */
|
/* Then collect all the offsets into the rank 0 */
|
||||||
MPI_Gather(sendbuf, offset_size(nsamples), MPI_CHAR,
|
MPI_Gather(sendbuf, offset_size(nsamples), MPI_CHAR,
|
||||||
offset, offset_size(nsamples), MPI_CHAR,
|
offset, offset_size(nsamples), MPI_CHAR,
|
||||||
0, MPI_COMM_WORLD);
|
0, MPI_COMM_WORLD);
|
||||||
|
|
||||||
/* Finish the offsets by computing the deltas on rank 0 */
|
/* Finish the offsets by computing the deltas on rank 0 */
|
||||||
if (rank == 0) {
|
if (rank == 0) {
|
||||||
for (int i = 0; i < table->nprocs; i++) {
|
for (int i = 0; i < table->nprocs; i++) {
|
||||||
offset_compute_delta(offset, table->offset[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)
|
print_table_detailed(FILE *out, struct offset_table *table)
|
||||||
{
|
{
|
||||||
fprintf(out, "%-10s %-20s %-20s %-20s %-20s\n",
|
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++) {
|
for (int i = 0; i < table->nprocs; i++) {
|
||||||
struct offset *offset = table->offset[i];
|
struct offset *offset = table->offset[i];
|
||||||
fprintf(out, "%-10d %-20s %-20ld %-20f %-20f\n",
|
fprintf(out, "%-10d %-20s %-20ld %-20f %-20f\n",
|
||||||
i, offset->hostname, offset->offset,
|
i, offset->hostname, offset->offset,
|
||||||
offset->delta_mean, offset->delta_std);
|
offset->delta_mean, offset->delta_std);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -389,14 +389,14 @@ do_work(struct options *options, int rank)
|
|||||||
if (rank == 0) {
|
if (rank == 0) {
|
||||||
if (mkpath(options->outpath, 0755) != 0) {
|
if (mkpath(options->outpath, 0755) != 0) {
|
||||||
fprintf(stderr, "mkpath(%s) failed: %s\n",
|
fprintf(stderr, "mkpath(%s) failed: %s\n",
|
||||||
options->outpath, strerror(errno));
|
options->outpath, strerror(errno));
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
out = fopen(options->outpath, "w");
|
out = fopen(options->outpath, "w");
|
||||||
if (out == NULL) {
|
if (out == NULL) {
|
||||||
fprintf(stderr, "fopen(%s) failed: %s\n",
|
fprintf(stderr, "fopen(%s) failed: %s\n",
|
||||||
options->outpath, strerror(errno));
|
options->outpath, strerror(errno));
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -859,7 +859,7 @@ parse_object_value(const char **string, size_t nesting)
|
|||||||
}
|
}
|
||||||
SKIP_WHITESPACES(string);
|
SKIP_WHITESPACES(string);
|
||||||
if (**string != '}' || /* Trim object after parsing is over */
|
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);
|
json_value_free(output_value);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -907,7 +907,7 @@ parse_array_value(const char **string, size_t nesting)
|
|||||||
}
|
}
|
||||||
SKIP_WHITESPACES(string);
|
SKIP_WHITESPACES(string);
|
||||||
if (**string != ']' || /* Trim array after parsing is over */
|
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);
|
json_value_free(output_value);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -2470,7 +2470,7 @@ json_value_equals(const JSON_Value *a, const JSON_Value *b)
|
|||||||
}
|
}
|
||||||
for (i = 0; i < a_count; i++) {
|
for (i = 0; i < a_count; i++) {
|
||||||
if (!json_value_equals(json_array_get_value(a_array, 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;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2486,7 +2486,7 @@ json_value_equals(const JSON_Value *a, const JSON_Value *b)
|
|||||||
for (i = 0; i < a_count; i++) {
|
for (i = 0; i < a_count; i++) {
|
||||||
key = json_object_get_name(a_object, i);
|
key = json_object_get_name(a_object, i);
|
||||||
if (!json_value_equals(json_object_get_value(a_object, key),
|
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;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -378,7 +378,7 @@ create_type(struct pcf_file *pcf, enum chan c)
|
|||||||
|
|
||||||
char label[MAX_PCF_LABEL];
|
char label[MAX_PCF_LABEL];
|
||||||
int ret = snprintf(label, MAX_PCF_LABEL, "%s %s",
|
int ret = snprintf(label, MAX_PCF_LABEL, "%s %s",
|
||||||
prefix, suffix);
|
prefix, suffix);
|
||||||
|
|
||||||
if (ret >= MAX_PCF_LABEL)
|
if (ret >= MAX_PCF_LABEL)
|
||||||
die("computed type label too long\n");
|
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) {
|
if (pcf->f == NULL) {
|
||||||
die("cannot open PCF file '%s': %s\n",
|
die("cannot open PCF file '%s': %s\n",
|
||||||
path, strerror(errno));
|
path, strerror(errno));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Create default types and values */
|
/* Create default types and values */
|
||||||
|
@ -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_find_type(struct pcf_file *pcf, int type_id);
|
||||||
|
|
||||||
struct pcf_type *pcf_add_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,
|
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);
|
struct pcf_value *pcf_find_value(struct pcf_type *type, int value);
|
||||||
|
|
||||||
|
16
src/sort.c
16
src/sort.c
@ -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) {
|
for (ssize_t i = start; i != end; i = i - 1 < 0 ? r->size - 1 : i - 1) {
|
||||||
if (r->ev[i]->header.clock < clock) {
|
if (r->ev[i]->header.clock < clock) {
|
||||||
dbg("found suitable position %ld events backwards\n",
|
dbg("found suitable position %ld events backwards\n",
|
||||||
nback);
|
nback);
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
nback++;
|
nback++;
|
||||||
@ -121,7 +121,7 @@ ends_unsorted_region(struct ovni_ev *ev)
|
|||||||
|
|
||||||
static void
|
static void
|
||||||
sort_buf(uint8_t *src, uint8_t *buf, int64_t bufsize,
|
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;
|
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);
|
int64_t i0 = find_destination(sp->r, sp->bad0->header.clock);
|
||||||
if (i0 < 0) {
|
if (i0 < 0) {
|
||||||
err("cannot find destination for region starting at clock %ld\n",
|
err("cannot find destination for region starting at clock %ld\n",
|
||||||
sp->bad0->header.clock);
|
sp->bad0->header.clock);
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -209,7 +209,7 @@ execute_sort_plan(struct sortplan *sp)
|
|||||||
die("malloc failed: %s\n", strerror(errno));
|
die("malloc failed: %s\n", strerror(errno));
|
||||||
|
|
||||||
sort_buf((uint8_t *) first, buf, bufsize,
|
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 */
|
/* Copy the sorted events back into the stream buffer */
|
||||||
memcpy(first, buf, bufsize);
|
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);
|
dbg("executing sort plan for stream tid=%d\n", stream->tid);
|
||||||
if (execute_sort_plan(&sp) < 0) {
|
if (execute_sort_plan(&sp) < 0) {
|
||||||
err("sort failed for stream tid=%d\n",
|
err("sort failed for stream tid=%d\n",
|
||||||
stream->tid);
|
stream->tid);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -281,7 +281,7 @@ stream_winsort(struct ovni_stream *stream, struct ring *r)
|
|||||||
|
|
||||||
if (empty_regions > 0)
|
if (empty_regions > 0)
|
||||||
err("warning: stream %d contains %ld empty sort regions\n",
|
err("warning: stream %d contains %ld empty sort regions\n",
|
||||||
stream->tid, empty_regions);
|
stream->tid, empty_regions);
|
||||||
|
|
||||||
if (updated && fdatasync(fd) < 0)
|
if (updated && fdatasync(fd) < 0)
|
||||||
die("fdatasync %s failed: %s\n", fn, strerror(errno));
|
die("fdatasync %s failed: %s\n", fn, strerror(errno));
|
||||||
@ -308,7 +308,7 @@ stream_check(struct ovni_stream *stream)
|
|||||||
|
|
||||||
if (cur_clock < last_clock) {
|
if (cur_clock < last_clock) {
|
||||||
err("backwards jump in time %ld -> %ld for stream tid=%d\n",
|
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;
|
ret = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -372,7 +372,7 @@ usage(void)
|
|||||||
err("tracedir, so they are suitable for the emulator ovniemu.\n");
|
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("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",
|
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("events, so the sort procedure can fail with an error.\n");
|
||||||
err("\n");
|
err("\n");
|
||||||
err("Options:\n");
|
err("Options:\n");
|
||||||
|
38
src/trace.c
38
src/trace.c
@ -127,29 +127,29 @@ check_metadata_version(struct ovni_eproc *proc)
|
|||||||
JSON_Value *version_val = json_object_get_value(meta, "version");
|
JSON_Value *version_val = json_object_get_value(meta, "version");
|
||||||
if (version_val == NULL) {
|
if (version_val == NULL) {
|
||||||
die("process %d is missing attribute \"version\" in metadata\n",
|
die("process %d is missing attribute \"version\" in metadata\n",
|
||||||
proc->pid);
|
proc->pid);
|
||||||
}
|
}
|
||||||
|
|
||||||
int version = (int) json_number(version_val);
|
int version = (int) json_number(version_val);
|
||||||
|
|
||||||
if (version != OVNI_METADATA_VERSION) {
|
if (version != OVNI_METADATA_VERSION) {
|
||||||
die("pid %d: metadata version mismatch %d (expected %d)\n",
|
die("pid %d: metadata version mismatch %d (expected %d)\n",
|
||||||
proc->pid, version,
|
proc->pid, version,
|
||||||
OVNI_METADATA_VERSION);
|
OVNI_METADATA_VERSION);
|
||||||
}
|
}
|
||||||
|
|
||||||
JSON_Value *mversion_val = json_object_get_value(meta, "model_version");
|
JSON_Value *mversion_val = json_object_get_value(meta, "model_version");
|
||||||
if (mversion_val == NULL) {
|
if (mversion_val == NULL) {
|
||||||
die("process %d is missing attribute \"model_version\" in metadata\n",
|
die("process %d is missing attribute \"model_version\" in metadata\n",
|
||||||
proc->pid);
|
proc->pid);
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *mversion = json_string(mversion_val);
|
const char *mversion = json_string(mversion_val);
|
||||||
|
|
||||||
if (strcmp(mversion, OVNI_MODEL_VERSION) != 0) {
|
if (strcmp(mversion, OVNI_MODEL_VERSION) != 0) {
|
||||||
die("pid %d: metadata model version mismatch '%s' (expected '%s')\n",
|
die("pid %d: metadata model version mismatch '%s' (expected '%s')\n",
|
||||||
proc->pid, mversion,
|
proc->pid, mversion,
|
||||||
OVNI_MODEL_VERSION);
|
OVNI_MODEL_VERSION);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -197,7 +197,7 @@ load_proc(struct ovni_eproc *proc, struct ovni_loom *loom, int index, int pid, c
|
|||||||
DIR *dir;
|
DIR *dir;
|
||||||
if ((dir = opendir(procdir)) == NULL) {
|
if ((dir = opendir(procdir)) == NULL) {
|
||||||
fprintf(stderr, "opendir %s failed: %s\n",
|
fprintf(stderr, "opendir %s failed: %s\n",
|
||||||
procdir, strerror(errno));
|
procdir, strerror(errno));
|
||||||
return -1;
|
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) {
|
if (proc->nthreads <= 0) {
|
||||||
err("cannot find any thread for process %d\n",
|
err("cannot find any thread for process %d\n",
|
||||||
proc->pid);
|
proc->pid);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -270,7 +270,7 @@ load_loom(struct ovni_loom *loom, char *loomdir)
|
|||||||
|
|
||||||
if ((dir = opendir(loomdir)) == NULL) {
|
if ((dir = opendir(loomdir)) == NULL) {
|
||||||
fprintf(stderr, "opendir %s failed: %s\n",
|
fprintf(stderr, "opendir %s failed: %s\n",
|
||||||
loomdir, strerror(errno));
|
loomdir, strerror(errno));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -279,7 +279,7 @@ load_loom(struct ovni_loom *loom, char *loomdir)
|
|||||||
|
|
||||||
if (loom->nprocs <= 0) {
|
if (loom->nprocs <= 0) {
|
||||||
err("cannot find any process directory in loom %s\n",
|
err("cannot find any process directory in loom %s\n",
|
||||||
loom->hostname);
|
loom->hostname);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -326,7 +326,7 @@ load_loom(struct ovni_loom *loom, char *loomdir)
|
|||||||
struct ovni_eproc *proc = &loom->proc[i];
|
struct ovni_eproc *proc = &loom->proc[i];
|
||||||
if (proc->rank < 0) {
|
if (proc->rank < 0) {
|
||||||
die("process %d is missing the rank\n",
|
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 */
|
/* Sort the looms, so we get the hostnames in alphanumeric order */
|
||||||
qsort(trace->loom, trace->nlooms, sizeof(struct ovni_loom),
|
qsort(trace->loom, trace->nlooms, sizeof(struct ovni_loom),
|
||||||
compare_looms);
|
compare_looms);
|
||||||
|
|
||||||
for (size_t i = 0; i < trace->nlooms; i++) {
|
for (size_t i = 0; i < trace->nlooms; i++) {
|
||||||
struct ovni_loom *loom = &trace->loom[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));
|
loom_to_host(name, loom->hostname, sizeof(loom->hostname));
|
||||||
|
|
||||||
if (snprintf(loom->path, PATH_MAX, "%s/%s",
|
if (snprintf(loom->path, PATH_MAX, "%s/%s",
|
||||||
tracedir, loom->dname)
|
tracedir, loom->dname)
|
||||||
>= PATH_MAX) {
|
>= PATH_MAX) {
|
||||||
err("error: loom path %s/%s too long\n",
|
err("error: loom path %s/%s too long\n",
|
||||||
tracedir, loom->dname);
|
tracedir, loom->dname);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -450,25 +450,25 @@ check_stream_header(struct ovni_stream *stream)
|
|||||||
|
|
||||||
if (stream->size < sizeof(struct ovni_stream_header)) {
|
if (stream->size < sizeof(struct ovni_stream_header)) {
|
||||||
err("stream %d: incomplete stream header\n",
|
err("stream %d: incomplete stream header\n",
|
||||||
stream->tid);
|
stream->tid);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct ovni_stream_header *h =
|
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) {
|
if (memcmp(h->magic, OVNI_STREAM_MAGIC, 4) != 0) {
|
||||||
char magic[5];
|
char magic[5];
|
||||||
memcpy(magic, h->magic, 4);
|
memcpy(magic, h->magic, 4);
|
||||||
magic[4] = '\0';
|
magic[4] = '\0';
|
||||||
err("stream %d: wrong stream magic '%s' (expected '%s')\n",
|
err("stream %d: wrong stream magic '%s' (expected '%s')\n",
|
||||||
stream->tid, magic, OVNI_STREAM_MAGIC);
|
stream->tid, magic, OVNI_STREAM_MAGIC);
|
||||||
ret = -1;
|
ret = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (h->version != OVNI_STREAM_VERSION) {
|
if (h->version != OVNI_STREAM_VERSION) {
|
||||||
err("stream %d: stream version mismatch %u (expected %u)\n",
|
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;
|
ret = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
334
src/uthash.h
334
src/uthash.h
@ -222,35 +222,35 @@ typedef unsigned char uint8_t;
|
|||||||
#define HASH_BLOOM_BYTELEN 0U
|
#define HASH_BLOOM_BYTELEN 0U
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define HASH_MAKE_TABLE(hh, head, oomed) \
|
#define HASH_MAKE_TABLE(hh, head, oomed) \
|
||||||
do { \
|
do { \
|
||||||
(head)->hh.tbl = (UT_hash_table *) uthash_malloc(sizeof(UT_hash_table)); \
|
(head)->hh.tbl = (UT_hash_table *) uthash_malloc(sizeof(UT_hash_table)); \
|
||||||
if (!(head)->hh.tbl) { \
|
if (!(head)->hh.tbl) { \
|
||||||
HASH_RECORD_OOM(oomed); \
|
HASH_RECORD_OOM(oomed); \
|
||||||
} else { \
|
} else { \
|
||||||
uthash_bzero((head)->hh.tbl, sizeof(UT_hash_table)); \
|
uthash_bzero((head)->hh.tbl, sizeof(UT_hash_table)); \
|
||||||
(head)->hh.tbl->tail = &((head)->hh); \
|
(head)->hh.tbl->tail = &((head)->hh); \
|
||||||
(head)->hh.tbl->num_buckets = HASH_INITIAL_NUM_BUCKETS; \
|
(head)->hh.tbl->num_buckets = HASH_INITIAL_NUM_BUCKETS; \
|
||||||
(head)->hh.tbl->log2_num_buckets = HASH_INITIAL_NUM_BUCKETS_LOG2; \
|
(head)->hh.tbl->log2_num_buckets = HASH_INITIAL_NUM_BUCKETS_LOG2; \
|
||||||
(head)->hh.tbl->hho = (char *) (&(head)->hh) - (char *) (head); \
|
(head)->hh.tbl->hho = (char *) (&(head)->hh) - (char *) (head); \
|
||||||
(head)->hh.tbl->buckets = (UT_hash_bucket *) uthash_malloc( \
|
(head)->hh.tbl->buckets = (UT_hash_bucket *) uthash_malloc( \
|
||||||
HASH_INITIAL_NUM_BUCKETS * sizeof(struct UT_hash_bucket)); \
|
HASH_INITIAL_NUM_BUCKETS * sizeof(struct UT_hash_bucket)); \
|
||||||
(head)->hh.tbl->signature = HASH_SIGNATURE; \
|
(head)->hh.tbl->signature = HASH_SIGNATURE; \
|
||||||
if (!(head)->hh.tbl->buckets) { \
|
if (!(head)->hh.tbl->buckets) { \
|
||||||
HASH_RECORD_OOM(oomed); \
|
HASH_RECORD_OOM(oomed); \
|
||||||
uthash_free((head)->hh.tbl, sizeof(UT_hash_table)); \
|
uthash_free((head)->hh.tbl, sizeof(UT_hash_table)); \
|
||||||
} else { \
|
} else { \
|
||||||
uthash_bzero((head)->hh.tbl->buckets, \
|
uthash_bzero((head)->hh.tbl->buckets, \
|
||||||
HASH_INITIAL_NUM_BUCKETS * sizeof(struct UT_hash_bucket)); \
|
HASH_INITIAL_NUM_BUCKETS * sizeof(struct UT_hash_bucket)); \
|
||||||
HASH_BLOOM_MAKE((head)->hh.tbl, oomed); \
|
HASH_BLOOM_MAKE((head)->hh.tbl, oomed); \
|
||||||
IF_HASH_NONFATAL_OOM( \
|
IF_HASH_NONFATAL_OOM( \
|
||||||
if (oomed) { \
|
if (oomed) { \
|
||||||
uthash_free((head)->hh.tbl->buckets, \
|
uthash_free((head)->hh.tbl->buckets, \
|
||||||
HASH_INITIAL_NUM_BUCKETS * sizeof(struct UT_hash_bucket)); \
|
HASH_INITIAL_NUM_BUCKETS * sizeof(struct UT_hash_bucket)); \
|
||||||
uthash_free((head)->hh.tbl, sizeof(UT_hash_table)); \
|
uthash_free((head)->hh.tbl, sizeof(UT_hash_table)); \
|
||||||
}) \
|
}) \
|
||||||
} \
|
} \
|
||||||
} \
|
} \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
#define HASH_REPLACE_BYHASHVALUE_INORDER(hh, head, fieldname, keylen_in, hashval, add, replaced, cmpfcn) \
|
#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)) { \
|
if ((_hd_hh_del->prev == NULL) && (_hd_hh_del->next == NULL)) { \
|
||||||
HASH_BLOOM_FREE((head)->hh.tbl); \
|
HASH_BLOOM_FREE((head)->hh.tbl); \
|
||||||
uthash_free((head)->hh.tbl->buckets, \
|
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)); \
|
uthash_free((head)->hh.tbl, sizeof(UT_hash_table)); \
|
||||||
(head) = NULL; \
|
(head) = NULL; \
|
||||||
} else { \
|
} else { \
|
||||||
@ -528,53 +528,53 @@ typedef unsigned char uint8_t;
|
|||||||
fprintf(stderr, __VA_ARGS__); \
|
fprintf(stderr, __VA_ARGS__); \
|
||||||
exit(-1); \
|
exit(-1); \
|
||||||
} while (0)
|
} while (0)
|
||||||
#define HASH_FSCK(hh, head, where) \
|
#define HASH_FSCK(hh, head, where) \
|
||||||
do { \
|
do { \
|
||||||
struct UT_hash_handle *_thh; \
|
struct UT_hash_handle *_thh; \
|
||||||
if (head) { \
|
if (head) { \
|
||||||
unsigned _bkt_i; \
|
unsigned _bkt_i; \
|
||||||
unsigned _count = 0; \
|
unsigned _count = 0; \
|
||||||
char *_prev; \
|
char *_prev; \
|
||||||
for (_bkt_i = 0; _bkt_i < (head)->hh.tbl->num_buckets; ++_bkt_i) { \
|
for (_bkt_i = 0; _bkt_i < (head)->hh.tbl->num_buckets; ++_bkt_i) { \
|
||||||
unsigned _bkt_count = 0; \
|
unsigned _bkt_count = 0; \
|
||||||
_thh = (head)->hh.tbl->buckets[_bkt_i].hh_head; \
|
_thh = (head)->hh.tbl->buckets[_bkt_i].hh_head; \
|
||||||
_prev = NULL; \
|
_prev = NULL; \
|
||||||
while (_thh) { \
|
while (_thh) { \
|
||||||
if (_prev != (char *) (_thh->hh_prev)) { \
|
if (_prev != (char *) (_thh->hh_prev)) { \
|
||||||
HASH_OOPS("%s: invalid hh_prev %p, actual %p\n", \
|
HASH_OOPS("%s: invalid hh_prev %p, actual %p\n", \
|
||||||
(where), (void *) _thh->hh_prev, (void *) _prev); \
|
(where), (void *) _thh->hh_prev, (void *) _prev); \
|
||||||
} \
|
} \
|
||||||
_bkt_count++; \
|
_bkt_count++; \
|
||||||
_prev = (char *) (_thh); \
|
_prev = (char *) (_thh); \
|
||||||
_thh = _thh->hh_next; \
|
_thh = _thh->hh_next; \
|
||||||
} \
|
} \
|
||||||
_count += _bkt_count; \
|
_count += _bkt_count; \
|
||||||
if ((head)->hh.tbl->buckets[_bkt_i].count != _bkt_count) { \
|
if ((head)->hh.tbl->buckets[_bkt_i].count != _bkt_count) { \
|
||||||
HASH_OOPS("%s: invalid bucket count %u, actual %u\n", \
|
HASH_OOPS("%s: invalid bucket count %u, actual %u\n", \
|
||||||
(where), (head)->hh.tbl->buckets[_bkt_i].count, _bkt_count); \
|
(where), (head)->hh.tbl->buckets[_bkt_i].count, _bkt_count); \
|
||||||
} \
|
} \
|
||||||
} \
|
} \
|
||||||
if (_count != (head)->hh.tbl->num_items) { \
|
if (_count != (head)->hh.tbl->num_items) { \
|
||||||
HASH_OOPS("%s: invalid hh item count %u, actual %u\n", \
|
HASH_OOPS("%s: invalid hh item count %u, actual %u\n", \
|
||||||
(where), (head)->hh.tbl->num_items, _count); \
|
(where), (head)->hh.tbl->num_items, _count); \
|
||||||
} \
|
} \
|
||||||
_count = 0; \
|
_count = 0; \
|
||||||
_prev = NULL; \
|
_prev = NULL; \
|
||||||
_thh = &(head)->hh; \
|
_thh = &(head)->hh; \
|
||||||
while (_thh) { \
|
while (_thh) { \
|
||||||
_count++; \
|
_count++; \
|
||||||
if (_prev != (char *) _thh->prev) { \
|
if (_prev != (char *) _thh->prev) { \
|
||||||
HASH_OOPS("%s: invalid prev %p, actual %p\n", \
|
HASH_OOPS("%s: invalid prev %p, actual %p\n", \
|
||||||
(where), (void *) _thh->prev, (void *) _prev); \
|
(where), (void *) _thh->prev, (void *) _prev); \
|
||||||
} \
|
} \
|
||||||
_prev = (char *) ELMT_FROM_HH((head)->hh.tbl, _thh); \
|
_prev = (char *) ELMT_FROM_HH((head)->hh.tbl, _thh); \
|
||||||
_thh = (_thh->next ? HH_FROM_ELMT((head)->hh.tbl, _thh->next) : NULL); \
|
_thh = (_thh->next ? HH_FROM_ELMT((head)->hh.tbl, _thh->next) : NULL); \
|
||||||
} \
|
} \
|
||||||
if (_count != (head)->hh.tbl->num_items) { \
|
if (_count != (head)->hh.tbl->num_items) { \
|
||||||
HASH_OOPS("%s: invalid app item count %u, actual %u\n", \
|
HASH_OOPS("%s: invalid app item count %u, actual %u\n", \
|
||||||
(where), (head)->hh.tbl->num_items, _count); \
|
(where), (head)->hh.tbl->num_items, _count); \
|
||||||
} \
|
} \
|
||||||
} \
|
} \
|
||||||
} while (0)
|
} while (0)
|
||||||
#else
|
#else
|
||||||
#define HASH_FSCK(hh, head, where)
|
#define HASH_FSCK(hh, head, where)
|
||||||
@ -691,14 +691,14 @@ typedef unsigned char uint8_t;
|
|||||||
_hj_k = (unsigned) (keylen); \
|
_hj_k = (unsigned) (keylen); \
|
||||||
while (_hj_k >= 12U) { \
|
while (_hj_k >= 12U) { \
|
||||||
_hj_i += (_hj_key[0] + ((unsigned) _hj_key[1] << 8) \
|
_hj_i += (_hj_key[0] + ((unsigned) _hj_key[1] << 8) \
|
||||||
+ ((unsigned) _hj_key[2] << 16) \
|
+ ((unsigned) _hj_key[2] << 16) \
|
||||||
+ ((unsigned) _hj_key[3] << 24)); \
|
+ ((unsigned) _hj_key[3] << 24)); \
|
||||||
_hj_j += (_hj_key[4] + ((unsigned) _hj_key[5] << 8) \
|
_hj_j += (_hj_key[4] + ((unsigned) _hj_key[5] << 8) \
|
||||||
+ ((unsigned) _hj_key[6] << 16) \
|
+ ((unsigned) _hj_key[6] << 16) \
|
||||||
+ ((unsigned) _hj_key[7] << 24)); \
|
+ ((unsigned) _hj_key[7] << 24)); \
|
||||||
hashv += (_hj_key[8] + ((unsigned) _hj_key[9] << 8) \
|
hashv += (_hj_key[8] + ((unsigned) _hj_key[9] << 8) \
|
||||||
+ ((unsigned) _hj_key[10] << 16) \
|
+ ((unsigned) _hj_key[10] << 16) \
|
||||||
+ ((unsigned) _hj_key[11] << 24)); \
|
+ ((unsigned) _hj_key[11] << 24)); \
|
||||||
\
|
\
|
||||||
HASH_JEN_MIX(_hj_i, _hj_j, hashv); \
|
HASH_JEN_MIX(_hj_i, _hj_j, hashv); \
|
||||||
\
|
\
|
||||||
@ -736,7 +736,7 @@ typedef unsigned char uint8_t;
|
|||||||
/* The Paul Hsieh hash function */
|
/* The Paul Hsieh hash function */
|
||||||
#undef get16bits
|
#undef get16bits
|
||||||
#if (defined(__GNUC__) && defined(__i386__)) || defined(__WATCOMC__) \
|
#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)))
|
#define get16bits(d) (*((const uint16_t *) (d)))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -906,12 +906,12 @@ typedef unsigned char uint8_t;
|
|||||||
} \
|
} \
|
||||||
_ha_head->hh_head = (addhh); \
|
_ha_head->hh_head = (addhh); \
|
||||||
if ((_ha_head->count >= ((_ha_head->expand_mult + 1U) * HASH_BKT_CAPACITY_THRESH)) \
|
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); \
|
HASH_EXPAND_BUCKETS(addhh, (addhh)->tbl, oomed); \
|
||||||
IF_HASH_NONFATAL_OOM( \
|
IF_HASH_NONFATAL_OOM( \
|
||||||
if (oomed) { \
|
if (oomed) { \
|
||||||
HASH_DEL_IN_BKT(head, addhh); \
|
HASH_DEL_IN_BKT(head, addhh); \
|
||||||
}) \
|
}) \
|
||||||
} \
|
} \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
@ -960,54 +960,54 @@ typedef unsigned char uint8_t;
|
|||||||
* ceil(n/b) = (n>>lb) + ( (n & (b-1)) ? 1:0)
|
* ceil(n/b) = (n>>lb) + ( (n & (b-1)) ? 1:0)
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
#define HASH_EXPAND_BUCKETS(hh, tbl, oomed) \
|
#define HASH_EXPAND_BUCKETS(hh, tbl, oomed) \
|
||||||
do { \
|
do { \
|
||||||
unsigned _he_bkt; \
|
unsigned _he_bkt; \
|
||||||
unsigned _he_bkt_i; \
|
unsigned _he_bkt_i; \
|
||||||
struct UT_hash_handle *_he_thh, *_he_hh_nxt; \
|
struct UT_hash_handle *_he_thh, *_he_hh_nxt; \
|
||||||
UT_hash_bucket *_he_new_buckets, *_he_newbkt; \
|
UT_hash_bucket *_he_new_buckets, *_he_newbkt; \
|
||||||
_he_new_buckets = (UT_hash_bucket *) uthash_malloc( \
|
_he_new_buckets = (UT_hash_bucket *) uthash_malloc( \
|
||||||
2UL * (tbl)->num_buckets * sizeof(struct UT_hash_bucket)); \
|
2UL * (tbl)->num_buckets * sizeof(struct UT_hash_bucket)); \
|
||||||
if (!_he_new_buckets) { \
|
if (!_he_new_buckets) { \
|
||||||
HASH_RECORD_OOM(oomed); \
|
HASH_RECORD_OOM(oomed); \
|
||||||
} else { \
|
} else { \
|
||||||
uthash_bzero(_he_new_buckets, \
|
uthash_bzero(_he_new_buckets, \
|
||||||
2UL * (tbl)->num_buckets * sizeof(struct UT_hash_bucket)); \
|
2UL * (tbl)->num_buckets * sizeof(struct UT_hash_bucket)); \
|
||||||
(tbl)->ideal_chain_maxlen = \
|
(tbl)->ideal_chain_maxlen = \
|
||||||
((tbl)->num_items >> ((tbl)->log2_num_buckets + 1U)) + ((((tbl)->num_items & (((tbl)->num_buckets * 2U) - 1U)) != 0U) ? 1U : 0U); \
|
((tbl)->num_items >> ((tbl)->log2_num_buckets + 1U)) + ((((tbl)->num_items & (((tbl)->num_buckets * 2U) - 1U)) != 0U) ? 1U : 0U); \
|
||||||
(tbl)->nonideal_items = 0; \
|
(tbl)->nonideal_items = 0; \
|
||||||
for (_he_bkt_i = 0; _he_bkt_i < (tbl)->num_buckets; _he_bkt_i++) { \
|
for (_he_bkt_i = 0; _he_bkt_i < (tbl)->num_buckets; _he_bkt_i++) { \
|
||||||
_he_thh = (tbl)->buckets[_he_bkt_i].hh_head; \
|
_he_thh = (tbl)->buckets[_he_bkt_i].hh_head; \
|
||||||
while (_he_thh != NULL) { \
|
while (_he_thh != NULL) { \
|
||||||
_he_hh_nxt = _he_thh->hh_next; \
|
_he_hh_nxt = _he_thh->hh_next; \
|
||||||
HASH_TO_BKT(_he_thh->hashv, (tbl)->num_buckets * 2U, _he_bkt); \
|
HASH_TO_BKT(_he_thh->hashv, (tbl)->num_buckets * 2U, _he_bkt); \
|
||||||
_he_newbkt = &(_he_new_buckets[_he_bkt]); \
|
_he_newbkt = &(_he_new_buckets[_he_bkt]); \
|
||||||
if (++(_he_newbkt->count) > (tbl)->ideal_chain_maxlen) { \
|
if (++(_he_newbkt->count) > (tbl)->ideal_chain_maxlen) { \
|
||||||
(tbl)->nonideal_items++; \
|
(tbl)->nonideal_items++; \
|
||||||
if (_he_newbkt->count > _he_newbkt->expand_mult * (tbl)->ideal_chain_maxlen) { \
|
if (_he_newbkt->count > _he_newbkt->expand_mult * (tbl)->ideal_chain_maxlen) { \
|
||||||
_he_newbkt->expand_mult++; \
|
_he_newbkt->expand_mult++; \
|
||||||
} \
|
} \
|
||||||
} \
|
} \
|
||||||
_he_thh->hh_prev = NULL; \
|
_he_thh->hh_prev = NULL; \
|
||||||
_he_thh->hh_next = _he_newbkt->hh_head; \
|
_he_thh->hh_next = _he_newbkt->hh_head; \
|
||||||
if (_he_newbkt->hh_head != NULL) { \
|
if (_he_newbkt->hh_head != NULL) { \
|
||||||
_he_newbkt->hh_head->hh_prev = _he_thh; \
|
_he_newbkt->hh_head->hh_prev = _he_thh; \
|
||||||
} \
|
} \
|
||||||
_he_newbkt->hh_head = _he_thh; \
|
_he_newbkt->hh_head = _he_thh; \
|
||||||
_he_thh = _he_hh_nxt; \
|
_he_thh = _he_hh_nxt; \
|
||||||
} \
|
} \
|
||||||
} \
|
} \
|
||||||
uthash_free((tbl)->buckets, (tbl)->num_buckets * sizeof(struct UT_hash_bucket)); \
|
uthash_free((tbl)->buckets, (tbl)->num_buckets * sizeof(struct UT_hash_bucket)); \
|
||||||
(tbl)->num_buckets *= 2U; \
|
(tbl)->num_buckets *= 2U; \
|
||||||
(tbl)->log2_num_buckets++; \
|
(tbl)->log2_num_buckets++; \
|
||||||
(tbl)->buckets = _he_new_buckets; \
|
(tbl)->buckets = _he_new_buckets; \
|
||||||
(tbl)->ineff_expands = ((tbl)->nonideal_items > ((tbl)->num_items >> 1)) ? ((tbl)->ineff_expands + 1U) : 0U; \
|
(tbl)->ineff_expands = ((tbl)->nonideal_items > ((tbl)->num_items >> 1)) ? ((tbl)->ineff_expands + 1U) : 0U; \
|
||||||
if ((tbl)->ineff_expands > 1U) { \
|
if ((tbl)->ineff_expands > 1U) { \
|
||||||
(tbl)->noexpand = 1; \
|
(tbl)->noexpand = 1; \
|
||||||
uthash_noexpand_fyi(tbl); \
|
uthash_noexpand_fyi(tbl); \
|
||||||
} \
|
} \
|
||||||
uthash_expand_fyi(tbl); \
|
uthash_expand_fyi(tbl); \
|
||||||
} \
|
} \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
|
|
||||||
@ -1053,9 +1053,9 @@ typedef unsigned char uint8_t;
|
|||||||
} \
|
} \
|
||||||
_hs_psize--; \
|
_hs_psize--; \
|
||||||
} else if ((cmpfcn( \
|
} else if ((cmpfcn( \
|
||||||
DECLTYPE(head)(ELMT_FROM_HH((head)->hh.tbl, _hs_p)), \
|
DECLTYPE(head)(ELMT_FROM_HH((head)->hh.tbl, _hs_p)), \
|
||||||
DECLTYPE(head)(ELMT_FROM_HH((head)->hh.tbl, _hs_q)))) \
|
DECLTYPE(head)(ELMT_FROM_HH((head)->hh.tbl, _hs_q)))) \
|
||||||
<= 0) { \
|
<= 0) { \
|
||||||
_hs_e = _hs_p; \
|
_hs_e = _hs_p; \
|
||||||
if (_hs_p != NULL) { \
|
if (_hs_p != NULL) { \
|
||||||
_hs_p = ((_hs_p->next != NULL) ? HH_FROM_ELMT((head)->hh.tbl, _hs_p->next) : 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) { \
|
if ((src) != NULL) { \
|
||||||
for (_src_bkt = 0; _src_bkt < (src)->hh_src.tbl->num_buckets; _src_bkt++) { \
|
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; \
|
for (_src_hh = (src)->hh_src.tbl->buckets[_src_bkt].hh_head; \
|
||||||
_src_hh != NULL; \
|
_src_hh != NULL; \
|
||||||
_src_hh = _src_hh->hh_next) { \
|
_src_hh = _src_hh->hh_next) { \
|
||||||
_elt = ELMT_FROM_HH((src)->hh_src.tbl, _src_hh); \
|
_elt = ELMT_FROM_HH((src)->hh_src.tbl, _src_hh); \
|
||||||
if (cond(_elt)) { \
|
if (cond(_elt)) { \
|
||||||
IF_HASH_NONFATAL_OOM(int _hs_oomed = 0;) \
|
IF_HASH_NONFATAL_OOM(int _hs_oomed = 0;) \
|
||||||
@ -1124,11 +1124,11 @@ typedef unsigned char uint8_t;
|
|||||||
DECLTYPE_ASSIGN(dst, _elt); \
|
DECLTYPE_ASSIGN(dst, _elt); \
|
||||||
HASH_MAKE_TABLE(hh_dst, dst, _hs_oomed); \
|
HASH_MAKE_TABLE(hh_dst, dst, _hs_oomed); \
|
||||||
IF_HASH_NONFATAL_OOM( \
|
IF_HASH_NONFATAL_OOM( \
|
||||||
if (_hs_oomed) { \
|
if (_hs_oomed) { \
|
||||||
uthash_nonfatal_oom(_elt); \
|
uthash_nonfatal_oom(_elt); \
|
||||||
(dst) = NULL; \
|
(dst) = NULL; \
|
||||||
continue; \
|
continue; \
|
||||||
}) \
|
}) \
|
||||||
} else { \
|
} else { \
|
||||||
_dst_hh->tbl = (dst)->hh_dst.tbl; \
|
_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); \
|
HASH_ADD_TO_BKT(_dst_hh->tbl->buckets[_dst_bkt], hh_dst, _dst_hh, _hs_oomed); \
|
||||||
(dst)->hh_dst.tbl->num_items++; \
|
(dst)->hh_dst.tbl->num_items++; \
|
||||||
IF_HASH_NONFATAL_OOM( \
|
IF_HASH_NONFATAL_OOM( \
|
||||||
if (_hs_oomed) { \
|
if (_hs_oomed) { \
|
||||||
HASH_ROLLBACK_BKT(hh_dst, dst, _dst_hh); \
|
HASH_ROLLBACK_BKT(hh_dst, dst, _dst_hh); \
|
||||||
HASH_DELETE_HH(hh_dst, dst, _dst_hh); \
|
HASH_DELETE_HH(hh_dst, dst, _dst_hh); \
|
||||||
_dst_hh->tbl = NULL; \
|
_dst_hh->tbl = NULL; \
|
||||||
uthash_nonfatal_oom(_elt); \
|
uthash_nonfatal_oom(_elt); \
|
||||||
continue; \
|
continue; \
|
||||||
}) \
|
}) \
|
||||||
HASH_BLOOM_ADD(_dst_hh->tbl, _dst_hh->hashv); \
|
HASH_BLOOM_ADD(_dst_hh->tbl, _dst_hh->hashv); \
|
||||||
_last_elt = _elt; \
|
_last_elt = _elt; \
|
||||||
_last_elt_hh = _dst_hh; \
|
_last_elt_hh = _dst_hh; \
|
||||||
@ -1153,30 +1153,30 @@ typedef unsigned char uint8_t;
|
|||||||
HASH_FSCK(hh_dst, dst, "HASH_SELECT"); \
|
HASH_FSCK(hh_dst, dst, "HASH_SELECT"); \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
#define HASH_CLEAR(hh, head) \
|
#define HASH_CLEAR(hh, head) \
|
||||||
do { \
|
do { \
|
||||||
if ((head) != NULL) { \
|
if ((head) != NULL) { \
|
||||||
HASH_BLOOM_FREE((head)->hh.tbl); \
|
HASH_BLOOM_FREE((head)->hh.tbl); \
|
||||||
uthash_free((head)->hh.tbl->buckets, \
|
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)); \
|
uthash_free((head)->hh.tbl, sizeof(UT_hash_table)); \
|
||||||
(head) = NULL; \
|
(head) = NULL; \
|
||||||
} \
|
} \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
#define HASH_OVERHEAD(hh, head) \
|
#define HASH_OVERHEAD(hh, head) \
|
||||||
(((head) != NULL) ? ( \
|
(((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))) \
|
(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)
|
: 0U)
|
||||||
|
|
||||||
#ifdef NO_DECLTYPE
|
#ifdef NO_DECLTYPE
|
||||||
#define HASH_ITER(hh, head, el, tmp) \
|
#define HASH_ITER(hh, head, el, tmp) \
|
||||||
for (((el) = (head)), ((*(char **) (&(tmp))) = (char *) ((head != NULL) ? (head)->hh.next : NULL)); \
|
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
|
#else
|
||||||
#define HASH_ITER(hh, head, el, tmp) \
|
#define HASH_ITER(hh, head, el, tmp) \
|
||||||
for (((el) = (head)), ((tmp) = DECLTYPE(el)((head != NULL) ? (head)->hh.next : NULL)); \
|
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
|
#endif
|
||||||
|
|
||||||
/* obtain a count of items in the hash */
|
/* obtain a count of items in the hash */
|
||||||
|
564
src/utlist.h
564
src/utlist.h
@ -127,297 +127,297 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||||||
#define LL_SORT(list, cmp) \
|
#define LL_SORT(list, cmp) \
|
||||||
LL_SORT2(list, cmp, next)
|
LL_SORT2(list, cmp, next)
|
||||||
|
|
||||||
#define LL_SORT2(list, cmp, next) \
|
#define LL_SORT2(list, cmp, next) \
|
||||||
do { \
|
do { \
|
||||||
LDECLTYPE(list) \
|
LDECLTYPE(list) \
|
||||||
_ls_p; \
|
_ls_p; \
|
||||||
LDECLTYPE(list) \
|
LDECLTYPE(list) \
|
||||||
_ls_q; \
|
_ls_q; \
|
||||||
LDECLTYPE(list) \
|
LDECLTYPE(list) \
|
||||||
_ls_e; \
|
_ls_e; \
|
||||||
LDECLTYPE(list) \
|
LDECLTYPE(list) \
|
||||||
_ls_tail; \
|
_ls_tail; \
|
||||||
IF_NO_DECLTYPE(LDECLTYPE(list) _tmp;) \
|
IF_NO_DECLTYPE(LDECLTYPE(list) _tmp;) \
|
||||||
int _ls_insize, _ls_nmerges, _ls_psize, _ls_qsize, _ls_i, _ls_looping; \
|
int _ls_insize, _ls_nmerges, _ls_psize, _ls_qsize, _ls_i, _ls_looping; \
|
||||||
if (list) { \
|
if (list) { \
|
||||||
_ls_insize = 1; \
|
_ls_insize = 1; \
|
||||||
_ls_looping = 1; \
|
_ls_looping = 1; \
|
||||||
while (_ls_looping) { \
|
while (_ls_looping) { \
|
||||||
UTLIST_CASTASGN(_ls_p, list); \
|
UTLIST_CASTASGN(_ls_p, list); \
|
||||||
(list) = NULL; \
|
(list) = NULL; \
|
||||||
_ls_tail = NULL; \
|
_ls_tail = NULL; \
|
||||||
_ls_nmerges = 0; \
|
_ls_nmerges = 0; \
|
||||||
while (_ls_p) { \
|
while (_ls_p) { \
|
||||||
_ls_nmerges++; \
|
_ls_nmerges++; \
|
||||||
_ls_q = _ls_p; \
|
_ls_q = _ls_p; \
|
||||||
_ls_psize = 0; \
|
_ls_psize = 0; \
|
||||||
for (_ls_i = 0; _ls_i < _ls_insize; _ls_i++) { \
|
for (_ls_i = 0; _ls_i < _ls_insize; _ls_i++) { \
|
||||||
_ls_psize++; \
|
_ls_psize++; \
|
||||||
UTLIST_SV(_ls_q, list); \
|
UTLIST_SV(_ls_q, list); \
|
||||||
_ls_q = UTLIST_NEXT(_ls_q, list, next); \
|
_ls_q = UTLIST_NEXT(_ls_q, list, next); \
|
||||||
UTLIST_RS(list); \
|
UTLIST_RS(list); \
|
||||||
if (!_ls_q) \
|
if (!_ls_q) \
|
||||||
break; \
|
break; \
|
||||||
} \
|
} \
|
||||||
_ls_qsize = _ls_insize; \
|
_ls_qsize = _ls_insize; \
|
||||||
while (_ls_psize > 0 || (_ls_qsize > 0 && _ls_q)) { \
|
while (_ls_psize > 0 || (_ls_qsize > 0 && _ls_q)) { \
|
||||||
if (_ls_psize == 0) { \
|
if (_ls_psize == 0) { \
|
||||||
_ls_e = _ls_q; \
|
_ls_e = _ls_q; \
|
||||||
UTLIST_SV(_ls_q, list); \
|
UTLIST_SV(_ls_q, list); \
|
||||||
_ls_q = \
|
_ls_q = \
|
||||||
UTLIST_NEXT(_ls_q, list, next); \
|
UTLIST_NEXT(_ls_q, list, next); \
|
||||||
UTLIST_RS(list); \
|
UTLIST_RS(list); \
|
||||||
_ls_qsize--; \
|
_ls_qsize--; \
|
||||||
} else if (_ls_qsize == 0 || !_ls_q) { \
|
} else if (_ls_qsize == 0 || !_ls_q) { \
|
||||||
_ls_e = _ls_p; \
|
_ls_e = _ls_p; \
|
||||||
UTLIST_SV(_ls_p, list); \
|
UTLIST_SV(_ls_p, list); \
|
||||||
_ls_p = \
|
_ls_p = \
|
||||||
UTLIST_NEXT(_ls_p, list, next); \
|
UTLIST_NEXT(_ls_p, list, next); \
|
||||||
UTLIST_RS(list); \
|
UTLIST_RS(list); \
|
||||||
_ls_psize--; \
|
_ls_psize--; \
|
||||||
} else if (cmp(_ls_p, _ls_q) <= 0) { \
|
} else if (cmp(_ls_p, _ls_q) <= 0) { \
|
||||||
_ls_e = _ls_p; \
|
_ls_e = _ls_p; \
|
||||||
UTLIST_SV(_ls_p, list); \
|
UTLIST_SV(_ls_p, list); \
|
||||||
_ls_p = \
|
_ls_p = \
|
||||||
UTLIST_NEXT(_ls_p, list, next); \
|
UTLIST_NEXT(_ls_p, list, next); \
|
||||||
UTLIST_RS(list); \
|
UTLIST_RS(list); \
|
||||||
_ls_psize--; \
|
_ls_psize--; \
|
||||||
} else { \
|
} else { \
|
||||||
_ls_e = _ls_q; \
|
_ls_e = _ls_q; \
|
||||||
UTLIST_SV(_ls_q, list); \
|
UTLIST_SV(_ls_q, list); \
|
||||||
_ls_q = \
|
_ls_q = \
|
||||||
UTLIST_NEXT(_ls_q, list, next); \
|
UTLIST_NEXT(_ls_q, list, next); \
|
||||||
UTLIST_RS(list); \
|
UTLIST_RS(list); \
|
||||||
_ls_qsize--; \
|
_ls_qsize--; \
|
||||||
} \
|
} \
|
||||||
if (_ls_tail) { \
|
if (_ls_tail) { \
|
||||||
UTLIST_SV(_ls_tail, list); \
|
UTLIST_SV(_ls_tail, list); \
|
||||||
UTLIST_NEXTASGN(_ls_tail, list, _ls_e, next); \
|
UTLIST_NEXTASGN(_ls_tail, list, _ls_e, next); \
|
||||||
UTLIST_RS(list); \
|
UTLIST_RS(list); \
|
||||||
} else { \
|
} else { \
|
||||||
UTLIST_CASTASGN(list, _ls_e); \
|
UTLIST_CASTASGN(list, _ls_e); \
|
||||||
} \
|
} \
|
||||||
_ls_tail = _ls_e; \
|
_ls_tail = _ls_e; \
|
||||||
} \
|
} \
|
||||||
_ls_p = _ls_q; \
|
_ls_p = _ls_q; \
|
||||||
} \
|
} \
|
||||||
if (_ls_tail) { \
|
if (_ls_tail) { \
|
||||||
UTLIST_SV(_ls_tail, list); \
|
UTLIST_SV(_ls_tail, list); \
|
||||||
UTLIST_NEXTASGN(_ls_tail, list, NULL, next); \
|
UTLIST_NEXTASGN(_ls_tail, list, NULL, next); \
|
||||||
UTLIST_RS(list); \
|
UTLIST_RS(list); \
|
||||||
} \
|
} \
|
||||||
if (_ls_nmerges <= 1) { \
|
if (_ls_nmerges <= 1) { \
|
||||||
_ls_looping = 0; \
|
_ls_looping = 0; \
|
||||||
} \
|
} \
|
||||||
_ls_insize *= 2; \
|
_ls_insize *= 2; \
|
||||||
} \
|
} \
|
||||||
} \
|
} \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
|
|
||||||
#define DL_SORT(list, cmp) \
|
#define DL_SORT(list, cmp) \
|
||||||
DL_SORT2(list, cmp, prev, next)
|
DL_SORT2(list, cmp, prev, next)
|
||||||
|
|
||||||
#define DL_SORT2(list, cmp, prev, next) \
|
#define DL_SORT2(list, cmp, prev, next) \
|
||||||
do { \
|
do { \
|
||||||
LDECLTYPE(list) \
|
LDECLTYPE(list) \
|
||||||
_ls_p; \
|
_ls_p; \
|
||||||
LDECLTYPE(list) \
|
LDECLTYPE(list) \
|
||||||
_ls_q; \
|
_ls_q; \
|
||||||
LDECLTYPE(list) \
|
LDECLTYPE(list) \
|
||||||
_ls_e; \
|
_ls_e; \
|
||||||
LDECLTYPE(list) \
|
LDECLTYPE(list) \
|
||||||
_ls_tail; \
|
_ls_tail; \
|
||||||
IF_NO_DECLTYPE(LDECLTYPE(list) _tmp;) \
|
IF_NO_DECLTYPE(LDECLTYPE(list) _tmp;) \
|
||||||
int _ls_insize, _ls_nmerges, _ls_psize, _ls_qsize, _ls_i, _ls_looping; \
|
int _ls_insize, _ls_nmerges, _ls_psize, _ls_qsize, _ls_i, _ls_looping; \
|
||||||
if (list) { \
|
if (list) { \
|
||||||
_ls_insize = 1; \
|
_ls_insize = 1; \
|
||||||
_ls_looping = 1; \
|
_ls_looping = 1; \
|
||||||
while (_ls_looping) { \
|
while (_ls_looping) { \
|
||||||
UTLIST_CASTASGN(_ls_p, list); \
|
UTLIST_CASTASGN(_ls_p, list); \
|
||||||
(list) = NULL; \
|
(list) = NULL; \
|
||||||
_ls_tail = NULL; \
|
_ls_tail = NULL; \
|
||||||
_ls_nmerges = 0; \
|
_ls_nmerges = 0; \
|
||||||
while (_ls_p) { \
|
while (_ls_p) { \
|
||||||
_ls_nmerges++; \
|
_ls_nmerges++; \
|
||||||
_ls_q = _ls_p; \
|
_ls_q = _ls_p; \
|
||||||
_ls_psize = 0; \
|
_ls_psize = 0; \
|
||||||
for (_ls_i = 0; _ls_i < _ls_insize; _ls_i++) { \
|
for (_ls_i = 0; _ls_i < _ls_insize; _ls_i++) { \
|
||||||
_ls_psize++; \
|
_ls_psize++; \
|
||||||
UTLIST_SV(_ls_q, list); \
|
UTLIST_SV(_ls_q, list); \
|
||||||
_ls_q = UTLIST_NEXT(_ls_q, list, next); \
|
_ls_q = UTLIST_NEXT(_ls_q, list, next); \
|
||||||
UTLIST_RS(list); \
|
UTLIST_RS(list); \
|
||||||
if (!_ls_q) \
|
if (!_ls_q) \
|
||||||
break; \
|
break; \
|
||||||
} \
|
} \
|
||||||
_ls_qsize = _ls_insize; \
|
_ls_qsize = _ls_insize; \
|
||||||
while ((_ls_psize > 0) || ((_ls_qsize > 0) && _ls_q)) { \
|
while ((_ls_psize > 0) || ((_ls_qsize > 0) && _ls_q)) { \
|
||||||
if (_ls_psize == 0) { \
|
if (_ls_psize == 0) { \
|
||||||
_ls_e = _ls_q; \
|
_ls_e = _ls_q; \
|
||||||
UTLIST_SV(_ls_q, list); \
|
UTLIST_SV(_ls_q, list); \
|
||||||
_ls_q = \
|
_ls_q = \
|
||||||
UTLIST_NEXT(_ls_q, list, next); \
|
UTLIST_NEXT(_ls_q, list, next); \
|
||||||
UTLIST_RS(list); \
|
UTLIST_RS(list); \
|
||||||
_ls_qsize--; \
|
_ls_qsize--; \
|
||||||
} else if ((_ls_qsize == 0) || (!_ls_q)) { \
|
} else if ((_ls_qsize == 0) || (!_ls_q)) { \
|
||||||
_ls_e = _ls_p; \
|
_ls_e = _ls_p; \
|
||||||
UTLIST_SV(_ls_p, list); \
|
UTLIST_SV(_ls_p, list); \
|
||||||
_ls_p = \
|
_ls_p = \
|
||||||
UTLIST_NEXT(_ls_p, list, next); \
|
UTLIST_NEXT(_ls_p, list, next); \
|
||||||
UTLIST_RS(list); \
|
UTLIST_RS(list); \
|
||||||
_ls_psize--; \
|
_ls_psize--; \
|
||||||
} else if (cmp(_ls_p, _ls_q) <= 0) { \
|
} else if (cmp(_ls_p, _ls_q) <= 0) { \
|
||||||
_ls_e = _ls_p; \
|
_ls_e = _ls_p; \
|
||||||
UTLIST_SV(_ls_p, list); \
|
UTLIST_SV(_ls_p, list); \
|
||||||
_ls_p = \
|
_ls_p = \
|
||||||
UTLIST_NEXT(_ls_p, list, next); \
|
UTLIST_NEXT(_ls_p, list, next); \
|
||||||
UTLIST_RS(list); \
|
UTLIST_RS(list); \
|
||||||
_ls_psize--; \
|
_ls_psize--; \
|
||||||
} else { \
|
} else { \
|
||||||
_ls_e = _ls_q; \
|
_ls_e = _ls_q; \
|
||||||
UTLIST_SV(_ls_q, list); \
|
UTLIST_SV(_ls_q, list); \
|
||||||
_ls_q = \
|
_ls_q = \
|
||||||
UTLIST_NEXT(_ls_q, list, next); \
|
UTLIST_NEXT(_ls_q, list, next); \
|
||||||
UTLIST_RS(list); \
|
UTLIST_RS(list); \
|
||||||
_ls_qsize--; \
|
_ls_qsize--; \
|
||||||
} \
|
} \
|
||||||
if (_ls_tail) { \
|
if (_ls_tail) { \
|
||||||
UTLIST_SV(_ls_tail, list); \
|
UTLIST_SV(_ls_tail, list); \
|
||||||
UTLIST_NEXTASGN(_ls_tail, list, _ls_e, next); \
|
UTLIST_NEXTASGN(_ls_tail, list, _ls_e, next); \
|
||||||
UTLIST_RS(list); \
|
UTLIST_RS(list); \
|
||||||
} else { \
|
} else { \
|
||||||
UTLIST_CASTASGN(list, _ls_e); \
|
UTLIST_CASTASGN(list, _ls_e); \
|
||||||
} \
|
} \
|
||||||
UTLIST_SV(_ls_e, list); \
|
UTLIST_SV(_ls_e, list); \
|
||||||
UTLIST_PREVASGN(_ls_e, list, _ls_tail, prev); \
|
UTLIST_PREVASGN(_ls_e, list, _ls_tail, prev); \
|
||||||
UTLIST_RS(list); \
|
UTLIST_RS(list); \
|
||||||
_ls_tail = _ls_e; \
|
_ls_tail = _ls_e; \
|
||||||
} \
|
} \
|
||||||
_ls_p = _ls_q; \
|
_ls_p = _ls_q; \
|
||||||
} \
|
} \
|
||||||
UTLIST_CASTASGN((list)->prev, _ls_tail); \
|
UTLIST_CASTASGN((list)->prev, _ls_tail); \
|
||||||
UTLIST_SV(_ls_tail, list); \
|
UTLIST_SV(_ls_tail, list); \
|
||||||
UTLIST_NEXTASGN(_ls_tail, list, NULL, next); \
|
UTLIST_NEXTASGN(_ls_tail, list, NULL, next); \
|
||||||
UTLIST_RS(list); \
|
UTLIST_RS(list); \
|
||||||
if (_ls_nmerges <= 1) { \
|
if (_ls_nmerges <= 1) { \
|
||||||
_ls_looping = 0; \
|
_ls_looping = 0; \
|
||||||
} \
|
} \
|
||||||
_ls_insize *= 2; \
|
_ls_insize *= 2; \
|
||||||
} \
|
} \
|
||||||
} \
|
} \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
#define CDL_SORT(list, cmp) \
|
#define CDL_SORT(list, cmp) \
|
||||||
CDL_SORT2(list, cmp, prev, next)
|
CDL_SORT2(list, cmp, prev, next)
|
||||||
|
|
||||||
#define CDL_SORT2(list, cmp, prev, next) \
|
#define CDL_SORT2(list, cmp, prev, next) \
|
||||||
do { \
|
do { \
|
||||||
LDECLTYPE(list) \
|
LDECLTYPE(list) \
|
||||||
_ls_p; \
|
_ls_p; \
|
||||||
LDECLTYPE(list) \
|
LDECLTYPE(list) \
|
||||||
_ls_q; \
|
_ls_q; \
|
||||||
LDECLTYPE(list) \
|
LDECLTYPE(list) \
|
||||||
_ls_e; \
|
_ls_e; \
|
||||||
LDECLTYPE(list) \
|
LDECLTYPE(list) \
|
||||||
_ls_tail; \
|
_ls_tail; \
|
||||||
LDECLTYPE(list) \
|
LDECLTYPE(list) \
|
||||||
_ls_oldhead; \
|
_ls_oldhead; \
|
||||||
LDECLTYPE(list) \
|
LDECLTYPE(list) \
|
||||||
_tmp; \
|
_tmp; \
|
||||||
int _ls_insize, _ls_nmerges, _ls_psize, _ls_qsize, _ls_i, _ls_looping; \
|
int _ls_insize, _ls_nmerges, _ls_psize, _ls_qsize, _ls_i, _ls_looping; \
|
||||||
if (list) { \
|
if (list) { \
|
||||||
_ls_insize = 1; \
|
_ls_insize = 1; \
|
||||||
_ls_looping = 1; \
|
_ls_looping = 1; \
|
||||||
while (_ls_looping) { \
|
while (_ls_looping) { \
|
||||||
UTLIST_CASTASGN(_ls_p, list); \
|
UTLIST_CASTASGN(_ls_p, list); \
|
||||||
UTLIST_CASTASGN(_ls_oldhead, list); \
|
UTLIST_CASTASGN(_ls_oldhead, list); \
|
||||||
(list) = NULL; \
|
(list) = NULL; \
|
||||||
_ls_tail = NULL; \
|
_ls_tail = NULL; \
|
||||||
_ls_nmerges = 0; \
|
_ls_nmerges = 0; \
|
||||||
while (_ls_p) { \
|
while (_ls_p) { \
|
||||||
_ls_nmerges++; \
|
_ls_nmerges++; \
|
||||||
_ls_q = _ls_p; \
|
_ls_q = _ls_p; \
|
||||||
_ls_psize = 0; \
|
_ls_psize = 0; \
|
||||||
for (_ls_i = 0; _ls_i < _ls_insize; _ls_i++) { \
|
for (_ls_i = 0; _ls_i < _ls_insize; _ls_i++) { \
|
||||||
_ls_psize++; \
|
_ls_psize++; \
|
||||||
UTLIST_SV(_ls_q, list); \
|
UTLIST_SV(_ls_q, list); \
|
||||||
if (UTLIST_NEXT(_ls_q, list, next) == _ls_oldhead) { \
|
if (UTLIST_NEXT(_ls_q, list, next) == _ls_oldhead) { \
|
||||||
_ls_q = NULL; \
|
_ls_q = NULL; \
|
||||||
} else { \
|
} else { \
|
||||||
_ls_q = UTLIST_NEXT(_ls_q, list, next); \
|
_ls_q = UTLIST_NEXT(_ls_q, list, next); \
|
||||||
} \
|
} \
|
||||||
UTLIST_RS(list); \
|
UTLIST_RS(list); \
|
||||||
if (!_ls_q) \
|
if (!_ls_q) \
|
||||||
break; \
|
break; \
|
||||||
} \
|
} \
|
||||||
_ls_qsize = _ls_insize; \
|
_ls_qsize = _ls_insize; \
|
||||||
while (_ls_psize > 0 || (_ls_qsize > 0 && _ls_q)) { \
|
while (_ls_psize > 0 || (_ls_qsize > 0 && _ls_q)) { \
|
||||||
if (_ls_psize == 0) { \
|
if (_ls_psize == 0) { \
|
||||||
_ls_e = _ls_q; \
|
_ls_e = _ls_q; \
|
||||||
UTLIST_SV(_ls_q, list); \
|
UTLIST_SV(_ls_q, list); \
|
||||||
_ls_q = \
|
_ls_q = \
|
||||||
UTLIST_NEXT(_ls_q, list, next); \
|
UTLIST_NEXT(_ls_q, list, next); \
|
||||||
UTLIST_RS(list); \
|
UTLIST_RS(list); \
|
||||||
_ls_qsize--; \
|
_ls_qsize--; \
|
||||||
if (_ls_q == _ls_oldhead) { \
|
if (_ls_q == _ls_oldhead) { \
|
||||||
_ls_q = NULL; \
|
_ls_q = NULL; \
|
||||||
} \
|
} \
|
||||||
} else if (_ls_qsize == 0 || !_ls_q) { \
|
} else if (_ls_qsize == 0 || !_ls_q) { \
|
||||||
_ls_e = _ls_p; \
|
_ls_e = _ls_p; \
|
||||||
UTLIST_SV(_ls_p, list); \
|
UTLIST_SV(_ls_p, list); \
|
||||||
_ls_p = \
|
_ls_p = \
|
||||||
UTLIST_NEXT(_ls_p, list, next); \
|
UTLIST_NEXT(_ls_p, list, next); \
|
||||||
UTLIST_RS(list); \
|
UTLIST_RS(list); \
|
||||||
_ls_psize--; \
|
_ls_psize--; \
|
||||||
if (_ls_p == _ls_oldhead) { \
|
if (_ls_p == _ls_oldhead) { \
|
||||||
_ls_p = NULL; \
|
_ls_p = NULL; \
|
||||||
} \
|
} \
|
||||||
} else if (cmp(_ls_p, _ls_q) <= 0) { \
|
} else if (cmp(_ls_p, _ls_q) <= 0) { \
|
||||||
_ls_e = _ls_p; \
|
_ls_e = _ls_p; \
|
||||||
UTLIST_SV(_ls_p, list); \
|
UTLIST_SV(_ls_p, list); \
|
||||||
_ls_p = \
|
_ls_p = \
|
||||||
UTLIST_NEXT(_ls_p, list, next); \
|
UTLIST_NEXT(_ls_p, list, next); \
|
||||||
UTLIST_RS(list); \
|
UTLIST_RS(list); \
|
||||||
_ls_psize--; \
|
_ls_psize--; \
|
||||||
if (_ls_p == _ls_oldhead) { \
|
if (_ls_p == _ls_oldhead) { \
|
||||||
_ls_p = NULL; \
|
_ls_p = NULL; \
|
||||||
} \
|
} \
|
||||||
} else { \
|
} else { \
|
||||||
_ls_e = _ls_q; \
|
_ls_e = _ls_q; \
|
||||||
UTLIST_SV(_ls_q, list); \
|
UTLIST_SV(_ls_q, list); \
|
||||||
_ls_q = \
|
_ls_q = \
|
||||||
UTLIST_NEXT(_ls_q, list, next); \
|
UTLIST_NEXT(_ls_q, list, next); \
|
||||||
UTLIST_RS(list); \
|
UTLIST_RS(list); \
|
||||||
_ls_qsize--; \
|
_ls_qsize--; \
|
||||||
if (_ls_q == _ls_oldhead) { \
|
if (_ls_q == _ls_oldhead) { \
|
||||||
_ls_q = NULL; \
|
_ls_q = NULL; \
|
||||||
} \
|
} \
|
||||||
} \
|
} \
|
||||||
if (_ls_tail) { \
|
if (_ls_tail) { \
|
||||||
UTLIST_SV(_ls_tail, list); \
|
UTLIST_SV(_ls_tail, list); \
|
||||||
UTLIST_NEXTASGN(_ls_tail, list, _ls_e, next); \
|
UTLIST_NEXTASGN(_ls_tail, list, _ls_e, next); \
|
||||||
UTLIST_RS(list); \
|
UTLIST_RS(list); \
|
||||||
} else { \
|
} else { \
|
||||||
UTLIST_CASTASGN(list, _ls_e); \
|
UTLIST_CASTASGN(list, _ls_e); \
|
||||||
} \
|
} \
|
||||||
UTLIST_SV(_ls_e, list); \
|
UTLIST_SV(_ls_e, list); \
|
||||||
UTLIST_PREVASGN(_ls_e, list, _ls_tail, prev); \
|
UTLIST_PREVASGN(_ls_e, list, _ls_tail, prev); \
|
||||||
UTLIST_RS(list); \
|
UTLIST_RS(list); \
|
||||||
_ls_tail = _ls_e; \
|
_ls_tail = _ls_e; \
|
||||||
} \
|
} \
|
||||||
_ls_p = _ls_q; \
|
_ls_p = _ls_q; \
|
||||||
} \
|
} \
|
||||||
UTLIST_CASTASGN((list)->prev, _ls_tail); \
|
UTLIST_CASTASGN((list)->prev, _ls_tail); \
|
||||||
UTLIST_CASTASGN(_tmp, list); \
|
UTLIST_CASTASGN(_tmp, list); \
|
||||||
UTLIST_SV(_ls_tail, list); \
|
UTLIST_SV(_ls_tail, list); \
|
||||||
UTLIST_NEXTASGN(_ls_tail, list, _tmp, next); \
|
UTLIST_NEXTASGN(_ls_tail, list, _tmp, next); \
|
||||||
UTLIST_RS(list); \
|
UTLIST_RS(list); \
|
||||||
if (_ls_nmerges <= 1) { \
|
if (_ls_nmerges <= 1) { \
|
||||||
_ls_looping = 0; \
|
_ls_looping = 0; \
|
||||||
} \
|
} \
|
||||||
_ls_insize *= 2; \
|
_ls_insize *= 2; \
|
||||||
} \
|
} \
|
||||||
} \
|
} \
|
||||||
} while (0)
|
} 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) \
|
#define CDL_FOREACH_SAFE2(head, el, tmp1, tmp2, prev, next) \
|
||||||
for ((el) = (head), (tmp1) = (head) ? (head)->prev : NULL; \
|
for ((el) = (head), (tmp1) = (head) ? (head)->prev : NULL; \
|
||||||
(el) && ((tmp2) = (el)->next, 1); \
|
(el) && ((tmp2) = (el)->next, 1); \
|
||||||
(el) = ((el) == (tmp1) ? NULL : (tmp2)))
|
(el) = ((el) == (tmp1) ? NULL : (tmp2)))
|
||||||
|
|
||||||
#define CDL_SEARCH_SCALAR(head, out, field, val) \
|
#define CDL_SEARCH_SCALAR(head, out, field, val) \
|
||||||
CDL_SEARCH_SCALAR2(head, out, field, val, next)
|
CDL_SEARCH_SCALAR2(head, out, field, val, next)
|
||||||
|
@ -97,7 +97,7 @@ instr_start(int rank, int nranks)
|
|||||||
int curcpu = rank;
|
int curcpu = rank;
|
||||||
|
|
||||||
dbg("thread %d has cpu %d (ncpus=%d)\n",
|
dbg("thread %d has cpu %d (ncpus=%d)\n",
|
||||||
gettid(), curcpu, nranks);
|
gettid(), curcpu, nranks);
|
||||||
|
|
||||||
instr_thread_execute(curcpu, -1, 0);
|
instr_thread_execute(curcpu, -1, 0);
|
||||||
}
|
}
|
||||||
|
@ -73,7 +73,7 @@ instr_start(int rank, int nranks)
|
|||||||
int curcpu = rank;
|
int curcpu = rank;
|
||||||
|
|
||||||
fprintf(stderr, "thread %d has cpu %d (ncpus=%d)\n",
|
fprintf(stderr, "thread %d has cpu %d (ncpus=%d)\n",
|
||||||
gettid(), curcpu, nranks);
|
gettid(), curcpu, nranks);
|
||||||
|
|
||||||
instr_thread_execute(curcpu, -1, 0);
|
instr_thread_execute(curcpu, -1, 0);
|
||||||
}
|
}
|
||||||
|
@ -85,7 +85,7 @@ instr_start(int rank)
|
|||||||
curcpu = -1;
|
curcpu = -1;
|
||||||
|
|
||||||
fprintf(stderr, "thread %d has cpu %d (ncpus=%d)\n",
|
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);
|
instr_thread_execute(curcpu, -1, 0);
|
||||||
}
|
}
|
||||||
|
@ -15,8 +15,8 @@ main(void)
|
|||||||
|
|
||||||
nosv_task_type_t type;
|
nosv_task_type_t type;
|
||||||
if (nosv_type_init(&type, NULL, NULL, NULL, "adopted", NULL,
|
if (nosv_type_init(&type, NULL, NULL, NULL, "adopted", NULL,
|
||||||
NULL, NOSV_TYPE_INIT_EXTERNAL)
|
NULL, NOSV_TYPE_INIT_EXTERNAL)
|
||||||
!= 0)
|
!= 0)
|
||||||
die("nosv_type_init failed\n");
|
die("nosv_type_init failed\n");
|
||||||
|
|
||||||
nosv_task_t task;
|
nosv_task_t task;
|
||||||
|
Loading…
Reference in New Issue
Block a user