merge to upstream

This commit is contained in:
Hayden Kowalchuk 2019-03-13 07:04:10 -04:00
commit 84edc083ea
2 changed files with 17 additions and 5 deletions

View File

@ -9,6 +9,8 @@
#if PROFILER_COMPILE #if PROFILER_COMPILE
#include "../containers/aligned_vector.h" #include "../containers/aligned_vector.h"
#ifdef PROFILER_COMPILE
#define MAX_PATH 256 #define MAX_PATH 256
typedef struct { typedef struct {
@ -129,7 +131,7 @@ void profiler_pop() {
aligned_vector_resize(&root->stack, root->stack.size - 1); aligned_vector_resize(&root->stack, root->stack.size - 1);
} }
#include <inttypes.h>
void profiler_print_stats() { void profiler_print_stats() {
if(!PROFILER_ENABLED) return; if(!PROFILER_ENABLED) return;
@ -143,7 +145,7 @@ void profiler_print_stats() {
float avg = ms / (float) result->total_calls; float avg = ms / (float) result->total_calls;
total_ms += ms; total_ms += ms;
fprintf(stderr, "%-60s%-20f%-20f%u\n", result->name, avg, ms, result->total_calls); fprintf(stderr, "%-60s%-20f%-20f%" PRIu64 "\n", result->name, (double)avg, (double)ms, result->total_calls);
} }
total_ms/=((ProfilerResult*)aligned_vector_at(&root->results, i-1))->total_calls; total_ms/=((ProfilerResult*)aligned_vector_at(&root->results, i-1))->total_calls;
fps = 1000/total_ms; fps = 1000/total_ms;

View File

@ -12,6 +12,17 @@
#include "named_array.h" #include "named_array.h"
#define BYTE_TO_BINARY_PATTERN "%c%c%c%c%c%c%c%c"
#define BYTE_TO_BINARY(byte) \
(byte & 0x80 ? '1' : '0'), \
(byte & 0x40 ? '1' : '0'), \
(byte & 0x20 ? '1' : '0'), \
(byte & 0x10 ? '1' : '0'), \
(byte & 0x08 ? '1' : '0'), \
(byte & 0x04 ? '1' : '0'), \
(byte & 0x02 ? '1' : '0'), \
(byte & 0x01 ? '1' : '0')
void named_array_init(NamedArray* array, unsigned int element_size, unsigned int max_elements) { void named_array_init(NamedArray* array, unsigned int element_size, unsigned int max_elements) {
array->element_size = element_size; array->element_size = element_size;
array->max_element_count = max_elements; array->max_element_count = max_elements;
@ -64,7 +75,6 @@ void* named_array_reserve(NamedArray* array, unsigned int id) {
unsigned int j = (id % 8); unsigned int j = (id % 8);
unsigned int i = id / 8; unsigned int i = id / 8;
assert(!named_array_used(array, id));
array->used_markers[i] |= (unsigned char) 1 << j; array->used_markers[i] |= (unsigned char) 1 << j;
assert(named_array_used(array, id)); assert(named_array_used(array, id));