Skip to content

Commit

Permalink
Squashed 'hdrhistogram/' changes from 17d3c9e..7bde163
Browse files Browse the repository at this point in the history
7bde163 Add more warnings and fix them

git-subtree-dir: hdrhistogram
git-subtree-split: 7bde16335daf9c9a2e25db67e7714f70dea184aa
  • Loading branch information
baruch committed Oct 10, 2015
1 parent 350a167 commit 2fe887d
Show file tree
Hide file tree
Showing 10 changed files with 30 additions and 33 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ project("hdr_histogram")
ENABLE_TESTING()

if(UNIX)
set(CMAKE_C_FLAGS "-Wall -Wno-unknown-pragmas -Wextra -Wshadow -Winit-self")
set(CMAKE_C_FLAGS "-Wall -Wno-unknown-pragmas -Wextra -Wshadow -Winit-self -Wmissing-prototypes")
set(CMAKE_C_FLAGS_DEBUG "-O0 -g")
set(CMAKE_C_FLAGS_RELEASE "-O3 -g")
endif()
Expand Down
10 changes: 5 additions & 5 deletions examples/hiccup.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#include <hdr_interval_recorder.h>
#include <hdr_time.h>

int64_t diff(struct timespec t0, struct timespec t1)
static int64_t diff(struct timespec t0, struct timespec t1)
{
int64_t delta_us = 0;
delta_us = (t1.tv_sec - t0.tv_sec) * 1000000;
Expand All @@ -32,15 +32,15 @@ int64_t diff(struct timespec t0, struct timespec t1)
return delta_us;
}

void update_histogram(void* data, void* arg)
static void update_histogram(void* data, void* arg)
{
struct hdr_histogram* h = data;
int64_t* values = arg;

hdr_record_value(h, values[0]);
}

void* record_hiccups(void* thread_context)
static void* record_hiccups(void* thread_context)
{
struct pollfd fd;
struct timespec t0;
Expand Down Expand Up @@ -90,7 +90,7 @@ const char* USAGE =
" interval: <number> Time in seconds between samples (default 1).\n"
" filename: <string> Name of the file to log to (default stdout).\n";

int handle_opts(int argc, char** argv, struct config_t* config)
static int handle_opts(int argc, char** argv, struct config_t* config)
{
int c;
int interval = 1;
Expand Down Expand Up @@ -205,4 +205,4 @@ int main(int argc, char** argv)
#pragma clang diagnostic pop

pthread_exit(NULL);
}
}
3 changes: 2 additions & 1 deletion src/hdr_encoding.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <math.h>

#include "hdr_encoding.h"
#include "hdr_tests.h"

int zig_zag_encode_i64(uint8_t* buffer, int64_t signed_value)
{
Expand Down Expand Up @@ -207,7 +208,7 @@ size_t hdr_base64_decoded_len(size_t encoded_size)
return (encoded_size / 4) * 3;
}

void hdr_base64_encode_block_pad(const uint8_t* input, char* output, size_t pad)
static void hdr_base64_encode_block_pad(const uint8_t* input, char* output, size_t pad)
{
uint32_t _24_bit_value = 0;

Expand Down
11 changes: 6 additions & 5 deletions src/hdr_histogram.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include <inttypes.h>

#include "hdr_histogram.h"
#include "hdr_tests.h"

// ###### ####### ## ## ## ## ######## ######
// ## ## ## ## ## ## ### ## ## ## ##
Expand Down Expand Up @@ -220,7 +221,7 @@ void hdr_reset_internal_counters(struct hdr_histogram* h)
h->total_count = observed_total_count;
}

