Skip to content

Commit 75b3818

Browse files
committed
vendor HdrHistogram_c
1 parent e5ea621 commit 75b3818

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+9125
-2
lines changed

lib/dune

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,19 @@
11
(library
22
(name hdr_histogram)
33
(public_name hdr_histogram)
4+
(install_c_headers hdr_histogram)
5+
(foreign_archives hdr_histogram)
46
; ctypes backward compatibility shims warn sometimes; suppress them
57
(flags (:standard -w -9-27))
68
(ctypes
79
(external_library_name hdr_histogram)
8-
(build_flags_resolver pkg_config)
9-
(headers (include "hdr/hdr_histogram.h"))
10+
(deps hdr_histogram.h dllhdr_histogram.so libhdr_histogram.a)
11+
(build_flags_resolver
12+
(vendored
13+
; hack: multiple -I directives to work around cc commands being run from
14+
; different relative directories. Is there a cleaner way to do this?
15+
(c_flags ("-Ilib" "-I."))))
16+
(headers (include "hdr_histogram.h"))
1017
(type_description
1118
(instance Type)
1219
(functor Type_description))
@@ -16,3 +23,21 @@
1623
(functor Function_description))
1724
(generated_types Types_generated)
1825
(generated_entry_point C)))
26+
27+
(data_only_dirs libhdr_histogram)
28+
29+
(rule
30+
(deps (source_tree libhdr_histogram))
31+
(targets dllhdr_histogram.so libhdr_histogram.a hdr_histogram.h)
32+
(action (no-infer
33+
(progn (chdir libhdr_histogram
34+
(progn (run mkdir -p _build)
35+
(chdir _build
36+
(progn (run cmake ..)
37+
(run make)))))
38+
(copy libhdr_histogram/_build/src/libhdr_histogram_static.a
39+
libhdr_histogram.a)
40+
(copy libhdr_histogram/_build/src/libhdr_histogram.so
41+
dllhdr_histogram.so)
42+
(copy libhdr_histogram/include/hdr/hdr_histogram.h
43+
hdr_histogram.h)))))
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
name: CI
2+
on: [push, pull_request]
3+
jobs:
4+
build:
5+
runs-on: ${{ matrix.runner }}
6+
strategy:
7+
matrix:
8+
os: [linux, windows, macos]
9+
build_type: [Debug, RelWithDebInfo]
10+
arch: [x86, x64]
11+
cmake: [minimal, latest]
12+
hdr_log_required: [ON, DISABLED]
13+
exclude:
14+
- os: linux
15+
arch: x86
16+
- os: windows
17+
cmake: minimal
18+
- os: windows
19+
hdr_log_required: DISABLED
20+
- os: macos
21+
arch: x86
22+
- os: macos
23+
cmake: minimal
24+
- os: macos
25+
hdr_log_required: DISABLED
26+
include:
27+
- cmake: minimal
28+
cmake_url_part: v3.12/cmake-3.12.4
29+
- cmake: latest
30+
cmake_url_part: v3.17/cmake-3.17.3
31+
- os: linux
32+
runner: ubuntu-latest
33+
- os: windows
34+
runner: windows-latest
35+
- os: windows
36+
arch: x86
37+
cmake_args: -A Win32 -DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake
38+
- os: windows
39+
arch: x64
40+
cmake_args: -A x64 -DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake
41+
- os: macos
42+
runner: macos-latest
43+
env:
44+
VCPKG_DEFAULT_TRIPLET: ${{ matrix.arch }}-${{ matrix.os }}
45+
VCPKG_TARGET_ARCHITECTURE: ${{ matrix.arch }}
46+
VCPKG_LIBRARY_LINKAGE: static
47+
steps:
48+
- name: Checkout
49+
uses: actions/checkout@v1
50+
with:
51+
submodules: recursive
52+
- name: Install dependencies (linux)
53+
if: matrix.os == 'linux'
54+
run: |
55+
sudo apt-get install -y zlib1g-dev
56+
wget --no-check-certificate https://cmake.org/files/${{ matrix.cmake_url_part }}-Linux-x86_64.tar.gz -O /tmp/cmake.tar.gz
57+
sudo tar xf /tmp/cmake.tar.gz -C /usr/local --strip-components 1
58+
- name: Install dependencies (windows)
59+
if: matrix.os == 'windows'
60+
run: vcpkg install zlib
61+
- name: CMake version
62+
run: |
63+
cmake --version
64+
ctest --version
65+
cpack --version
66+
- name: Configure
67+
run: cmake -E make_directory _build && cmake -E chdir _build cmake .. -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -DHDR_LOG_REQUIRED=${{ matrix.hdr_log_required }} ${{ matrix.cmake_args }}
68+
- name: Build
69+
run: cmake --build _build --config ${{ matrix.build_type }}
70+
- name: Test
71+
run: cmake -E chdir _build ctest --build-config ${{ matrix.build_type }} --output-in-failure

