#include #include #include #include #include #include #include #include #include #include "ovni.h" #include "def.h" /* Data per process */ struct ovniproc ovniproc = {0}; /* Data per thread */ _Thread_local struct ovnithr ovnithr = {0}; static int create_trace_dirs(char *tracedir, int loom, int proc) { char path[PATH_MAX]; fprintf(stderr, "create trace dirs for loom=%d, proc=%d\n", loom, proc); snprintf(path, PATH_MAX, "%s", tracedir); if(mkdir(path, 0755)) { fprintf(stderr, "mkdir %s: %s\n", path, strerror(errno)); //return -1; } snprintf(path, PATH_MAX, "%s/loom.%d", tracedir, loom); if(mkdir(path, 0755)) { fprintf(stderr, "mkdir %s: %s\n", path, strerror(errno)); //return -1; } snprintf(ovniproc.dir, PATH_MAX, "%s/loom.%d/proc.%d", tracedir, loom, proc); if(mkdir(ovniproc.dir, 0755)) { fprintf(stderr, "mkdir %s: %s\n", ovniproc.dir, strerror(errno)); return -1; } return 0; } static int create_trace_streams(int ncpus) { char path[PATH_MAX]; int i; for(i=0; i> 6; ovnithr.clockvalue = (uint64_t) raw; return 0; } //static void //pack_int64(uint8_t **q, int64_t n) //{ // uint8_t *p = *q; // // *p++ = (n >> 0) & 0xff; // *p++ = (n >> 8) & 0xff; // *p++ = (n >> 16) & 0xff; // *p++ = (n >> 24) & 0xff; // *p++ = (n >> 32) & 0xff; // *p++ = (n >> 40) & 0xff; // *p++ = (n >> 48) & 0xff; // *p++ = (n >> 56) & 0xff; // // *q = p; //} static void pack_uint32(uint8_t **q, uint32_t n) { uint8_t *p = *q; *p++ = (n >> 0) & 0xff; *p++ = (n >> 8) & 0xff; *p++ = (n >> 16) & 0xff; *p++ = (n >> 24) & 0xff; *q = p; } static void pack_uint8(uint8_t **q, uint8_t n) { uint8_t *p = *q; *p++ = n; *q = p; } static int ovni_write(uint8_t *buf, size_t size) { FILE *f; int i, j; printf("writing %ld bytes in cpu=%d\n", size, ovnithr.cpu); for(i=0; i 1) { fprintf(stderr, "the stream for cpu.%d is already in use\n", cpu); abort(); } } void ovni_stream_close(int cpu) { atomic_fetch_sub(&ovniproc.opened[cpu], 1); }