int32_t buckets_needed_to_cover_value(int64_t value, int32_t sub_bucket_count, int32_t unit_magnitude)
static int32_t buckets_needed_to_cover_value(int64_t value, int32_t sub_bucket_count, int32_t unit_magnitude)
{
int64_t smallest_untrackable_value = ((int64_t) sub_bucket_count) << unit_magnitude;
int32_t buckets_needed = 1;
Expand Down Expand Up @@ -686,7 +687,7 @@ bool hdr_iter_next(struct hdr_iter* iter)
// ## ## ## ## ## ## ## ## ### ## ## ## ## ## ##
// ## ######## ## ## ###### ######## ## ## ## #### ######## ######## ######

bool _percentile_iter_next(struct hdr_iter* iter)
static bool _percentile_iter_next(struct hdr_iter* iter)
{
struct hdr_iter_percentiles* percentiles = &iter->specifics.percentiles;

Expand Down Expand Up @@ -772,7 +773,7 @@ static void format_line_string(char* str, size_t len, int significant_figures, f
// ## ## ######## ###### ####### ## ## ######## ######## ########


bool _recorded_iter_next(struct hdr_iter* iter)
static bool _recorded_iter_next(struct hdr_iter* iter)
{
while (_basic_iter_next(iter))
{
Expand Down Expand Up @@ -806,7 +807,7 @@ void hdr_iter_recorded_init(struct hdr_iter* iter, const struct hdr_histogram* h
// ######## #### ## ## ######## ## ## ## ##


bool _iter_linear_next(struct hdr_iter* iter)
static bool _iter_linear_next(struct hdr_iter* iter)
{
struct hdr_iter_linear* linear = &iter->specifics.linear;

Expand Down Expand Up @@ -862,7 +863,7 @@ void hdr_iter_linear_init(struct hdr_iter* iter, const struct hdr_histogram* h,
// ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ##
// ######## ####### ###### ## ## ## ## #### ## ## ## ## ## #### ######

bool _log_iter_next(struct hdr_iter *iter)
static bool _log_iter_next(struct hdr_iter *iter)
{
struct hdr_iter_log* logarithmic = &iter->specifics.log;

Expand Down
9 changes: 5 additions & 4 deletions src/hdr_histogram_log.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include "hdr_encoding.h"
#include "hdr_histogram.h"
#include "hdr_histogram_log.h"
#include "hdr_tests.h"

#ifdef __APPLE__

Expand Down Expand Up @@ -54,7 +55,7 @@ int32_t counts_index_for(const struct hdr_histogram* h, int64_t value);
} \
while (0)

int realloc_buffer(
static int realloc_buffer(
void** buffer, size_t nmemb, ssize_t size)
{
size_t len = nmemb * size;
Expand Down Expand Up @@ -86,7 +87,7 @@ int realloc_buffer(
// ## ## ## ## ## ## ## ### ## ## ## ##
// ###### ## ## ## #### ## ## ###### ######

ssize_t null_trailing_whitespace(char* s, ssize_t len)
static ssize_t null_trailing_whitespace(char* s, ssize_t len)
{
ssize_t i = len;
while (--i != -1)
Expand Down Expand Up @@ -121,12 +122,12 @@ static const int32_t V1_COMPRESSION_COOKIE = 0x1c849302;
static const int32_t V2_ENCODING_COOKIE = 0x1c849303;
static const int32_t V2_COMPRESSION_COOKIE = 0x1c849304;

int32_t get_cookie_base(int32_t cookie)
static int32_t get_cookie_base(int32_t cookie)
{
return (cookie & ~0xf0);
}

int32_t word_size_from_cookie(int32_t cookie)
static int32_t word_size_from_cookie(int32_t cookie)
{
return (cookie & 0xf0) >> 4;
}
Expand Down
6 changes: 3 additions & 3 deletions src/hdr_writer_reader_phaser.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,17 @@

#include "hdr_writer_reader_phaser.h"

int64_t _hdr_phaser_get_epoch(int64_t* field)
static int64_t _hdr_phaser_get_epoch(int64_t* field)
{
return __atomic_load_n(field, __ATOMIC_SEQ_CST);
}

void _hdr_phaser_set_epoch(int64_t* field, int64_t val)
static void _hdr_phaser_set_epoch(int64_t* field, int64_t val)
{
__atomic_store_n(field, val, __ATOMIC_SEQ_CST);
}

int64_t _hdr_phaser_reset_epoch(int64_t* field, int64_t initial_value)
static int64_t _hdr_phaser_reset_epoch(int64_t* field, int64_t initial_value)
{
return __atomic_exchange_n(field, initial_value, __ATOMIC_SEQ_CST);
}
Expand Down
2 changes: 1 addition & 1 deletion test/hdr_histogram_log_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -818,7 +818,7 @@ static struct mu_result all_tests()
mu_ok;
}

int hdr_histogram_log_run_tests()
static int hdr_histogram_log_run_tests()
{
struct mu_result result = all_tests();

Expand Down
8 changes: 1 addition & 7 deletions test/hdr_histogram_perf.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

#include "hdr_time.h"

struct timespec diff(struct timespec start, struct timespec end)
static struct timespec diff(struct timespec start, struct timespec end)
{
struct timespec temp;
if ((end.tv_nsec-start.tv_nsec) < 0)
Expand All @@ -29,12 +29,6 @@ struct timespec diff(struct timespec start, struct timespec end)
return temp;
}

void inc(struct hdr_histogram* h, int32_t index, int64_t value)
{
h->counts[index] += value;
h->total_count += value;
}

int main()
{
struct hdr_histogram* histogram;
Expand Down
8 changes: 4 additions & 4 deletions test/hdr_histogram_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@

#include "minunit.h"

bool compare_values(double a, double b, double variation)
static bool compare_values(double a, double b, double variation)
{
return compare_double(a, b, b * variation);
}

bool compare_percentile(int64_t a, double b, double variation)
static bool compare_percentile(int64_t a, double b, double variation)
{
return compare_values((double) a, b, variation);
// return fabs(a - b) <= b * variation;
Expand Down Expand Up @@ -425,7 +425,7 @@ static char* test_scaling_equivalence()
return 0;
}

char* test_out_of_range_values()
static char* test_out_of_range_values()
{
struct hdr_histogram *h;
hdr_init(1, 1000, 4, &h);
Expand Down Expand Up @@ -455,7 +455,7 @@ static struct mu_result all_tests()
mu_ok;
}

int hdr_histogram_run_tests()
static int hdr_histogram_run_tests()
{
struct mu_result result = all_tests();

Expand Down
4 changes: 2 additions & 2 deletions test/minunit.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ struct mu_result

extern int tests_run;

bool compare_double(double a, double b, double delta)
static bool compare_double(double a, double b, double delta)
{
if (fabs(a - b) < delta)
{
Expand All @@ -66,4 +66,4 @@ static bool compare_int64(int64_t a, int64_t b)
return false;
}

#endif
#endif

0 comments on commit 2fe887d

Please sign in to comment.