From 39ea079034bbf121ee9fce26c4e552828975271e Mon Sep 17 00:00:00 2001 From: Ivan Lezhankin Date: Mon, 17 Feb 2020 17:27:09 +0300 Subject: [PATCH] More clean-up --- CMakeLists.txt | 1 - base/CMakeLists.txt | 4 -- base/common/CMakeLists.txt | 14 +---- base/common/LineReader.cpp | 2 +- base/common/ReplxxLineReader.cpp | 2 +- base/common/apple_rt.cpp | 52 ------------------- base/common/shift10.cpp | 3 +- base/common/time.h | 7 +++ base/daemon/include/daemon/BaseDaemon.h | 2 +- base/port/clock.h | 49 ----------------- base/port/ssize_t.h | 8 --- base/port/unistd.h | 11 ---- cmake/find/rt.cmake | 10 ---- dbms/CMakeLists.txt | 7 --- dbms/programs/benchmark/Benchmark.cpp | 2 +- .../performance-test/PerformanceTestSuite.cpp | 2 +- dbms/src/Common/ShellCommand.cpp | 2 +- dbms/src/Common/Stopwatch.h | 6 +-- dbms/src/Common/Throttler.h | 2 - dbms/src/Common/ZooKeeper/ZooKeeper.h | 2 +- .../ZooKeeper/tests/zkutil_test_commands.cpp | 2 +- dbms/src/Common/randomSeed.cpp | 3 +- dbms/src/Common/tests/Random.cpp | 1 - dbms/src/Common/tests/compact_array.cpp | 2 +- dbms/src/Common/tests/int_hashes_perf.cpp | 5 +- .../Compression/CachedCompressedReadBuffer.h | 1 - .../CompressedReadBufferFromFile.h | 1 - dbms/src/IO/ReadBufferFromFileBase.h | 15 +++--- dbms/src/IO/ReadBufferFromFileDescriptor.h | 4 +- dbms/src/IO/WriteBufferFromFileDescriptor.cpp | 2 +- .../tests/gtest_aio_seek_back_after_eof.cpp | 2 +- dbms/src/IO/tests/read_buffer_aio.cpp | 3 +- dbms/src/Interpreters/ClientInfo.cpp | 2 +- dbms/src/Interpreters/tests/users.cpp | 2 +- .../Formats/Impl/PrettyBlockOutputFormat.cpp | 2 +- dbms/src/Storages/MergeTree/MergeTreeReader.h | 1 - .../tests/remove_symlink_directory.cpp | 2 +- utils/iotest/iotest.cpp | 28 +++++----- utils/iotest/iotest_aio.cpp | 2 +- utils/iotest/iotest_nonblock.cpp | 36 +++++++------ 40 files changed, 77 insertions(+), 227 deletions(-) delete mode 100644 base/common/apple_rt.cpp create mode 100644 base/common/time.h delete mode 100644 base/port/clock.h delete mode 100644 base/port/ssize_t.h delete mode 100644 base/port/unistd.h delete mode 100644 cmake/find/rt.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 436e2cec6d8..d2cb6154ee0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -330,7 +330,6 @@ include (cmake/find/poco.cmake) include (cmake/find/lz4.cmake) include (cmake/find/xxhash.cmake) include (cmake/find/sparsehash.cmake) -include (cmake/find/rt.cmake) include (cmake/find/execinfo.cmake) include (cmake/find/re2.cmake) include (cmake/find/libgsasl.cmake) diff --git a/base/CMakeLists.txt b/base/CMakeLists.txt index cca578815e0..65593f70a95 100644 --- a/base/CMakeLists.txt +++ b/base/CMakeLists.txt @@ -1,7 +1,3 @@ -if (USE_DEBUG_HELPERS) - set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -include ${CMAKE_CURRENT_SOURCE_DIR}/common/iostream_debug_helpers.h") -endif () - add_subdirectory (common) add_subdirectory (loggers) add_subdirectory (daemon) diff --git a/base/common/CMakeLists.txt b/base/common/CMakeLists.txt index 32aa25e40ea..cce3a28e582 100644 --- a/base/common/CMakeLists.txt +++ b/base/common/CMakeLists.txt @@ -1,11 +1,5 @@ configure_file (config_common.h.in config_common.h) -add_library(apple_rt apple_rt.cpp) -target_include_directories(apple_rt PRIVATE ..) # TODO: replace with proper header-only target. -if (DEFINED APPLE_HAVE_CLOCK_GETTIME) - target_compile_definitions(apple_rt PUBLIC -DAPPLE_HAVE_CLOCK_GETTIME=${APPLE_HAVE_CLOCK_GETTIME}) -endif () - set (SRCS argsToConfig.cpp coverage.cpp @@ -36,7 +30,7 @@ add_library (common ${SRCS}) target_include_directories(common PUBLIC .. ${CMAKE_CURRENT_BINARY_DIR}/..) if (USE_INTERNAL_MEMCPY) - set (MEMCPY_LIBRARIES memcpy) + target_link_libraries (common PRIVATE memcpy) endif () if(CCTZ_INCLUDE_DIR) @@ -63,14 +57,8 @@ target_link_libraries (common ${Poco_Foundation_LIBRARY} ${CITYHASH_LIBRARIES} ${Boost_SYSTEM_LIBRARY} - PRIVATE - ${MEMCPY_LIBRARIES} ) -if (RT_LIBRARY) - target_link_libraries (common PRIVATE ${RT_LIBRARY}) -endif () - if (ENABLE_TESTS) add_subdirectory (tests) endif () diff --git a/base/common/LineReader.cpp b/base/common/LineReader.cpp index 22e0019803d..9dfefcea01f 100644 --- a/base/common/LineReader.cpp +++ b/base/common/LineReader.cpp @@ -3,8 +3,8 @@ #include #include -#include #include +#include #ifdef OS_LINUX /// We can detect if code is linked with one or another readline variants or open the library dynamically. diff --git a/base/common/ReplxxLineReader.cpp b/base/common/ReplxxLineReader.cpp index 044ea05413d..6a0956fb36a 100644 --- a/base/common/ReplxxLineReader.cpp +++ b/base/common/ReplxxLineReader.cpp @@ -1,8 +1,8 @@ #include #include -#include #include +#include namespace { diff --git a/base/common/apple_rt.cpp b/base/common/apple_rt.cpp deleted file mode 100644 index cf260cce604..00000000000 --- a/base/common/apple_rt.cpp +++ /dev/null @@ -1,52 +0,0 @@ -/** Allows to build on MacOS X - * - * Highly experimental, not recommended, disabled by default. - * - * To use, include this file with -include compiler parameter. - */ - -#include - -#ifdef __APPLE__ -#if !APPLE_HAVE_CLOCK_GETTIME - -#include -#include -#include -#include -#include -#include - - -int clock_gettime_thread(timespec *spec) { - thread_port_t thread = mach_thread_self(); - - mach_msg_type_number_t count = THREAD_BASIC_INFO_COUNT; - thread_basic_info_data_t info; - if (KERN_SUCCESS != thread_info(thread, THREAD_BASIC_INFO, reinterpret_cast(&info), &count)) - return -1; - - spec->tv_sec = info.user_time.seconds + info.system_time.seconds; - spec->tv_nsec = info.user_time.microseconds * 1000 + info.system_time.microseconds * 1000; - mach_port_deallocate(mach_task_self(), thread); - - return 0; -} - -int clock_gettime(int clk_id, struct timespec* t) { - if (clk_id == CLOCK_THREAD_CPUTIME_ID) - return clock_gettime_thread(t); - - struct timeval now; - int rv = gettimeofday(&now, NULL); - - if (rv) - return rv; - t->tv_sec = now.tv_sec; - t->tv_nsec = now.tv_usec * 1000; - - return 0; -} - -#endif -#endif diff --git a/base/common/shift10.cpp b/base/common/shift10.cpp index d837fb064fb..45f5733bd76 100644 --- a/base/common/shift10.cpp +++ b/base/common/shift10.cpp @@ -1,7 +1,8 @@ #include + #include + #include -#include template diff --git a/base/common/time.h b/base/common/time.h new file mode 100644 index 00000000000..9a52d8e40b8 --- /dev/null +++ b/base/common/time.h @@ -0,0 +1,7 @@ +#pragma once + +#include + +#if defined (OS_DARWIN) +# define CLOCK_MONOTONIC_COARSE CLOCK_MONOTONIC +#endif diff --git a/base/daemon/include/daemon/BaseDaemon.h b/base/daemon/include/daemon/BaseDaemon.h index 6a2764db8c1..b7070c76e9b 100644 --- a/base/daemon/include/daemon/BaseDaemon.h +++ b/base/daemon/include/daemon/BaseDaemon.h @@ -1,7 +1,7 @@ #pragma once #include -#include +#include #include #include #include diff --git a/base/port/clock.h b/base/port/clock.h deleted file mode 100644 index 552d56ede0d..00000000000 --- a/base/port/clock.h +++ /dev/null @@ -1,49 +0,0 @@ -#pragma once -/** Allows to build on MacOS X - * - * Highly experimental, not recommended, disabled by default. - * - * To use, include this file with -include compiler parameter. - */ - -#include - -#ifdef __APPLE__ - -# if !defined(APPLE_HAVE_CLOCK_GETTIME) -# include -# if !defined(MAC_OS_X_VERSION_10_12) -# define MAC_OS_X_VERSION_10_12 101200 -# endif -# define APPLE_HAVE_CLOCK_GETTIME MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12 -# endif - -# if !APPLE_HAVE_CLOCK_GETTIME || !defined(CLOCK_MONOTONIC) -/** - * MacOS X doesn't support different clock sources - * - * Mapping all of them to 0, except for - * CLOCK_THREAD_CPUTIME_ID, because there is a way - * to implement it using in-kernel stats about threads - */ -# if !defined(CLOCK_MONOTONIC) -# define CLOCK_MONOTONIC 0 -# endif -# if !defined(CLOCK_REALTIME) -# define CLOCK_REALTIME CLOCK_MONOTONIC -# endif -# if !defined(CLOCK_THREAD_CPUTIME_ID) -# define CLOCK_THREAD_CPUTIME_ID 3 -# endif - -typedef int clockid_t; -int clock_gettime(int clk_id, struct timespec* t); -# else - -# endif - -# if !defined(CLOCK_MONOTONIC_COARSE) -# define CLOCK_MONOTONIC_COARSE CLOCK_MONOTONIC -# endif - -#endif diff --git a/base/port/ssize_t.h b/base/port/ssize_t.h deleted file mode 100644 index 62199bbe1f0..00000000000 --- a/base/port/ssize_t.h +++ /dev/null @@ -1,8 +0,0 @@ -#pragma once - -#ifdef _MSC_VER - #include - typedef SSIZE_T ssize_t; -#else - #include -#endif diff --git a/base/port/unistd.h b/base/port/unistd.h deleted file mode 100644 index 2c08bd0bcd2..00000000000 --- a/base/port/unistd.h +++ /dev/null @@ -1,11 +0,0 @@ -#pragma once - -// https://stackoverflow.com/questions/341817/is-there-a-replacement-for-unistd-h-for-windows-visual-c - -#ifdef _MSC_VER - #include -#else - #include -#endif - -#include "ssize_t.h" diff --git a/cmake/find/rt.cmake b/cmake/find/rt.cmake deleted file mode 100644 index 25614fe55eb..00000000000 --- a/cmake/find/rt.cmake +++ /dev/null @@ -1,10 +0,0 @@ -if (APPLE) - # lib from libs/libcommon - set (RT_LIBRARY "apple_rt") -elseif (OS_FREEBSD) - find_library (RT_LIBRARY rt) -else () - set (RT_LIBRARY "") -endif () - -message(STATUS "Using rt: ${RT_LIBRARY}") diff --git a/dbms/CMakeLists.txt b/dbms/CMakeLists.txt index 30c5f5fddb4..0af6955eab0 100644 --- a/dbms/CMakeLists.txt +++ b/dbms/CMakeLists.txt @@ -185,11 +185,6 @@ elseif (COMPILER_GCC) add_cxx_compile_options(-Wvector-operation-performance) endif () -if (USE_DEBUG_HELPERS) - set (INCLUDE_DEBUG_HELPERS "-I${ClickHouse_SOURCE_DIR}/libs/libcommon/include -include ${ClickHouse_SOURCE_DIR}/dbms/src/Core/iostream_debug_helpers.h") - set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${INCLUDE_DEBUG_HELPERS}") -endif () - if (COMPILER_GCC) # If we leave this optimization enabled, gcc-7 replaces a pair of SSE intrinsics (16 byte load, store) with a call to memcpy. # It leads to slow code. This is compiler bug. It looks like this: @@ -389,8 +384,6 @@ target_link_libraries(clickhouse_common_io PUBLIC ${Boost_SYSTEM_LIBRARY} ${Boost_PROGRAM_OPTIONS_LIBRARY} - PRIVATE - apple_rt PUBLIC roaring ) diff --git a/dbms/programs/benchmark/Benchmark.cpp b/dbms/programs/benchmark/Benchmark.cpp index 3dd89cd1710..440d07f8ad3 100644 --- a/dbms/programs/benchmark/Benchmark.cpp +++ b/dbms/programs/benchmark/Benchmark.cpp @@ -1,4 +1,4 @@ -#include +#include #include #include #include diff --git a/dbms/programs/performance-test/PerformanceTestSuite.cpp b/dbms/programs/performance-test/PerformanceTestSuite.cpp index fbf43bfa29f..73ae2ae90ed 100644 --- a/dbms/programs/performance-test/PerformanceTestSuite.cpp +++ b/dbms/programs/performance-test/PerformanceTestSuite.cpp @@ -6,7 +6,7 @@ #include #include -#include +#include #include #include diff --git a/dbms/src/Common/ShellCommand.cpp b/dbms/src/Common/ShellCommand.cpp index dd99221d4f7..706d5bfbece 100644 --- a/dbms/src/Common/ShellCommand.cpp +++ b/dbms/src/Common/ShellCommand.cpp @@ -7,7 +7,7 @@ #include #include #include -#include +#include #include namespace diff --git a/dbms/src/Common/Stopwatch.h b/dbms/src/Common/Stopwatch.h index 6db345c219a..db337355e2d 100644 --- a/dbms/src/Common/Stopwatch.h +++ b/dbms/src/Common/Stopwatch.h @@ -1,9 +1,9 @@ #pragma once -#include -#include +#include #include -#include + +#include namespace StopWatchDetail diff --git a/dbms/src/Common/Throttler.h b/dbms/src/Common/Throttler.h index a23b0f9db22..172cce783d8 100644 --- a/dbms/src/Common/Throttler.h +++ b/dbms/src/Common/Throttler.h @@ -1,6 +1,5 @@ #pragma once -#include /// nanosleep #include #include #include @@ -8,7 +7,6 @@ #include #include #include -#include namespace ProfileEvents diff --git a/dbms/src/Common/ZooKeeper/ZooKeeper.h b/dbms/src/Common/ZooKeeper/ZooKeeper.h index 5bae272102d..c553d162c2b 100644 --- a/dbms/src/Common/ZooKeeper/ZooKeeper.h +++ b/dbms/src/Common/ZooKeeper/ZooKeeper.h @@ -11,7 +11,7 @@ #include #include #include -#include +#include namespace ProfileEvents diff --git a/dbms/src/Common/ZooKeeper/tests/zkutil_test_commands.cpp b/dbms/src/Common/ZooKeeper/tests/zkutil_test_commands.cpp index a49a5cf1a6d..490c834eab9 100644 --- a/dbms/src/Common/ZooKeeper/tests/zkutil_test_commands.cpp +++ b/dbms/src/Common/ZooKeeper/tests/zkutil_test_commands.cpp @@ -2,7 +2,7 @@ #include #include #include -#include +#include using namespace zkutil; diff --git a/dbms/src/Common/randomSeed.cpp b/dbms/src/Common/randomSeed.cpp index 8402fa4acf8..4d466d283c9 100644 --- a/dbms/src/Common/randomSeed.cpp +++ b/dbms/src/Common/randomSeed.cpp @@ -1,11 +1,10 @@ #include -#include +#include #include #include #include #include #include -#include namespace DB diff --git a/dbms/src/Common/tests/Random.cpp b/dbms/src/Common/tests/Random.cpp index d926b21c133..5264a2d9adc 100644 --- a/dbms/src/Common/tests/Random.cpp +++ b/dbms/src/Common/tests/Random.cpp @@ -1,6 +1,5 @@ /// Taken from SMHasher. #include "Random.h" -#include Rand g_rand1(1); Rand g_rand2(2); diff --git a/dbms/src/Common/tests/compact_array.cpp b/dbms/src/Common/tests/compact_array.cpp index e238263c801..91fb59d543f 100644 --- a/dbms/src/Common/tests/compact_array.cpp +++ b/dbms/src/Common/tests/compact_array.cpp @@ -13,7 +13,7 @@ #include #include #include -#include +#include namespace fs = std::filesystem; diff --git a/dbms/src/Common/tests/int_hashes_perf.cpp b/dbms/src/Common/tests/int_hashes_perf.cpp index 5f028cbbde8..69020178bd4 100644 --- a/dbms/src/Common/tests/int_hashes_perf.cpp +++ b/dbms/src/Common/tests/int_hashes_perf.cpp @@ -1,5 +1,5 @@ -#if !defined(__APPLE__) && !defined(__FreeBSD__) -#include +#if defined (OS_LINUX) +# include #endif #include @@ -9,7 +9,6 @@ #include #include #include "AvalancheTest.h" /// Taken from SMHasher. -#include static void setAffinity() diff --git a/dbms/src/Compression/CachedCompressedReadBuffer.h b/dbms/src/Compression/CachedCompressedReadBuffer.h index 52ef750ff19..8821a824a0f 100644 --- a/dbms/src/Compression/CachedCompressedReadBuffer.h +++ b/dbms/src/Compression/CachedCompressedReadBuffer.h @@ -5,7 +5,6 @@ #include #include "CompressedReadBufferBase.h" #include -#include namespace DB diff --git a/dbms/src/Compression/CompressedReadBufferFromFile.h b/dbms/src/Compression/CompressedReadBufferFromFile.h index 641e3d6ed1b..191368da3d4 100644 --- a/dbms/src/Compression/CompressedReadBufferFromFile.h +++ b/dbms/src/Compression/CompressedReadBufferFromFile.h @@ -4,7 +4,6 @@ #include #include #include -#include namespace DB diff --git a/dbms/src/IO/ReadBufferFromFileBase.h b/dbms/src/IO/ReadBufferFromFileBase.h index d9e26d80405..4a10215a1a2 100644 --- a/dbms/src/IO/ReadBufferFromFileBase.h +++ b/dbms/src/IO/ReadBufferFromFileBase.h @@ -1,13 +1,14 @@ #pragma once -#include -#include -#include -#include -#include #include -#include -#include "SeekableReadBuffer.h" +#include +#include + +#include +#include + +#include + namespace DB { diff --git a/dbms/src/IO/ReadBufferFromFileDescriptor.h b/dbms/src/IO/ReadBufferFromFileDescriptor.h index b19a04aef18..8b6ffe54158 100644 --- a/dbms/src/IO/ReadBufferFromFileDescriptor.h +++ b/dbms/src/IO/ReadBufferFromFileDescriptor.h @@ -1,8 +1,8 @@ #pragma once -#include #include -#include + +#include namespace DB diff --git a/dbms/src/IO/WriteBufferFromFileDescriptor.cpp b/dbms/src/IO/WriteBufferFromFileDescriptor.cpp index bfa1e9582d3..2891c1b7076 100644 --- a/dbms/src/IO/WriteBufferFromFileDescriptor.cpp +++ b/dbms/src/IO/WriteBufferFromFileDescriptor.cpp @@ -1,4 +1,4 @@ -#include +#include #include #include diff --git a/dbms/src/IO/tests/gtest_aio_seek_back_after_eof.cpp b/dbms/src/IO/tests/gtest_aio_seek_back_after_eof.cpp index 35c2db70564..22cfffdda05 100644 --- a/dbms/src/IO/tests/gtest_aio_seek_back_after_eof.cpp +++ b/dbms/src/IO/tests/gtest_aio_seek_back_after_eof.cpp @@ -3,7 +3,7 @@ #include #include -#include +#include #include #include #include diff --git a/dbms/src/IO/tests/read_buffer_aio.cpp b/dbms/src/IO/tests/read_buffer_aio.cpp index adb2f7d5458..62acd069339 100644 --- a/dbms/src/IO/tests/read_buffer_aio.cpp +++ b/dbms/src/IO/tests/read_buffer_aio.cpp @@ -6,7 +6,7 @@ #include #include #include -#include +#include namespace @@ -670,4 +670,3 @@ int main() run(); return 0; } - diff --git a/dbms/src/Interpreters/ClientInfo.cpp b/dbms/src/Interpreters/ClientInfo.cpp index 3fbc015afe2..743fe934dc3 100644 --- a/dbms/src/Interpreters/ClientInfo.cpp +++ b/dbms/src/Interpreters/ClientInfo.cpp @@ -7,7 +7,7 @@ #include #include #include -#include +#include namespace DB diff --git a/dbms/src/Interpreters/tests/users.cpp b/dbms/src/Interpreters/tests/users.cpp index 93b1f6c27f1..ca96d6f4568 100644 --- a/dbms/src/Interpreters/tests/users.cpp +++ b/dbms/src/Interpreters/tests/users.cpp @@ -11,7 +11,7 @@ #include #include #include -#include +#include namespace { diff --git a/dbms/src/Processors/Formats/Impl/PrettyBlockOutputFormat.cpp b/dbms/src/Processors/Formats/Impl/PrettyBlockOutputFormat.cpp index c0b1b2e4ffc..6a3a34278fe 100644 --- a/dbms/src/Processors/Formats/Impl/PrettyBlockOutputFormat.cpp +++ b/dbms/src/Processors/Formats/Impl/PrettyBlockOutputFormat.cpp @@ -1,5 +1,5 @@ #include -#include +#include #include #include #include diff --git a/dbms/src/Storages/MergeTree/MergeTreeReader.h b/dbms/src/Storages/MergeTree/MergeTreeReader.h index 65485f950c6..1505b71ef53 100644 --- a/dbms/src/Storages/MergeTree/MergeTreeReader.h +++ b/dbms/src/Storages/MergeTree/MergeTreeReader.h @@ -2,7 +2,6 @@ #include #include -#include namespace DB diff --git a/dbms/src/Storages/tests/remove_symlink_directory.cpp b/dbms/src/Storages/tests/remove_symlink_directory.cpp index b455357863e..ae5fa72fa66 100644 --- a/dbms/src/Storages/tests/remove_symlink_directory.cpp +++ b/dbms/src/Storages/tests/remove_symlink_directory.cpp @@ -1,4 +1,4 @@ -#include +#include #include #include #include diff --git a/utils/iotest/iotest.cpp b/utils/iotest/iotest.cpp index 8c17163778e..ea7cd439838 100644 --- a/utils/iotest/iotest.cpp +++ b/utils/iotest/iotest.cpp @@ -1,21 +1,23 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include #include +#include #include #include -#include -#include #include -#include +#include +#include + #include -#include +#include +#include +#include +#include + +#include +#include +#include +#include + namespace DB { diff --git a/utils/iotest/iotest_aio.cpp b/utils/iotest/iotest_aio.cpp index 038bc600ec6..800e605d62e 100644 --- a/utils/iotest/iotest_aio.cpp +++ b/utils/iotest/iotest_aio.cpp @@ -3,7 +3,7 @@ int main(int, char **) { return 0; } #else #include -#include +#include #include #include #include diff --git a/utils/iotest/iotest_nonblock.cpp b/utils/iotest/iotest_nonblock.cpp index 62871f6c162..3d6b8666043 100644 --- a/utils/iotest/iotest_nonblock.cpp +++ b/utils/iotest/iotest_nonblock.cpp @@ -1,24 +1,26 @@ -#include -#include -#include -#include -#include -#if !defined(__APPLE__) && !defined(__FreeBSD__) -#include -#endif -#include -#include -#include -#include -#include -#include #include +#include #include #include -#include -#include #include -#include +#include +#include + +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#if defined (OS_LINUX) +# include +#endif + namespace DB {