More clean-up

This commit is contained in:
Ivan Lezhankin 2020-02-17 17:27:09 +03:00
parent 4cedd4619d
commit 39ea079034
40 changed files with 77 additions and 227 deletions

View File

@ -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)

View File

@ -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)

View File

@ -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 ()

View File

@ -3,8 +3,8 @@
#include <iostream>
#include <string_view>
#include <port/unistd.h>
#include <string.h>
#include <unistd.h>
#ifdef OS_LINUX
/// We can detect if code is linked with one or another readline variants or open the library dynamically.

View File

@ -1,8 +1,8 @@
#include <common/ReplxxLineReader.h>
#include <errno.h>
#include <port/unistd.h>
#include <string.h>
#include <unistd.h>
namespace
{

View File

@ -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 <port/clock.h>
#ifdef __APPLE__
#if !APPLE_HAVE_CLOCK_GETTIME
#include <time.h>
#include <stdlib.h>
#include <mach/mach_init.h>
#include <mach/thread_act.h>
#include <mach/mach_port.h>
#include <sys/time.h>
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<thread_info_t>(&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

View File

@ -1,7 +1,8 @@
#include <common/shift10.h>
#include <common/likely.h>
#include <limits>
#include <port/ssize_t.h>
template <typename T>

7
base/common/time.h Normal file
View File

@ -0,0 +1,7 @@
#pragma once
#include <time.h>
#if defined (OS_DARWIN)
# define CLOCK_MONOTONIC_COARSE CLOCK_MONOTONIC
#endif

View File

@ -1,7 +1,7 @@
#pragma once
#include <sys/types.h>
#include <port/unistd.h>
#include <unistd.h>
#include <iostream>
#include <memory>
#include <functional>

View File

@ -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 <time.h>
#ifdef __APPLE__
# if !defined(APPLE_HAVE_CLOCK_GETTIME)
# include <AvailabilityMacros.h>
# 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

View File

@ -1,8 +0,0 @@
#pragma once
#ifdef _MSC_VER
#include <basetsd.h>
typedef SSIZE_T ssize_t;
#else
#include <sys/types.h>
#endif

View File

@ -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 <io.h>
#else
#include <unistd.h>
#endif
#include "ssize_t.h"

View File

@ -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}")

View File

@ -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
)

View File

@ -1,4 +1,4 @@
#include <port/unistd.h>
#include <unistd.h>
#include <stdlib.h>
#include <fcntl.h>
#include <signal.h>

View File

@ -6,7 +6,7 @@
#include <memory>
#include <filesystem>
#include <port/unistd.h>
#include <unistd.h>
#include <sys/stat.h>
#include <boost/program_options.hpp>

View File

@ -7,7 +7,7 @@
#include <Common/PipeFDs.h>
#include <common/logger_useful.h>
#include <IO/WriteHelpers.h>
#include <port/unistd.h>
#include <unistd.h>
#include <csignal>
namespace

View File

@ -1,9 +1,9 @@
#pragma once
#include <time.h>
#include <atomic>
#include <common/time.h>
#include <common/Types.h>
#include <port/clock.h>
#include <atomic>
namespace StopWatchDetail

View File

@ -1,6 +1,5 @@
#pragma once
#include <time.h> /// nanosleep
#include <mutex>
#include <memory>
#include <Common/Stopwatch.h>
@ -8,7 +7,6 @@
#include <Common/ProfileEvents.h>
#include <common/sleep.h>
#include <IO/WriteHelpers.h>
#include <port/clock.h>
namespace ProfileEvents

View File

@ -11,7 +11,7 @@
#include <Common/ProfileEvents.h>
#include <Common/CurrentMetrics.h>
#include <Common/ZooKeeper/IKeeper.h>
#include <port/unistd.h>
#include <unistd.h>
namespace ProfileEvents

View File

@ -2,7 +2,7 @@
#include <Common/ZooKeeper/KeeperException.h>
#include <Common/typeid_cast.h>
#include <iostream>
#include <port/unistd.h>
#include <unistd.h>
using namespace zkutil;

View File

@ -1,11 +1,10 @@
#include <time.h>
#include <port/unistd.h>
#include <unistd.h>
#include <sys/types.h>
#include <Common/Exception.h>
#include <Common/randomSeed.h>
#include <Common/SipHash.h>
#include <Core/Types.h>
#include <port/clock.h>
namespace DB

View File

@ -1,6 +1,5 @@
/// Taken from SMHasher.
#include "Random.h"
#include <port/clock.h>
Rand g_rand1(1);
Rand g_rand2(2);

View File

@ -13,7 +13,7 @@
#include <fstream>
#include <stdexcept>
#include <cstdlib>
#include <port/unistd.h>
#include <unistd.h>
namespace fs = std::filesystem;

View File

@ -1,5 +1,5 @@
#if !defined(__APPLE__) && !defined(__FreeBSD__)
#include <sched.h>
#if defined (OS_LINUX)
# include <sched.h>
#endif
#include <iostream>
@ -9,7 +9,6 @@
#include <Common/Stopwatch.h>
#include <Core/Defines.h>
#include "AvalancheTest.h" /// Taken from SMHasher.
#include <port/clock.h>
static void setAffinity()

