From 0e9ad62d5286534f419b70a840c5b0381f8f1313 Mon Sep 17 00:00:00 2001 From: Muhammed Uluyol Date: Fri, 16 Jul 2021 19:11:27 -0400 Subject: [PATCH 1/6] Avoid reading past the end of the input buffer The loop condition may read past the input buffer. Usually, this won't be a problem since the loop will terminate anyway. However, this could be a problem if the following byte is at an address that is not mapped, and it causes tools like ThreadSanitizer to complain. For the record: this bug was found using ThreadSanitizer. --- src/hdr_histogram.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hdr_histogram.c b/src/hdr_histogram.c index 5d1ca57..570e424 100644 --- a/src/hdr_histogram.c +++ b/src/hdr_histogram.c @@ -699,7 +699,7 @@ int hdr_value_at_percentiles(const struct hdr_histogram *h, const double *percen while (hdr_iter_next(&iter) && at_pos < length) { total += iter.count; - while (total >= values[at_pos] && at_pos < length) + while (at_pos < length && total >= values[at_pos]) { values[at_pos] = highest_equivalent_value(h, iter.value); at_pos++; From ceb59aa20acd582aa7287883003dada139b2d54e Mon Sep 17 00:00:00 2001 From: filipecosta90 Date: Mon, 9 Aug 2021 22:38:11 +0100 Subject: [PATCH 2/6] [perf] Reuse common computed values within highest_equivalent_value/lowest_equivalent_value/hdr_median_equivalent_value calls on hdr_next_non_equivalent_value() --- src/hdr_histogram.c | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/src/hdr_histogram.c b/src/hdr_histogram.c index 570e424..1591f27 100644 --- a/src/hdr_histogram.c +++ b/src/hdr_histogram.c @@ -222,6 +222,12 @@ int64_t hdr_size_of_equivalent_value_range(const struct hdr_histogram* h, int64_ return INT64_C(1) << (h->unit_magnitude + adjusted_bucket); } +int64_t hdr_size_of_equivalent_value_range_given_bucket_indices(const struct hdr_histogram* h, int64_t value, int32_t bucket_index, int32_t sub_bucket_index) +{ + const int32_t adjusted_bucket = (sub_bucket_index >= h->sub_bucket_count) ? (bucket_index + 1) : bucket_index; + return INT64_C(1) << (h->unit_magnitude + adjusted_bucket); +} + static int64_t lowest_equivalent_value(const struct hdr_histogram* h, int64_t value) { int32_t bucket_index = get_bucket_index(h, value); @@ -229,6 +235,12 @@ static int64_t lowest_equivalent_value(const struct hdr_histogram* h, int64_t va return value_from_index(bucket_index, sub_bucket_index, h->unit_magnitude); } +static int64_t lowest_equivalent_value_given_bucket_indices(const struct hdr_histogram* h, int64_t value, int32_t bucket_index, int32_t sub_bucket_index) +{ + return value_from_index(bucket_index, sub_bucket_index, h->unit_magnitude); +} + + int64_t hdr_next_non_equivalent_value(const struct hdr_histogram *h, int64_t value) { return lowest_equivalent_value(h, value) + hdr_size_of_equivalent_value_range(h, value); @@ -797,11 +809,15 @@ static bool move_next(struct hdr_iter* iter) iter->count = counts_get_normalised(iter->h, iter->counts_index); iter->cumulative_count += iter->count; - - iter->value = hdr_value_at_index(iter->h, iter->counts_index); - iter->highest_equivalent_value = highest_equivalent_value(iter->h, iter->value); - iter->lowest_equivalent_value = lowest_equivalent_value(iter->h, iter->value); - iter->median_equivalent_value = hdr_median_equivalent_value(iter->h, iter->value); + const int64_t value = hdr_value_at_index(iter->h, iter->counts_index); + const int32_t bucket_index = get_bucket_index(iter->h, value); + const int32_t sub_bucket_index = get_sub_bucket_index(value, bucket_index, iter->h->unit_magnitude); + const int64_t leq = lowest_equivalent_value_given_bucket_indices(iter->h, value, bucket_index, sub_bucket_index); + const int64_t size_of_equivalent_value_range = hdr_size_of_equivalent_value_range_given_bucket_indices(iter->h, value, bucket_index, sub_bucket_index); + iter->lowest_equivalent_value = leq; + iter->value = value; + iter->highest_equivalent_value = leq + size_of_equivalent_value_range - 1; + iter->median_equivalent_value = leq + (size_of_equivalent_value_range >> 1); return true; } From 3545c15f3f629222c23261b65477aa8f9e7b09aa Mon Sep 17 00:00:00 2001 From: filipecosta90 Date: Thu, 12 Aug 2021 13:38:45 +0100 Subject: [PATCH 3/6] [fix] Fixes per PR review: made hdr_size_of_equivalent_value_range_given_bucket_indices static --- src/hdr_histogram.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/hdr_histogram.c b/src/hdr_histogram.c index 1591f27..ad261c2 100644 --- a/src/hdr_histogram.c +++ b/src/hdr_histogram.c @@ -222,7 +222,7 @@ int64_t hdr_size_of_equivalent_value_range(const struct hdr_histogram* h, int64_ return INT64_C(1) << (h->unit_magnitude + adjusted_bucket); } -int64_t hdr_size_of_equivalent_value_range_given_bucket_indices(const struct hdr_histogram* h, int64_t value, int32_t bucket_index, int32_t sub_bucket_index) +static int64_t hdr_size_of_equivalent_value_range_given_bucket_indices(const struct hdr_histogram* h, int64_t value, int32_t bucket_index, int32_t sub_bucket_index) { const int32_t adjusted_bucket = (sub_bucket_index >= h->sub_bucket_count) ? (bucket_index + 1) : bucket_index; return INT64_C(1) << (h->unit_magnitude + adjusted_bucket); @@ -240,7 +240,6 @@ static int64_t lowest_equivalent_value_given_bucket_indices(const struct hdr_his return value_from_index(bucket_index, sub_bucket_index, h->unit_magnitude); } - int64_t hdr_next_non_equivalent_value(const struct hdr_histogram *h, int64_t value) { return lowest_equivalent_value(h, value) + hdr_size_of_equivalent_value_range(h, value); From 7615a45ed0975d76dced55eaeac4ad13b150a983 Mon Sep 17 00:00:00 2001 From: Jon Olsson Date: Thu, 13 Jan 2022 08:05:36 +0100 Subject: [PATCH 4/6] Spelling fixes --- src/hdr_histogram.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/hdr_histogram.h b/src/hdr_histogram.h index d6d6f6a..59ffe54 100644 --- a/src/hdr_histogram.h +++ b/src/hdr_histogram.h @@ -159,10 +159,10 @@ bool hdr_record_values_atomic(struct hdr_histogram* h, int64_t value, int64_t co * Record a value in the histogram and backfill based on an expected interval. * * Records a value in the histogram, will round this value of to a precision at or better - * than the significant_figure specified at contruction time. This is specifically used + * than the significant_figure specified at construction time. This is specifically used * for recording latency. If the value is larger than the expected_interval then the * latency recording system has experienced co-ordinated omission. This method fills in the - * values that would have occured had the client providing the load not been blocked. + * values that would have occurred had the client providing the load not been blocked. * @param h "This" pointer * @param value Value to add to the histogram @@ -170,16 +170,16 @@ bool hdr_record_values_atomic(struct hdr_histogram* h, int64_t value, int64_t co * @return false if the value is larger than the highest_trackable_value and can't be recorded, * true otherwise. */ -bool hdr_record_corrected_value(struct hdr_histogram* h, int64_t value, int64_t expexcted_interval); +bool hdr_record_corrected_value(struct hdr_histogram* h, int64_t value, int64_t expected_interval); /** * Record a value in the histogram and backfill based on an expected interval. * * Records a value in the histogram, will round this value of to a precision at or better - * than the significant_figure specified at contruction time. This is specifically used + * than the significant_figure specified at construction time. This is specifically used * for recording latency. If the value is larger than the expected_interval then the * latency recording system has experienced co-ordinated omission. This method fills in the - * values that would have occured had the client providing the load not been blocked. + * values that would have occurred had the client providing the load not been blocked. * * Will record this value atomically, however the whole structure may appear inconsistent * when read concurrently with this update. Do NOT mix calls to this method with calls @@ -191,7 +191,7 @@ bool hdr_record_corrected_value(struct hdr_histogram* h, int64_t value, int64_t * @return false if the value is larger than the highest_trackable_value and can't be recorded, * true otherwise. */ -bool hdr_record_corrected_value_atomic(struct hdr_histogram* h, int64_t value, int64_t expexcted_interval); +bool hdr_record_corrected_value_atomic(struct hdr_histogram* h, int64_t value, int64_t expected_interval); /** * Record a value in the histogram 'count' times. Applies the same correcting logic @@ -504,7 +504,7 @@ int64_t hdr_next_non_equivalent_value(const struct hdr_histogram* h, int64_t val int64_t hdr_median_equivalent_value(const struct hdr_histogram* h, int64_t value); /** - * Used to reset counters after importing data manuallying into the histogram, used by the logging code + * Used to reset counters after importing data manually into the histogram, used by the logging code * and other custom serialisation tools. */ void hdr_reset_internal_counters(struct hdr_histogram* h); From 4d73ff0e63aa8bbf59ff3351c4969da19502b561 Mon Sep 17 00:00:00 2001 From: Tristan Partin Date: Wed, 23 Feb 2022 19:20:55 -0600 Subject: [PATCH 5/6] Mirror include directory in source tree The include files now sit in include/hdr like they are when they are installed. --- CMakeLists.txt | 1 + examples/hdr_decoder.c | 8 ++++---- examples/hiccup.c | 14 ++++++------- include/CMakeLists.txt | 11 ++++++++++ {src => include/hdr}/hdr_histogram.h | 0 {src => include/hdr}/hdr_histogram_log.h | 4 ++-- {src => include/hdr}/hdr_interval_recorder.h | 6 +++--- {src => include/hdr}/hdr_thread.h | 0 {src => include/hdr}/hdr_time.h | 0 .../hdr}/hdr_writer_reader_phaser.h | 0 src/CMakeLists.txt | 20 +++++-------------- src/hdr_histogram.c | 2 +- src/hdr_histogram_log.c | 6 +++--- src/hdr_interval_recorder.c | 2 +- src/hdr_tests.h | 2 +- src/hdr_thread.c | 2 +- src/hdr_time.c | 5 +---- src/hdr_writer_reader_phaser.c | 7 +++---- test/CMakeLists.txt | 3 +++ test/hdr_histogram_atomic_concurrency_test.c | 4 ++-- test/hdr_histogram_atomic_test.c | 4 ++-- test/hdr_histogram_log_test.c | 8 ++++---- test/hdr_histogram_perf.c | 4 ++-- test/hdr_histogram_test.c | 4 ++-- 24 files changed, 59 insertions(+), 58 deletions(-) create mode 100644 include/CMakeLists.txt rename {src => include/hdr}/hdr_histogram.h (100%) rename {src => include/hdr}/hdr_histogram_log.h (99%) rename {src => include/hdr}/hdr_interval_recorder.h (97%) rename {src => include/hdr}/hdr_thread.h (100%) rename {src => include/hdr}/hdr_time.h (100%) rename {src => include/hdr}/hdr_writer_reader_phaser.h (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6167922..275b450 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -49,6 +49,7 @@ if (${HDR_LOG_REQUIRED} AND NOT HDR_LOG_ENABLED) message(SEND_ERROR "HDR_LOG_REQUIRED=ON and unable to find zlib library") endif() +add_subdirectory(include) add_subdirectory(src) option(HDR_HISTOGRAM_BUILD_PROGRAMS "Build tests and examples" ON) diff --git a/examples/hdr_decoder.c b/examples/hdr_decoder.c index 4360e70..1432943 100644 --- a/examples/hdr_decoder.c +++ b/examples/hdr_decoder.c @@ -10,9 +10,9 @@ #include #include #include - -#include -#include + +#include +#include #if defined(_MSC_VER) #pragma warning(push) @@ -71,7 +71,7 @@ int main(int argc, char** argv) { fprintf(stderr, "Failed to print histogram: %s\n", hdr_strerror(rc)); return -1; - } + } } return 0; diff --git a/examples/hiccup.c b/examples/hiccup.c index 123e2f6..6277697 100644 --- a/examples/hiccup.c +++ b/examples/hiccup.c @@ -17,10 +17,10 @@ #include #include -#include -#include -#include -#include +#include +#include +#include +#include static int64_t diff(struct timespec t0, struct timespec t1) { @@ -36,7 +36,7 @@ static void* record_hiccups(void* thread_context) struct pollfd fd; struct timespec t0; struct timespec t1; - struct itimerspec timeout; + struct itimerspec timeout; struct hdr_interval_recorder* r = thread_context; memset(&fd, 0, sizeof(struct pollfd)); @@ -140,7 +140,7 @@ int main(int argc, char** argv) if (!output) { fprintf( - stderr, "Failed to open/create file: %s, %s", + stderr, "Failed to open/create file: %s, %s", config.filename, strerror(errno)); return -1; @@ -167,7 +167,7 @@ int main(int argc, char** argv) #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wmissing-noreturn" while (true) - { + { sleep(config.interval); inactive = hdr_interval_recorder_sample_and_recycle(&recorder, inactive); diff --git a/include/CMakeLists.txt b/include/CMakeLists.txt new file mode 100644 index 0000000..6131e6e --- /dev/null +++ b/include/CMakeLists.txt @@ -0,0 +1,11 @@ +set(HDR_HISTOGRAM_PUBLIC_HEADERS + hdr/hdr_histogram.h + hdr/hdr_histogram_log.h + hdr/hdr_interval_recorder.h + hdr/hdr_thread.h + hdr/hdr_time.h + hdr/hdr_writer_reader_phaser.h) + +install( + FILES ${HDR_HISTOGRAM_PUBLIC_HEADERS} + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/hdr) diff --git a/src/hdr_histogram.h b/include/hdr/hdr_histogram.h similarity index 100% rename from src/hdr_histogram.h rename to include/hdr/hdr_histogram.h diff --git a/src/hdr_histogram_log.h b/include/hdr/hdr_histogram_log.h similarity index 99% rename from src/hdr_histogram_log.h rename to include/hdr/hdr_histogram_log.h index 141bbd6..c1842b2 100644 --- a/src/hdr_histogram_log.h +++ b/include/hdr/hdr_histogram_log.h @@ -27,8 +27,8 @@ #include #include -#include "hdr_time.h" -#include "hdr_histogram.h" +#include +#include #ifdef __cplusplus extern "C" { diff --git a/src/hdr_interval_recorder.h b/include/hdr/hdr_interval_recorder.h similarity index 97% rename from src/hdr_interval_recorder.h rename to include/hdr/hdr_interval_recorder.h index 91ceaec..02091ac 100644 --- a/src/hdr_interval_recorder.h +++ b/include/hdr/hdr_interval_recorder.h @@ -7,8 +7,8 @@ #ifndef HDR_INTERVAL_RECORDER_H #define HDR_INTERVAL_RECORDER_H 1 -#include "hdr_writer_reader_phaser.h" -#include "hdr_histogram.h" +#include +#include HDR_ALIGN_PREFIX(8) struct hdr_interval_recorder @@ -16,7 +16,7 @@ struct hdr_interval_recorder struct hdr_histogram* active; struct hdr_histogram* inactive; struct hdr_writer_reader_phaser phaser; -} +} HDR_ALIGN_SUFFIX(8); #ifdef __cplusplus diff --git a/src/hdr_thread.h b/include/hdr/hdr_thread.h similarity index 100% rename from src/hdr_thread.h rename to include/hdr/hdr_thread.h diff --git a/src/hdr_time.h b/include/hdr/hdr_time.h similarity index 100% rename from src/hdr_time.h rename to include/hdr/hdr_time.h diff --git a/src/hdr_writer_reader_phaser.h b/include/hdr/hdr_writer_reader_phaser.h similarity index 100% rename from src/hdr_writer_reader_phaser.h rename to include/hdr/hdr_writer_reader_phaser.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index ba7f2dd..55f0947 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -27,19 +27,12 @@ set(HDR_HISTOGRAM_PRIVATE_HEADERS hdr_tests.h hdr_malloc.h) -set(HDR_HISTOGRAM_PUBLIC_HEADERS - hdr_histogram.h - hdr_histogram_log.h - hdr_interval_recorder.h - hdr_thread.h - hdr_time.h - hdr_writer_reader_phaser.h) - function(hdr_histogram_add_library NAME LIBRARY_TYPE DO_INSTALL) add_library(${NAME} ${LIBRARY_TYPE} ${HDR_HISTOGRAM_SOURCES} ${HDR_HISTOGRAM_PRIVATE_HEADERS} ${HDR_HISTOGRAM_PUBLIC_HEADERS}) + target_link_libraries(${NAME} PRIVATE # ZLIB::ZLIB @@ -49,10 +42,11 @@ function(hdr_histogram_add_library NAME LIBRARY_TYPE DO_INSTALL) $<$:m> $<$:rt> $<$:ws2_32>) - target_include_directories(${NAME} + target_include_directories( + ${NAME} PUBLIC - $ - $) + $ + $) if(DO_INSTALL) install( TARGETS ${NAME} @@ -77,7 +71,3 @@ option(HDR_HISTOGRAM_INSTALL_STATIC "Install static library" ON) if(HDR_HISTOGRAM_BUILD_STATIC) hdr_histogram_add_library(hdr_histogram_static STATIC ${HDR_HISTOGRAM_INSTALL_STATIC}) endif() - -install( - FILES ${HDR_HISTOGRAM_PUBLIC_HEADERS} - DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/hdr) diff --git a/src/hdr_histogram.c b/src/hdr_histogram.c index ad261c2..3ebe74a 100644 --- a/src/hdr_histogram.c +++ b/src/hdr_histogram.c @@ -13,7 +13,7 @@ #include #include -#include "hdr_histogram.h" +#include #include "hdr_tests.h" #include "hdr_atomic.h" diff --git a/src/hdr_histogram_log.c b/src/hdr_histogram_log.c index 0b45e65..06ab81a 100644 --- a/src/hdr_histogram_log.c +++ b/src/hdr_histogram_log.c @@ -17,9 +17,9 @@ #include #include +#include +#include #include "hdr_encoding.h" -#include "hdr_histogram.h" -#include "hdr_histogram_log.h" #include "hdr_tests.h" #if defined(_MSC_VER) @@ -120,7 +120,7 @@ union uint64_dbl_cvt static double int64_bits_to_double(int64_t i) { union uint64_dbl_cvt x; - + x.l = (uint64_t) i; return x.d; } diff --git a/src/hdr_interval_recorder.c b/src/hdr_interval_recorder.c index d44369d..151e518 100644 --- a/src/hdr_interval_recorder.c +++ b/src/hdr_interval_recorder.c @@ -4,8 +4,8 @@ * as explained at http://creativecommons.org/publicdomain/zero/1.0/ */ +#include #include "hdr_atomic.h" -#include "hdr_interval_recorder.h" #ifndef HDR_MALLOC_INCLUDE #define HDR_MALLOC_INCLUDE "hdr_malloc.h" diff --git a/src/hdr_tests.h b/src/hdr_tests.h index c016d3a..5cc65a0 100644 --- a/src/hdr_tests.h +++ b/src/hdr_tests.h @@ -3,7 +3,7 @@ /* These are functions used in tests and are not intended for normal usage. */ -#include "hdr_histogram.h" +#include #ifdef __cplusplus extern "C" { diff --git a/src/hdr_thread.c b/src/hdr_thread.c index 7d1a07d..f92f576 100644 --- a/src/hdr_thread.c +++ b/src/hdr_thread.c @@ -5,7 +5,7 @@ */ #include -#include "hdr_thread.h" +#include #ifndef HDR_MALLOC_INCLUDE #define HDR_MALLOC_INCLUDE "hdr_malloc.h" diff --git a/src/hdr_time.c b/src/hdr_time.c index 0967d51..0a6f081 100644 --- a/src/hdr_time.c +++ b/src/hdr_time.c @@ -4,7 +4,7 @@ * as explained at http://creativecommons.org/publicdomain/zero/1.0/ */ -#include "hdr_time.h" +#include #if defined(_WIN32) || defined(_WIN64) @@ -93,6 +93,3 @@ void hdr_timespec_from_double(hdr_timespec* t, double value) t->tv_sec = seconds; t->tv_nsec = milliseconds * 1000000; } - - - diff --git a/src/hdr_writer_reader_phaser.c b/src/hdr_writer_reader_phaser.c index fb49047..2d9e965 100644 --- a/src/hdr_writer_reader_phaser.c +++ b/src/hdr_writer_reader_phaser.c @@ -8,10 +8,9 @@ #include #include +#include +#include #include "hdr_atomic.h" -#include "hdr_thread.h" - -#include "hdr_writer_reader_phaser.h" #ifndef HDR_MALLOC_INCLUDE #define HDR_MALLOC_INCLUDE "hdr_malloc.h" @@ -77,7 +76,7 @@ int64_t hdr_phaser_writer_enter(struct hdr_writer_reader_phaser* p) void hdr_phaser_writer_exit( struct hdr_writer_reader_phaser* p, int64_t critical_value_at_enter) { - int64_t* end_epoch = + int64_t* end_epoch = (critical_value_at_enter < 0) ? &p->odd_end_epoch : &p->even_end_epoch; hdr_atomic_add_fetch_64(end_epoch, 1); } diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index f795e33..3cb8643 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -49,6 +49,9 @@ function(hdr_histogram_add_test_executable NAME) target_link_libraries(${NAME} PRIVATE hdr_histogram_static) + target_include_directories(${NAME} + PRIVATE + ${PROJECT_SOURCE_DIR}/src) install( TARGETS ${NAME} DESTINATION ${CMAKE_INSTALL_BINDIR}) diff --git a/test/hdr_histogram_atomic_concurrency_test.c b/test/hdr_histogram_atomic_concurrency_test.c index d18a881..e1cad52 100644 --- a/test/hdr_histogram_atomic_concurrency_test.c +++ b/test/hdr_histogram_atomic_concurrency_test.c @@ -10,7 +10,7 @@ #include #include -#include +#include #include #include "minunit.h" @@ -60,7 +60,7 @@ static char* test_recording_concurrently() { values[i] = rand() % 20000; } - + for (i = 0; i < value_count; i++) { hdr_record_value(expected_histogram, values[i]); diff --git a/test/hdr_histogram_atomic_test.c b/test/hdr_histogram_atomic_test.c index 629ae39..a21d126 100644 --- a/test/hdr_histogram_atomic_test.c +++ b/test/hdr_histogram_atomic_test.c @@ -10,8 +10,8 @@ #include #include -#include -#include +#include +#include #include "minunit.h" #include "hdr_test_util.h" diff --git a/test/hdr_histogram_log_test.c b/test/hdr_histogram_log_test.c index a17b4df..1b7e3e7 100644 --- a/test/hdr_histogram_log_test.c +++ b/test/hdr_histogram_log_test.c @@ -14,10 +14,10 @@ #include #include -#include "hdr_time.h" -#include -#include -#include +#include +#include +#include +#include "hdr_encoding.h" #include "minunit.h" #if defined(_MSC_VER) diff --git a/test/hdr_histogram_perf.c b/test/hdr_histogram_perf.c index 1721402..9d7d4aa 100644 --- a/test/hdr_histogram_perf.c +++ b/test/hdr_histogram_perf.c @@ -8,10 +8,10 @@ #include #include -#include +#include +#include #include -#include "hdr_time.h" #if defined(_WIN32) || defined(_WIN64) || defined(__CYGWIN__) diff --git a/test/hdr_histogram_test.c b/test/hdr_histogram_test.c index 6498eef..d473a3b 100644 --- a/test/hdr_histogram_test.c +++ b/test/hdr_histogram_test.c @@ -10,8 +10,8 @@ #include #include -#include -#include +#include +#include #include "minunit.h" #include "hdr_test_util.h" From 3b43ad846e0355188cbb2f693617d55a0c691532 Mon Sep 17 00:00:00 2001 From: Tristan Partin Date: Wed, 23 Feb 2022 19:41:32 -0600 Subject: [PATCH 6/6] Only install export when either library is actually being installed --- CMakeLists.txt | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 275b450..8a10071 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -71,10 +71,12 @@ configure_file( config.cmake.in ${PROJECT_NAME}-config.cmake @ONLY) -install( - EXPORT ${PROJECT_NAME}-targets - DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME} - NAMESPACE ${PROJECT_NAME}::) +if(HDR_HISTOGRAM_INSTALL_SHARED OR HDR_HISTOGRAM_INSTALL_STATIC) + install( + EXPORT ${PROJECT_NAME}-targets + DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME} + NAMESPACE ${PROJECT_NAME}::) +endif() install( FILES ${PROJECT_BINARY_DIR}/${PROJECT_NAME}-config.cmake