fixing bots

This commit is contained in:
Hans Dembinski
2016-05-10 10:51:59 -04:00
parent 154b57011a
commit 0133fb0fc0
2 changed files with 17 additions and 13 deletions

View File

@@ -14,8 +14,12 @@ if(${CMAKE_BUILD_TYPE})
endif()
find_package(Boost 1.55 REQUIRED
COMPONENTS iostreams serialization unit_test_framework)
find_library(Boost_PYTHON_FOUND boost_python) # optional
COMPONENTS iostreams serialization unit_test_framework python)
if(NOT ${Boost_FOUND})
# try again without boost.python
find_package(Boost 1.55 REQUIRED
COMPONENTS iostreams serialization unit_test_framework)
endif()
add_definitions(-DBOOST_TEST_DYN_LINK) # for unit_test_framework
add_definitions(-Wall)
@@ -58,6 +62,8 @@ if(USE_PYTHON AND Boost_PYTHON_FOUND)
# Python3 is currently not supported
set(HAVE_PYTHON 1)
message(STATUS "Python version: ${PYTHON_VERSION}")
include_directories(${PYTHON_INCLUDE_DIRS})
if(${PYTHON_VERSION} VERSION_GREATER 3.0)
@@ -80,7 +86,7 @@ if(USE_PYTHON AND Boost_PYTHON_FOUND)
../src/python/basic_histogram.cpp
../src/python/histogram.cpp
)
target_link_libraries(pyhistogram boost_histogram ${LIBRARIES} boost_python ${PYTHON_LIBRARIES})
target_link_libraries(pyhistogram boost_histogram ${LIBRARIES} ${PYTHON_LIBRARIES})
set_target_properties(pyhistogram PROPERTIES OUTPUT_NAME "histogram" PREFIX "" SUFFIX ".so")
endif()
endif()

View File

@@ -136,22 +136,20 @@ void
nstore::grow()
{
BOOST_ASSERT(size_ > 0);
if (depth_ == 0) {
depth_ = sizeof(uint8_t);
create(0);
return;
}
// realloc is safe if buffer_ is null
buffer_ = std::realloc(buffer_, size_ * 2 * depth_);
if (!buffer_) throw std::bad_alloc();
size_type i = size_;
switch (depth_) {
case 0:
depth_ = sizeof(uint8_t);
create(0);
return;
#define BOOST_HISTOGRAM_NSTORE_GROW(T0, T1) \
case sizeof(T0): \
depth_ = sizeof(T1); \
buffer_ = std::realloc(buffer_, size_ * depth_); \
if (!buffer_) throw std::bad_alloc(); \
while (i--) \
((T1*)buffer_)[i] = ((T0*)buffer_)[i]; \
depth_ = sizeof(T1); \
break
return
BOOST_HISTOGRAM_NSTORE_GROW(uint8_t, uint16_t);
BOOST_HISTOGRAM_NSTORE_GROW(uint16_t, uint32_t);
BOOST_HISTOGRAM_NSTORE_GROW(uint32_t, uint64_t);