View File

@ -5,7 +5,6 @@
#include <IO/ReadBufferFromFileBase.h>
#include "CompressedReadBufferBase.h"
#include <IO/UncompressedCache.h>
#include <port/clock.h>
namespace DB

View File

@ -4,7 +4,6 @@
#include <IO/ReadBufferFromFileBase.h>
#include <time.h>
#include <memory>
#include <port/clock.h>
namespace DB

View File

@ -1,13 +1,14 @@
#pragma once
#include <string>
#include <ctime>
#include <functional>
#include <fcntl.h>
#include <IO/ReadBuffer.h>
#include <IO/BufferWithOwnMemory.h>
#include <port/clock.h>
#include "SeekableReadBuffer.h"
#include <IO/SeekableReadBuffer.h>
#include <common/time.h>
#include <functional>
#include <string>
#include <fcntl.h>
namespace DB
{

View File

@ -1,8 +1,8 @@
#pragma once
#include <port/unistd.h>
#include <IO/ReadBufferFromFileBase.h>
#include <IO/ReadBuffer.h>
#include <unistd.h>
namespace DB

View File

@ -1,4 +1,4 @@
#include <port/unistd.h>
#include <unistd.h>
#include <errno.h>
#include <Common/Exception.h>

View File

@ -3,7 +3,7 @@
#include <gtest/gtest.h>
#include <Core/Defines.h>
#include <port/unistd.h>
#include <unistd.h>
#include <IO/ReadBufferAIO.h>
#include <fstream>
#include <string>

View File

@ -6,7 +6,7 @@
#include <fstream>
#include <functional>
#include <cstdlib>
#include <port/unistd.h>
#include <unistd.h>
namespace
@ -670,4 +670,3 @@ int main()
run();
return 0;
}

View File

@ -7,7 +7,7 @@
#include <Common/getFQDNOrHostName.h>
#include <Common/ClickHouseRevision.h>
#include <Common/config_version.h>
#include <port/unistd.h>
#include <unistd.h>
namespace DB

View File

@ -11,7 +11,7 @@
#include <sstream>
#include <stdexcept>
#include <cstdlib>
#include <port/unistd.h>
#include <unistd.h>
namespace
{

View File

@ -1,5 +1,5 @@
#include <sys/ioctl.h>
#include <port/unistd.h>
#include <unistd.h>
#include <Processors/Formats/Impl/PrettyBlockOutputFormat.h>
#include <Formats/FormatFactory.h>
#include <IO/WriteBuffer.h>

View File

@ -2,7 +2,6 @@
#include <Core/NamesAndTypes.h>
#include <Storages/MergeTree/MergeTreeReaderStream.h>
#include <port/clock.h>
namespace DB

View File

@ -1,4 +1,4 @@
#include <port/unistd.h>
#include <unistd.h>
#include <iostream>
#include <Poco/File.h>
#include <Poco/Path.h>

View File

@ -1,21 +1,23 @@
#include <fcntl.h>
#include <port/unistd.h>
#include <stdlib.h>
#include <time.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <random>
#include <pcg_random.hpp>
#include <IO/BufferWithOwnMemory.h>
#include <IO/ReadHelpers.h>
#include <pcg_random.hpp>
#include <Poco/Exception.h>
#include <Common/Exception.h>
#include <Common/randomSeed.h>
#include <Common/ThreadPool.h>
#include <Common/Stopwatch.h>
#include <IO/BufferWithOwnMemory.h>
#include <Common/ThreadPool.h>
#include <Common/randomSeed.h>
#include <cstdlib>
#include <port/clock.h>
#include <iomanip>
#include <iostream>
#include <random>
#include <vector>
#include <fcntl.h>
#include <stdlib.h>
#include <time.h>
#include <unistd.h>
namespace DB
{

View File

@ -3,7 +3,7 @@ int main(int, char **) { return 0; }
#else
#include <fcntl.h>
#include <port/unistd.h>
#include <unistd.h>
#include <stdlib.h>
#include <time.h>
#include <iostream>

View File

@ -1,24 +1,26 @@
#include <fcntl.h>
#include <port/unistd.h>
#include <stdlib.h>
#include <time.h>
#include <stdlib.h>
#if !defined(__APPLE__) && !defined(__FreeBSD__)
#include <malloc.h>
#endif
#include <poll.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <random>
#include <pcg_random.hpp>
#include <IO/ReadHelpers.h>
#include <pcg_random.hpp>
#include <Poco/Exception.h>
#include <Common/Exception.h>
#include <Common/randomSeed.h>
#include <Common/ThreadPool.h>
#include <Common/Stopwatch.h>
#include <port/clock.h>
#include <Common/ThreadPool.h>
#include <Common/randomSeed.h>
#include <iomanip>
#include <iostream>
#include <random>
#include <vector>
#include <fcntl.h>
#include <poll.h>
#include <stdlib.h>
#include <time.h>
#include <unistd.h>
#if defined (OS_LINUX)
# include <malloc.h>
#endif
namespace DB
{