Skip to content

Commit

Permalink
ICU-21900 Update double-conversion to v3.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
sffc authored and pedberg-icu committed Feb 23, 2022
1 parent 9907ca8 commit c626c6d
Show file tree
Hide file tree
Showing 11 changed files with 195 additions and 7 deletions.
25 changes: 25 additions & 0 deletions icu4c/source/i18n/double-conversion-ieee.h
Original file line number Diff line number Diff line change
Expand Up @@ -164,11 +164,19 @@ class Double {
}

bool IsQuietNan() const {
#if (defined(__mips__) && !defined(__mips_nan2008)) || defined(__hppa__)
return IsNan() && ((AsUint64() & kQuietNanBit) == 0);
#else
return IsNan() && ((AsUint64() & kQuietNanBit) != 0);
#endif
}

bool IsSignalingNan() const {
#if (defined(__mips__) && !defined(__mips_nan2008)) || defined(__hppa__)
return IsNan() && ((AsUint64() & kQuietNanBit) != 0);
#else
return IsNan() && ((AsUint64() & kQuietNanBit) == 0);
#endif
}


Expand Down Expand Up @@ -250,7 +258,12 @@ class Double {
private:
static const int kDenormalExponent = -kExponentBias + 1;
static const uint64_t kInfinity = DOUBLE_CONVERSION_UINT64_2PART_C(0x7FF00000, 00000000);
#if (defined(__mips__) && !defined(__mips_nan2008)) || defined(__hppa__)
static const uint64_t kNaN = DOUBLE_CONVERSION_UINT64_2PART_C(0x7FF7FFFF, FFFFFFFF);
#else
static const uint64_t kNaN = DOUBLE_CONVERSION_UINT64_2PART_C(0x7FF80000, 00000000);
#endif


const uint64_t d64_;

Expand Down Expand Up @@ -350,11 +363,19 @@ class Single {
}

bool IsQuietNan() const {
#if (defined(__mips__) && !defined(__mips_nan2008)) || defined(__hppa__)
return IsNan() && ((AsUint32() & kQuietNanBit) == 0);
#else
return IsNan() && ((AsUint32() & kQuietNanBit) != 0);
#endif
}

bool IsSignalingNan() const {
#if (defined(__mips__) && !defined(__mips_nan2008)) || defined(__hppa__)
return IsNan() && ((AsUint32() & kQuietNanBit) != 0);
#else
return IsNan() && ((AsUint32() & kQuietNanBit) == 0);
#endif
}


Expand Down Expand Up @@ -424,7 +445,11 @@ class Single {
static const int kDenormalExponent = -kExponentBias + 1;
static const int kMaxExponent = 0xFF - kExponentBias;
static const uint32_t kInfinity = 0x7F800000;
#if (defined(__mips__) && !defined(__mips_nan2008)) || defined(__hppa__)
static const uint32_t kNaN = 0x7FBFFFFF;
#else
static const uint32_t kNaN = 0x7FC00000;
#endif

const uint32_t d32_;

Expand Down
42 changes: 40 additions & 2 deletions icu4c/source/i18n/double-conversion-utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@
#ifndef DOUBLE_CONVERSION_UTILS_H_
#define DOUBLE_CONVERSION_UTILS_H_

// Use DOUBLE_CONVERSION_NON_PREFIXED_MACROS to get unprefixed macros as was
// the case in double-conversion releases prior to 3.1.6

#include <cstdlib>
#include <cstring>

Expand All @@ -46,16 +49,28 @@
#define DOUBLE_CONVERSION_ASSERT(condition) \
U_ASSERT(condition)
#endif
#if defined(DOUBLE_CONVERSION_NON_PREFIXED_MACROS) && !defined(ASSERT)
#define ASSERT DOUBLE_CONVERSION_ASSERT
#endif

#ifndef DOUBLE_CONVERSION_UNIMPLEMENTED
#define DOUBLE_CONVERSION_UNIMPLEMENTED() (abort())
#endif
#if defined(DOUBLE_CONVERSION_NON_PREFIXED_MACROS) && !defined(UNIMPLEMENTED)
#define UNIMPLEMENTED DOUBLE_CONVERSION_UNIMPLEMENTED
#endif

#ifndef DOUBLE_CONVERSION_NO_RETURN
#ifdef _MSC_VER
#define DOUBLE_CONVERSION_NO_RETURN __declspec(noreturn)
#else
#define DOUBLE_CONVERSION_NO_RETURN __attribute__((noreturn))
#endif
#endif
#if defined(DOUBLE_CONVERSION_NON_PREFIXED_MACROS) && !defined(NO_RETURN)
#define NO_RETURN DOUBLE_CONVERSION_NO_RETURN
#endif

#ifndef DOUBLE_CONVERSION_UNREACHABLE
#ifdef _MSC_VER
void DOUBLE_CONVERSION_NO_RETURN abort_noreturn();
Expand All @@ -65,6 +80,9 @@ inline void abort_noreturn() { abort(); }
#define DOUBLE_CONVERSION_UNREACHABLE() (abort())
#endif
#endif
#if defined(DOUBLE_CONVERSION_NON_PREFIXED_MACROS) && !defined(UNREACHABLE)
#define UNREACHABLE DOUBLE_CONVERSION_UNREACHABLE
#endif

// Not all compilers support __has_attribute and combining a check for both
// ifdef and __has_attribute on the same preprocessor line isn't portable.
Expand All @@ -81,12 +99,18 @@ inline void abort_noreturn() { abort(); }
#define DOUBLE_CONVERSION_UNUSED
#endif
#endif
#if defined(DOUBLE_CONVERSION_NON_PREFIXED_MACROS) && !defined(UNUSED)
#define UNUSED DOUBLE_CONVERSION_UNUSED
#endif

#if DOUBLE_CONVERSION_HAS_ATTRIBUTE(uninitialized)
#define DOUBLE_CONVERSION_STACK_UNINITIALIZED __attribute__((uninitialized))
#else
#define DOUBLE_CONVERSION_STACK_UNINITIALIZED
#endif
#if defined(DOUBLE_CONVERSION_NON_PREFIXED_MACROS) && !defined(STACK_UNINITIALIZED)
#define STACK_UNINITIALIZED DOUBLE_CONVERSION_STACK_UNINITIALIZED
#endif

// Double operations detection based on target architecture.
// Linux uses a 80bit wide floating point stack on x86. This induces double
Expand Down Expand Up @@ -127,7 +151,7 @@ int main(int argc, char** argv) {
defined(_MIPS_ARCH_MIPS32R2) || defined(__ARMEB__) ||\
defined(__AARCH64EL__) || defined(__aarch64__) || defined(__AARCH64EB__) || \
defined(__riscv) || defined(__e2k__) || \
defined(__or1k__) || defined(__arc__) || \
defined(__or1k__) || defined(__arc__) || defined(__ARC64__) || \
defined(__microblaze__) || defined(__XTENSA__) || \
defined(__EMSCRIPTEN__) || defined(__wasm32__)
#define DOUBLE_CONVERSION_CORRECT_DOUBLE_OPERATIONS 1
Expand All @@ -144,6 +168,9 @@ int main(int argc, char** argv) {
#else
#error Target architecture was not detected as supported by Double-Conversion.
#endif
#if defined(DOUBLE_CONVERSION_NON_PREFIXED_MACROS) && !defined(CORRECT_DOUBLE_OPERATIONS)
#define CORRECT_DOUBLE_OPERATIONS DOUBLE_CONVERSION_CORRECT_DOUBLE_OPERATIONS
#endif

#if defined(_WIN32) && !defined(__MINGW32__)

Expand All @@ -169,7 +196,9 @@ typedef uint16_t uc16;
// Usage: instead of writing 0x1234567890123456
// write DOUBLE_CONVERSION_UINT64_2PART_C(0x12345678,90123456);
#define DOUBLE_CONVERSION_UINT64_2PART_C(a, b) (((static_cast<uint64_t>(a) << 32) + 0x##b##u))

#if defined(DOUBLE_CONVERSION_NON_PREFIXED_MACROS) && !defined(UINT64_2PART_C)
#define UINT64_2PART_C DOUBLE_CONVERSION_UINT64_2PART_C
#endif

// The expression DOUBLE_CONVERSION_ARRAY_SIZE(a) is a compile-time constant of type
// size_t which represents the number of elements of the given
Expand All @@ -180,6 +209,9 @@ typedef uint16_t uc16;
((sizeof(a) / sizeof(*(a))) / \
static_cast<size_t>(!(sizeof(a) % sizeof(*(a)))))
#endif
#if defined(DOUBLE_CONVERSION_NON_PREFIXED_MACROS) && !defined(ARRAY_SIZE)
#define ARRAY_SIZE DOUBLE_CONVERSION_ARRAY_SIZE
#endif

// A macro to disallow the evil copy constructor and operator= functions
// This should be used in the private: declarations for a class
Expand All @@ -188,6 +220,9 @@ typedef uint16_t uc16;
TypeName(const TypeName&); \
void operator=(const TypeName&)
#endif
#if defined(DOUBLE_CONVERSION_NON_PREFIXED_MACROS) && !defined(DC_DISALLOW_COPY_AND_ASSIGN)
#define DC_DISALLOW_COPY_AND_ASSIGN DOUBLE_CONVERSION_DISALLOW_COPY_AND_ASSIGN
#endif

// A macro to disallow all the implicit constructors, namely the
// default constructor, copy constructor and operator= functions.
Expand All @@ -200,6 +235,9 @@ typedef uint16_t uc16;
TypeName(); \
DOUBLE_CONVERSION_DISALLOW_COPY_AND_ASSIGN(TypeName)
#endif
#if defined(DOUBLE_CONVERSION_NON_PREFIXED_MACROS) && !defined(DC_DISALLOW_IMPLICIT_CONSTRUCTORS)
#define DC_DISALLOW_IMPLICIT_CONSTRUCTORS DOUBLE_CONVERSION_DISALLOW_IMPLICIT_CONSTRUCTORS
#endif

// ICU PATCH: Wrap in ICU namespace
U_NAMESPACE_BEGIN
Expand Down
34 changes: 34 additions & 0 deletions vendor/double-conversion/upstream/.github/workflows/cmake.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: CMake

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

env:
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
BUILD_TYPE: Debug

jobs:
build:
# The CMake configure and build commands are platform agnostic and should work equally well on Windows or Mac.
# You can convert this to a matrix build if you need cross-platform coverage.
# See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- name: Configure CMake
# Configure CMake in a 'build' subdirectory.
run: cmake -B ${{github.workspace}}/build -DBUILD_TESTING=ON

- name: Build
# Build your program with the given configuration
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}

- name: Test
working-directory: ${{github.workspace}}/build
# Execute all tests.
run: test/cctest/cctest
File renamed without changes.
2 changes: 1 addition & 1 deletion vendor/double-conversion/upstream/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.0)
project(double-conversion VERSION 3.1.5)
project(double-conversion VERSION 3.2.0)

if(BUILD_SHARED_LIBS AND MSVC)
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
Expand Down
17 changes: 17 additions & 0 deletions vendor/double-conversion/upstream/Changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
2022-01-10:
Fix quiet NANs on MIPS* and PA-RISC architectures.
Update version number.

2021-12-22:
Add support of Synopsys ARC64 architecture.
Reintroduce macros, if DOUBLE_CONVERSION_NON_PREFIXED_MACROS is set.

2021-12-04:
Update version number.

2021-10-04:
Consistently use semicolons after DOUBLE_CONVERSION_ASSERT.

2021-07-16:
Fix spelling.

2021-05-19:
Loongarch is a RISC-style command system architecture.
Add support for loongarch architecture.
Expand Down
2 changes: 1 addition & 1 deletion vendor/double-conversion/upstream/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ all:
scons debug=1

test:
./run_tests --list | tr -d '<' | xargs ./run_tests
./run_tests

.PHONY: test all
2 changes: 1 addition & 1 deletion vendor/double-conversion/upstream/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ Use `-DBUILD_TESTING=ON` to build the test executable.

cmake . -DBUILD_TESTING=ON
make
test/cctest/cctest --list | tr -d '<' | xargs test/cctest/cctest
test/cctest/cctest

[0]: http://www.scons.org/
[1]: https://cmake.org/
25 changes: 25 additions & 0 deletions vendor/double-conversion/upstream/double-conversion/ieee.h
Original file line number Diff line number Diff line change
Expand Up @@ -150,11 +150,19 @@ class Double {
}

bool IsQuietNan() const {
#if (defined(__mips__) && !defined(__mips_nan2008)) || defined(__hppa__)
return IsNan() && ((AsUint64() & kQuietNanBit) == 0);
#else
return IsNan() && ((AsUint64() & kQuietNanBit) != 0);
#endif
}

bool IsSignalingNan() const {
#if (defined(__mips__) && !defined(__mips_nan2008)) || defined(__hppa__)
return IsNan() && ((AsUint64() & kQuietNanBit) != 0);
#else
return IsNan() && ((AsUint64() & kQuietNanBit) == 0);
#endif
}


Expand Down Expand Up @@ -236,7 +244,12 @@ class Double {
private:
static const int kDenormalExponent = -kExponentBias + 1;
static const uint64_t kInfinity = DOUBLE_CONVERSION_UINT64_2PART_C(0x7FF00000, 00000000);
#if (defined(__mips__) && !defined(__mips_nan2008)) || defined(__hppa__)
static const uint64_t kNaN = DOUBLE_CONVERSION_UINT64_2PART_C(0x7FF7FFFF, FFFFFFFF);
#else
static const uint64_t kNaN = DOUBLE_CONVERSION_UINT64_2PART_C(0x7FF80000, 00000000);
#endif


const uint64_t d64_;

Expand Down Expand Up @@ -336,11 +349,19 @@ class Single {
}

bool IsQuietNan() const {
#if (defined(__mips__) && !defined(__mips_nan2008)) || defined(__hppa__)
return IsNan() && ((AsUint32() & kQuietNanBit) == 0);
#else
return IsNan() && ((AsUint32() & kQuietNanBit) != 0);
#endif
}

bool IsSignalingNan() const {
#if (defined(__mips__) && !defined(__mips_nan2008)) || defined(__hppa__)
return IsNan() && ((AsUint32() & kQuietNanBit) != 0);
#else
return IsNan() && ((AsUint32() & kQuietNanBit) == 0);
#endif
}


Expand Down Expand Up @@ -410,7 +431,11 @@ class Single {
static const int kDenormalExponent = -kExponentBias + 1;
static const int kMaxExponent = 0xFF - kExponentBias;
static const uint32_t kInfinity = 0x7F800000;
#if (defined(__mips__) && !defined(__mips_nan2008)) || defined(__hppa__)
static const uint32_t kNaN = 0x7FBFFFFF;
#else
static const uint32_t kNaN = 0x7FC00000;
#endif

const uint32_t d32_;

Expand Down
Loading

0 comments on commit c626c6d

Please sign in to comment.