X-Git-Url: https://pd.if.org/git/?p=nbds;a=blobdiff_plain;f=runtime%2Flwt.c;h=a986567bcb05023f8e6bafb541035fe5266f9900;hp=f6bd3467d81eace074f13ef07bee64193c692772;hb=778b8c8ca708b082a1192acfb114a6751b2ad7c9;hpb=f0777b2151019e22458f6f166a8f3c569c32a505 diff --git a/runtime/lwt.c b/runtime/lwt.c index f6bd346..a986567 100644 --- a/runtime/lwt.c +++ b/runtime/lwt.c @@ -10,15 +10,15 @@ #include "lwt.h" #include "mem.h" -#define LWT_BUFFER_SCALE 16 -#define LWT_BUFFER_SIZE (1 << LWT_BUFFER_SCALE) +#define LWT_BUFFER_SCALE 20 +#define LWT_BUFFER_SIZE (1ULL << LWT_BUFFER_SCALE) #define LWT_BUFFER_MASK (LWT_BUFFER_SIZE - 1) volatile int halt_ = 0; typedef struct lwt_record { uint64_t timestamp; - const char *format; + uint64_t format; size_t value1; size_t value2; } lwt_record_t; @@ -51,15 +51,15 @@ void lwt_set_trace_level (const char *flags) } } -static inline void dump_record (FILE *file, int thread_id, lwt_record_t *r, uint64_t offset) +static void dump_record (FILE *file, int thread_id, lwt_record_t *r, uint64_t offset) { // print the record if its trace category is enabled at a high enough level - int flag = (size_t)r->format >> 56; - int level = ((size_t)r->format >> 48) & 0xFF; + int flag = r->format >> 56; + int level = (r->format >> 48) & 0xFF; if (flag_state_[(unsigned)flag] >= level) { char s[3] = {flag, level, '\0'}; fprintf(file, "%09llu %d %s ", ((uint64_t)r->timestamp - offset) >> 5, thread_id, s); - const char *format = (const char *)((size_t)r->format & MASK(48)); // strip out the embedded flags + const char *format = (const char *)(size_t)(r->format & MASK(48)); // strip out the embedded flags fprintf(file, format, r->value1, r->value2); fprintf(file, "\n"); } @@ -118,7 +118,7 @@ void lwt_dump (const char *file_name) } } -void lwt_trace_i (const char *format, size_t value1, size_t value2) { +void lwt_trace_i (uint64_t format, size_t value1, size_t value2) { while (halt_) {} LOCALIZE_THREAD_LOCAL(tid_, int); lwt_buffer_t *tb = lwt_buf_[tid_];