From 6c5e59718f104f62ed1e865468dc3cdd04c1b86f Mon Sep 17 00:00:00 2001 From: Camilo Aguilar Date: Sat, 9 Apr 2016 14:00:35 -0400 Subject: [PATCH 1/4] Fixes conflict with musl libc defined variable PAGE_SIZE. --- src/heap.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/heap.c b/src/heap.c index e6a29b16..d6b32b97 100644 --- a/src/heap.c +++ b/src/heap.c @@ -44,7 +44,7 @@ static int ENTRIES_PER_PAGE = 0; * Stores the number of bytes in a single * page of memory. */ -static int PAGE_SIZE = 0; +static int MEM_PAGE_SIZE = 0; // Helper function to map a number of pages into memory // Returns NULL on error, otherwise returns a pointer to the @@ -54,13 +54,13 @@ static void* map_in_pages(int page_count) { assert(page_count > 0); // Call malloc to get the pages - void* addr = malloc(page_count*PAGE_SIZE); + void* addr = malloc(page_count*MEM_PAGE_SIZE); if (!addr) return NULL; else { // Clear the memory - bzero(addr,page_count*PAGE_SIZE); + bzero(addr,page_count*MEM_PAGE_SIZE); // Return the address return addr; @@ -98,12 +98,12 @@ int compare_int_keys(register void* key1, register void* key2) { // Creates a new heap void heap_create(heap* h, int initial_size, int (*comp_func)(void*,void*)) { // Check if we need to setup our globals - if (PAGE_SIZE == 0) { + if (MEM_PAGE_SIZE == 0) { // Get the page size - PAGE_SIZE = getpagesize(); + MEM_PAGE_SIZE = getpagesize(); // Calculate the max entries - ENTRIES_PER_PAGE = PAGE_SIZE / sizeof(heap_entry); + ENTRIES_PER_PAGE = MEM_PAGE_SIZE / sizeof(heap_entry); } // Check that initial size is greater than 0, else set it to ENTRIES_PER_PAGE @@ -185,7 +185,7 @@ void heap_insert(heap *h, void* key, void* value) { heap_entry* new_table = map_in_pages(new_size); // Copy the old entries, copy the entire pages - memcpy(new_table, h->table, h->allocated_pages*PAGE_SIZE); + memcpy(new_table, h->table, h->allocated_pages*MEM_PAGE_SIZE); // Cleanup the old table map_out_pages(h->table, h->allocated_pages); @@ -344,7 +344,7 @@ int heap_delmin(heap* h, void** key, void** value) { heap_entry* new_table = map_in_pages(new_size); // Copy the old entries, copy the entire pages - memcpy(new_table, h->table, used_pages*PAGE_SIZE); + memcpy(new_table, h->table, used_pages*MEM_PAGE_SIZE); // Cleanup the old table map_out_pages(h->table, h->allocated_pages); @@ -376,5 +376,3 @@ void heap_foreach(heap* h, void (*func)(void*,void*)) { func(entry->key, entry->value); } } - - From b84b20deb9e844a548f32b1ea4f44857cf0925f7 Mon Sep 17 00:00:00 2001 From: Camilo Aguilar Date: Sat, 9 Apr 2016 14:10:17 -0400 Subject: [PATCH 2/4] Fixes "always_inline function might not be inlinable" warning The '__attribute__((always_inline))' does not strictly imply 'inline'. Newer versions of gcc detect this misuse and issue the warning. Including the missing 'inline' resolves the build warning. --- deps/murmurhash/MurmurHash3.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/deps/murmurhash/MurmurHash3.c b/deps/murmurhash/MurmurHash3.c index 44ca36e7..d680e092 100644 --- a/deps/murmurhash/MurmurHash3.c +++ b/deps/murmurhash/MurmurHash3.c @@ -12,7 +12,7 @@ //----------------------------------------------------------------------------- // Platform-specific functions and macros -#define FORCE_INLINE __attribute__((always_inline)) +#define FORCE_INLINE inline __attribute__((always_inline)) inline uint64_t rotl64(uint64_t x, int8_t r){ return (x << r) | (x >> (64 - r)); @@ -124,4 +124,3 @@ void MurmurHash3_x64_128 ( const void * key, const int len, ((uint64_t*)out)[0] = h1; ((uint64_t*)out)[1] = h2; } - From f227b25531ac2be505560a10be4f6cac9eb87567 Mon Sep 17 00:00:00 2001 From: Camilo Aguilar Date: Sat, 9 Apr 2016 14:16:22 -0400 Subject: [PATCH 3/4] Fixes compilation warning when using %lld formatting with uint64_t types --- src/conn_handler.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/conn_handler.c b/src/conn_handler.c index 89ac38f9..da6967d3 100644 --- a/src/conn_handler.c +++ b/src/conn_handler.c @@ -112,7 +112,7 @@ static int stream_formatter(FILE *pipe, void *data, metric_type type, char *name case COUNTER: if (GLOBAL_CONFIG->extended_counters) { if (counters_config->count) { - STREAM("%s%s.count|%lld|%lld\n", prefix, name, counter_count(value)); + STREAM("%s%s.count|%lu|%lld\n", prefix, name, counter_count(value)); } if (counters_config->mean) { STREAM("%s%s.mean|%f|%lld\n", prefix, name, counter_mean(value)); @@ -141,7 +141,7 @@ static int stream_formatter(FILE *pipe, void *data, metric_type type, char *name break; case SET: - STREAM("%s%s|%lld|%lld\n", prefix, name, set_size(value)); + STREAM("%s%s|%lu|%lld\n", prefix, name, set_size(value)); break; case TIMER: @@ -162,7 +162,7 @@ static int stream_formatter(FILE *pipe, void *data, metric_type type, char *name STREAM("%s%s.upper|%f|%lld\n", prefix, name, timer_max(&t->tm)); } if (timers_config->count) { - STREAM("%s%s.count|%lld|%lld\n", prefix, name, timer_count(&t->tm)); + STREAM("%s%s.count|%lu|%lld\n", prefix, name, timer_count(&t->tm)); } if (timers_config->stdev) { STREAM("%s%s.stdev|%f|%lld\n", prefix, name, timer_stddev(&t->tm)); From 6f1ab96733f31c96729947a02ccc49e5c24bba5e Mon Sep 17 00:00:00 2001 From: Camilo Aguilar Date: Sat, 9 Apr 2016 14:32:31 -0400 Subject: [PATCH 4/4] Uses PRIu64 to format uint64_t types according to each platform. --- src/conn_handler.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/conn_handler.c b/src/conn_handler.c index da6967d3..92c5f3ea 100644 --- a/src/conn_handler.c +++ b/src/conn_handler.c @@ -12,6 +12,7 @@ #include "metrics.h" #include "streaming.h" #include "conn_handler.h" +#include /* * Binary defines @@ -112,7 +113,7 @@ static int stream_formatter(FILE *pipe, void *data, metric_type type, char *name case COUNTER: if (GLOBAL_CONFIG->extended_counters) { if (counters_config->count) { - STREAM("%s%s.count|%lu|%lld\n", prefix, name, counter_count(value)); + STREAM("%s%s.count|%"PRIu64"|%lld\n", prefix, name, counter_count(value)); } if (counters_config->mean) { STREAM("%s%s.mean|%f|%lld\n", prefix, name, counter_mean(value)); @@ -141,7 +142,7 @@ static int stream_formatter(FILE *pipe, void *data, metric_type type, char *name break; case SET: - STREAM("%s%s|%lu|%lld\n", prefix, name, set_size(value)); + STREAM("%s%s|%"PRIu64"|%lld\n", prefix, name, set_size(value)); break; case TIMER: @@ -162,7 +163,7 @@ static int stream_formatter(FILE *pipe, void *data, metric_type type, char *name STREAM("%s%s.upper|%f|%lld\n", prefix, name, timer_max(&t->tm)); } if (timers_config->count) { - STREAM("%s%s.count|%lu|%lld\n", prefix, name, timer_count(&t->tm)); + STREAM("%s%s.count|%"PRIu64"|%lld\n", prefix, name, timer_count(&t->tm)); } if (timers_config->stdev) { STREAM("%s%s.stdev|%f|%lld\n", prefix, name, timer_stddev(&t->tm));