lib/libhdr_histogram/.gitignore

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
target
2+
.idea
3+
out
4+
gh-pages
5+
HdrHistogram.iml
6+
.classpath
7+
.project
8+
.settings
9+
release.properties
10+
install_manifest.txt
11+
/bin
12+
alltests
13+
format_example
14+
*.a
15+
*.iml
16+
.sconsign.dblite
17+
*.o
18+
*.os
19+
.DS_Store
20+
build
21+
CMakeCache.txt
22+
CMakeFiles/
23+
CPackConfig.cmake
24+
CPackSourceConfig.cmake
25+
CTestTestfile.cmake
26+
Makefile
27+
Testing/
28+
cmake_install.cmake
29+
examples/CMakeFiles/
30+
examples/CTestTestfile.cmake
31+
examples/Makefile
32+
examples/cmake_install.cmake
33+
examples/hdr_decoder
34+
examples/hiccup
35+
src/CMakeFiles/
36+
src/CTestTestfile.cmake
37+
src/Makefile
38+
src/cmake_install.cmake
39+
src/libhdr_histogram.so
40+
src/libhdr_histogram.so.*
41+
test/CMakeFiles/
42+
test/CTestTestfile.cmake
43+
test/Makefile
44+
test/cmake_install.cmake
45+
test/hdr_atomic_test
46+
test/hdr_dbl_histogram_test
47+
test/hdr_histogram_atomic_concurrency_test
48+
test/hdr_histogram_atomic_test
49+
test/hdr_histogram_log_test
50+
test/hdr_histogram_test
51+
test/perftest
52+
.gdb_history
53+
debug
54+
cmake-build-debug
55+
/build-afl

