Skip to content

Commit

Permalink
Merge branch 'master' into branch_v3.1
Browse files Browse the repository at this point in the history
  • Loading branch information
floitsch committed Sep 9, 2018
2 parents fd043b2 + 20ecba5 commit e67d737
Show file tree
Hide file tree
Showing 27 changed files with 1,007 additions and 279 deletions.
2 changes: 2 additions & 0 deletions BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

licenses(["notice"])

exports_files(["LICENSE"])

cc_library(
name = "double-conversion",
srcs = [
Expand Down
147 changes: 94 additions & 53 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,27 +1,34 @@
cmake_minimum_required(VERSION 2.8.12)
project(double-conversion)
cmake_minimum_required(VERSION 3.0)
project(double-conversion VERSION 3.0.0)

include(GNUInstallDirs)
set(headers
double-conversion/bignum.h
double-conversion/cached-powers.h
double-conversion/diy-fp.h
double-conversion/double-conversion.h
double-conversion/fast-dtoa.h
double-conversion/fixed-dtoa.h
double-conversion/ieee.h
double-conversion/strtod.h
double-conversion/utils.h)

# pick a version #
set(double-conversion_VERSION 2.0.1)
set(double-conversion_SOVERSION_MAJOR 1)
set(double-conversion_SOVERSION_MINOR 0)
set(double-conversion_SOVERSION_PATCH 0)
set(double-conversion_SOVERSION
${double-conversion_SOVERSION_MAJOR}.${double-conversion_SOVERSION_MINOR}.${double-conversion_SOVERSION_PATCH})

# set suffix for CMake files used for packaging
if(WIN32 AND NOT CYGWIN)
set(INSTALL_CMAKE_DIR CMake)
else()
set(INSTALL_CMAKE_DIR ${CMAKE_INSTALL_LIBDIR}/cmake/double-conversion)
endif()
add_library(double-conversion
double-conversion/bignum.cc
double-conversion/bignum-dtoa.cc
double-conversion/cached-powers.cc
double-conversion/diy-fp.cc
double-conversion/double-conversion.cc
double-conversion/fast-dtoa.cc
double-conversion/fixed-dtoa.cc
double-conversion/strtod.cc
${headers})
target_include_directories(
double-conversion PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>)

# Add src subdirectory
add_subdirectory(double-conversion)
# pick a version #
set_property(TARGET double-conversion PROPERTY SOVERSION ${PROJECT_VERSION})

#
# set up testing if requested
option(BUILD_TESTING "Build test programs" OFF)
if(BUILD_TESTING)
Expand All @@ -30,41 +37,75 @@ if(BUILD_TESTING)
add_subdirectory(test)
endif()

#
# mention the library target as export library
export(TARGETS double-conversion
FILE "${PROJECT_BINARY_DIR}/double-conversionLibraryDepends.cmake")
####
# Installation (https://github.com/forexample/package-example)

# Layout. This works for all platforms:
# * <prefix>/lib/cmake/<PROJECT-NAME>
# * <prefix>/lib/
# * <prefix>/include/
set(config_install_dir "lib/cmake/${PROJECT_NAME}")
set(include_install_dir "include")

set(generated_dir "${CMAKE_CURRENT_BINARY_DIR}/generated")

# Configuration
set(version_config "${generated_dir}/${PROJECT_NAME}ConfigVersion.cmake")
set(project_config "${generated_dir}/${PROJECT_NAME}Config.cmake")
set(targets_export_name "${PROJECT_NAME}Targets")
set(namespace "${PROJECT_NAME}::")

# Include module with function 'write_basic_package_version_file'
include(CMakePackageConfigHelpers)

# Configure '<PROJECT-NAME>ConfigVersion.cmake'
# Note: PROJECT_VERSION is used as a VERSION
write_basic_package_version_file(
"${version_config}" COMPATIBILITY SameMajorVersion
)

#
# set this build as an importable package
export(PACKAGE double-conversion)
# Configure '<PROJECT-NAME>Config.cmake'
# Use variables:
# * targets_export_name
# * PROJECT_NAME
configure_package_config_file(
"cmake/Config.cmake.in"
"${project_config}"
INSTALL_DESTINATION "${config_install_dir}"
)

#
# make a cmake file -- in this case, all that needs defining
# is double-conversion_INCLUDE_DIRS
configure_file(double-conversionBuildTreeSettings.cmake.in
"${PROJECT_BINARY_DIR}/double-conversionBuildTreeSettings.cmake"
@ONLY)
# Targets:
# * <prefix>/lib/libdouble-conversion.a
# * header location after install: <prefix>/include/double-conversion/*.h
# * headers can be included by C++ code `#include <double-conversion/*.h>`
install(
TARGETS double-conversion
EXPORT "${targets_export_name}"
LIBRARY DESTINATION "lib"
ARCHIVE DESTINATION "lib"
RUNTIME DESTINATION "bin"
INCLUDES DESTINATION "${include_install_dir}"
)

#
# sets up config to be used by CMake find_package
configure_file(double-conversionConfig.cmake.in
"${PROJECT_BINARY_DIR}/double-conversionConfig.cmake"
@ONLY)
#
# Export version # checked by find_package
configure_file(double-conversionConfigVersion.cmake.in
"${PROJECT_BINARY_DIR}/double-conversionConfigVersion.cmake"
@ONLY)
#
# install config files for find_package
install(FILES
"${PROJECT_BINARY_DIR}/double-conversionConfig.cmake"
"${PROJECT_BINARY_DIR}/double-conversionConfigVersion.cmake"
DESTINATION "${INSTALL_CMAKE_DIR}" COMPONENT dev)
# Headers:
# * double-conversion/*.h -> <prefix>/include/double-conversion/*.h
install(
FILES ${headers}
DESTINATION "${include_install_dir}/double-conversion"
)

# Config
# * <prefix>/lib/cmake/double-conversion/double-conversionConfig.cmake
# * <prefix>/lib/cmake/double-conversion/double-conversionConfigVersion.cmake
install(
FILES "${project_config}" "${version_config}"
DESTINATION "${config_install_dir}"
)

#
# generates install cmake files to find libraries in installation.
install(EXPORT double-conversionLibraryDepends DESTINATION
"${INSTALL_CMAKE_DIR}" COMPONENT dev)
# Config
# * <prefix>/lib/cmake/double-conversion/double-conversionTargets.cmake
install(
EXPORT "${targets_export_name}"
NAMESPACE "${namespace}"
DESTINATION "${config_install_dir}"
)
11 changes: 11 additions & 0 deletions Changelog
Original file line number Diff line number Diff line change
@@ -1,9 +1,20 @@
2018-09-09:
Fix bug where large hex literals would lose their minus sign.
Added support for separator characters (which adds a new optional
argument). Thus increasing the version number to 3.1.0
Added support for hexadecimal float literals.
Support for more architectures.

2017-12-06:
Renamed `DISALLOW_COPY_AND_ASSIGN` and `DISALLOW_IMPLICIT_CONSTRUCTORS`
macros to `DC_DISALLOW_COPY_AND_ASSIGN` and
`DC_DISALLOW_IMPLICIT_CONSTRUCTORS` to make it easier to integrate the
library with other libraries that have similar macros.

2017-08-05:
Tagged v3.0.0.
Due to the directory rename switching to a new version number.
The API for the library itself hasn't changed.

2017-03-04:
Avoid negative shift. Fixes #41.
Expand Down
4 changes: 4 additions & 0 deletions cmake/Config.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
@PACKAGE_INIT@

include("${CMAKE_CURRENT_LIST_DIR}/@[email protected]")
check_required_components("@PROJECT_NAME@")
57 changes: 0 additions & 57 deletions double-conversion/CMakeLists.txt

This file was deleted.

8 changes: 4 additions & 4 deletions double-conversion/bignum-dtoa.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

#include <math.h>
#include <cmath>

#include "bignum-dtoa.h"
#include <double-conversion/bignum-dtoa.h>

#include "bignum.h"
#include "ieee.h"
#include <double-conversion/bignum.h>
#include <double-conversion/ieee.h>

namespace double_conversion {

Expand Down
2 changes: 1 addition & 1 deletion double-conversion/bignum-dtoa.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
#ifndef DOUBLE_CONVERSION_BIGNUM_DTOA_H_
#define DOUBLE_CONVERSION_BIGNUM_DTOA_H_

#include "utils.h"
#include <double-conversion/utils.h>

namespace double_conversion {

Expand Down
13 changes: 7 additions & 6 deletions double-conversion/bignum.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

#include "bignum.h"
#include "utils.h"
#include <double-conversion/bignum.h>
#include <double-conversion/utils.h>

namespace double_conversion {

Bignum::Bignum()
: bigits_(bigits_buffer_, kBigitCapacity), used_digits_(0), exponent_(0) {
: bigits_buffer_(), bigits_(bigits_buffer_, kBigitCapacity), used_digits_(0), exponent_(0) {
for (int i = 0; i < kBigitCapacity; ++i) {
bigits_[i] = 0;
}
Expand Down Expand Up @@ -445,26 +445,27 @@ void Bignum::AssignPowerUInt16(uint16_t base, int power_exponent) {
mask >>= 2;
uint64_t this_value = base;

bool delayed_multipliciation = false;
bool delayed_multiplication = false;
const uint64_t max_32bits = 0xFFFFFFFF;
while (mask != 0 && this_value <= max_32bits) {
this_value = this_value * this_value;
// Verify that there is enough space in this_value to perform the
// multiplication. The first bit_size bits must be 0.
if ((power_exponent & mask) != 0) {
ASSERT(bit_size > 0);
uint64_t base_bits_mask =
~((static_cast<uint64_t>(1) << (64 - bit_size)) - 1);
bool high_bits_zero = (this_value & base_bits_mask) == 0;
if (high_bits_zero) {
this_value *= base;
} else {
delayed_multipliciation = true;
delayed_multiplication = true;
}
}
mask >>= 1;
}
AssignUInt64(this_value);
if (delayed_multipliciation) {
if (delayed_multiplication) {
MultiplyByUInt32(base);
}

Expand Down
4 changes: 2 additions & 2 deletions double-conversion/bignum.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
#ifndef DOUBLE_CONVERSION_BIGNUM_H_
#define DOUBLE_CONVERSION_BIGNUM_H_

#include "utils.h"
#include <double-conversion/utils.h>

namespace double_conversion {

Expand Down Expand Up @@ -136,7 +136,7 @@ class Bignum {
// The Bignum's value equals value(bigits_) * 2^(exponent_ * kBigitSize).
int exponent_;

DISALLOW_COPY_AND_ASSIGN(Bignum);
DC_DISALLOW_COPY_AND_ASSIGN(Bignum);
};

} // namespace double_conversion
Expand Down
10 changes: 5 additions & 5 deletions double-conversion/cached-powers.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

#include <stdarg.h>
#include <limits.h>
#include <math.h>
#include <climits>
#include <cmath>
#include <cstdarg>

#include "utils.h"
#include <double-conversion/utils.h>

#include "cached-powers.h"
#include <double-conversion/cached-powers.h>

namespace double_conversion {

Expand Down
2 changes: 1 addition & 1 deletion double-conversion/cached-powers.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
#ifndef DOUBLE_CONVERSION_CACHED_POWERS_H_
#define DOUBLE_CONVERSION_CACHED_POWERS_H_

#include "diy-fp.h"
#include <double-conversion/diy-fp.h>

namespace double_conversion {

Expand Down
4 changes: 2 additions & 2 deletions double-conversion/diy-fp.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.


#include "diy-fp.h"
#include "utils.h"
#include <double-conversion/diy-fp.h>
#include <double-conversion/utils.h>

namespace double_conversion {

Expand Down
2 changes: 1 addition & 1 deletion double-conversion/diy-fp.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
#ifndef DOUBLE_CONVERSION_DIY_FP_H_
#define DOUBLE_CONVERSION_DIY_FP_H_

#include "utils.h"
#include <double-conversion/utils.h>

namespace double_conversion {

Expand Down
Loading

0 comments on commit e67d737

Please sign in to comment.