| 176 | #endif |
| 177 | |
| 178 | void mtr_init_from_stream(void *stream) { |
| 179 | #ifndef MTR_ENABLED |
| 180 | return; |
| 181 | #endif |
| 182 | event_buffer = (raw_event_t *)malloc(INTERNAL_MINITRACE_BUFFER_SIZE * sizeof(raw_event_t)); |
| 183 | flush_buffer = (raw_event_t *)malloc(INTERNAL_MINITRACE_BUFFER_SIZE * sizeof(raw_event_t)); |
| 184 | is_tracing = 1; |
| 185 | event_count = 0; |
| 186 | f = (FILE *)stream; |
| 187 | const char *header = "{\"traceEvents\":[\n"; |
| 188 | fwrite(header, 1, strlen(header), f); |
| 189 | time_offset = (uint64_t)(mtr_time_s() * 1000000); |
| 190 | first_line = 1; |
| 191 | pthread_mutex_init(&mutex, 0); |
| 192 | pthread_mutex_init(&event_mutex, 0); |
| 193 | } |
| 194 | |
| 195 | void mtr_init(const char *json_file) { |
| 196 | #ifndef MTR_ENABLED |
no test coverage detected