lib/libhdr_histogram/.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "test/vendor/google/benchmark"]
2+
path = test/vendor/google/benchmark
3+
url = https://github.com/google/benchmark.git
Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
cmake_minimum_required(VERSION 3.12)
2+
3+
project(hdr_histogram
4+
VERSION 0.11.4
5+
LANGUAGES C
6+
DESCRIPTION "C port of the HdrHistogram"
7+
HOMEPAGE_URL "http://hdrhistogram.github.io/HdrHistogram/")
8+
9+
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
10+
11+
include(GNUInstallDirs)
12+
include(CMakePackageConfigHelpers)
13+
14+
# Follow all steps below in order to calculate new ABI version when updating the library
15+
# NOTE: THIS IS UNRELATED to the actual project version
16+
#
17+
# 1. If the library source code has changed at all since the last update, then increment revision
18+
# 2. If any interfaces have been added, removed, or changed since the last update, increment current and set revision to 0.
19+
# 3. If any interfaces have been added since the last public release, then increment age.
20+
# 4. If any interfaces have been removed since the last public release, then set age to 0.
21+
22+
set(HDR_SOVERSION_CURRENT 6)
23+
set(HDR_SOVERSION_AGE 1)
24+
set(HDR_SOVERSION_REVISION 1)
25+
26+
set(HDR_VERSION ${HDR_SOVERSION_CURRENT}.${HDR_SOVERSION_AGE}.${HDR_SOVERSION_REVISION})
27+
set(HDR_SOVERSION ${HDR_SOVERSION_CURRENT})
28+
option(HDR_LOG_REQUIRED "HDR Logging component required" ON)
29+
30+
set(CMAKE_C_STANDARD 99)
31+
set(CMAKE_C_STANDARD_REQUIRED ON)
32+
set(CMAKE_C_EXTENSIONS OFF)
33+
34+
set(CMAKE_CXX_STANDARD 11)
35+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
36+
set(CMAKE_CXX_EXTENSIONS OFF)
37+
38+
set(CMAKE_SHARED_LIBRARY_SUFFIX .so)
39+
40+
if(UNIX)
41+
add_compile_options(
42+
-Wall
43+
-Wno-unknown-pragmas
44+
-Wextra
45+
-Wshadow
46+
-Winit-self
47+
-Wpedantic
48+
$<$<COMPILE_LANGUAGE:C>:-Wmissing-prototypes>)
49+
add_definitions(-D_GNU_SOURCE)
50+
endif()
51+
52+
find_package(ZLIB)
53+
find_package(Threads REQUIRED)
54+
55+
if (HDR_LOG_REQUIRED STREQUAL "DISABLED")
56+
set(HDR_LOG_ENABLED "FALSE")
57+
else()
58+
set(HDR_LOG_ENABLED ${ZLIB_FOUND})
59+
if (${HDR_LOG_REQUIRED} AND NOT HDR_LOG_ENABLED)
60+
message(SEND_ERROR "HDR_LOG_REQUIRED=ON and unable to find zlib library")
61+
endif()
62+
endif()
63+
64+
add_subdirectory(include)
65+
add_subdirectory(src)
66+
67+
option(HDR_HISTOGRAM_BUILD_PROGRAMS "Build tests and examples" ON)
68+
if(HDR_HISTOGRAM_BUILD_PROGRAMS)
69+
include(CTest)
70+
71+
if(BUILD_TESTING)
72+
add_subdirectory(test)
73+
endif()
74+
75+
add_subdirectory(examples)
76+
endif()
77+
78+
write_basic_package_version_file(
79+
${PROJECT_BINARY_DIR}/${PROJECT_NAME}-config-version.cmake
80+
VERSION ${PROJECT_VERSION}
81+
COMPATIBILITY AnyNewerVersion)
82+
configure_file(
83+
config.cmake.in
84+
${PROJECT_NAME}-config.cmake
85+
@ONLY)
86+
if(HDR_HISTOGRAM_INSTALL_SHARED OR HDR_HISTOGRAM_INSTALL_STATIC)
87+
install(
88+
EXPORT ${PROJECT_NAME}-targets
89+
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}
90+
NAMESPACE ${PROJECT_NAME}::)
91+
endif()
92+
install(
93+
FILES
94+
${PROJECT_BINARY_DIR}/${PROJECT_NAME}-config.cmake
95+
${PROJECT_BINARY_DIR}/${PROJECT_NAME}-config-version.cmake
96+
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME})
97+
98+
set(CPACK_GENERATOR "TGZ")
99+
include(CPack)
100+
101+
include(JoinPaths)
102+
103+
join_paths(includedir_for_pc_file "\${prefix}" "${CMAKE_INSTALL_INCLUDEDIR}")
104+
join_paths(libdir_for_pc_file "\${prefix}" "${CMAKE_INSTALL_LIBDIR}")
105+
106+
if(${ZLIB_FOUND})
107+
set(PC_REQUIRES_PRIVATE_ZLIB "zlib")
108+
else()
109+
set(PC_REQUIRES_PRIVATE_ZLIB "")
110+
endif()
111+
configure_file(
112+
${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}.pc.in
113+
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc
114+
@ONLY
115+
)
116+
install(
117+
FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc
118+
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig
119+
)

0 commit comments

Comments
 (0)