Skip to content

Commit

Permalink
Revert "Microsoft's floating-point to_chars powered by Ryu and Ryu Pr…
Browse files Browse the repository at this point in the history
…intf"

This reverts commit a8025e0 since
it triggers PR52584 with debug info enabled.
  • Loading branch information
petrhosek committed Dec 7, 2021
1 parent 2ccab2e commit ae53d02
Show file tree
Hide file tree
Showing 48 changed files with 18 additions and 73,318 deletions.
15 changes: 0 additions & 15 deletions libcxx/CREDITS.TXT
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@ N: Saleem Abdulrasool
E: compnerd@compnerd.org
D: Minor patches and Linux fixes.

N: Ulf Adams
D: Invented the Ryu and Ryu Printf algorithms used in floating-point to_chars, and wrote the initial code.

N: Muiez Ahmed
E: muiez@ibm.com
D: z/OS port.
Expand All @@ -31,9 +28,6 @@ N: Holger Arnold
E: holgerar@gmail.com
D: Minor fix.

N: Jorg Brown
D: Ported floating-point to_chars from MSVC to libc++.

N: David Chisnall
E: theraven at theravensnest dot org
D: FreeBSD and Solaris ports, libcxxrt support, some atomics work.
Expand Down Expand Up @@ -87,14 +81,6 @@ N: Argyrios Kyrtzidis
E: kyrtzidis@apple.com
D: Bug fixes.

N: Stephan T. Lavavej
E: stl@microsoft.com
E: stl@nuwen.net
D: Implemented floating-point to_chars.

N: Microsoft Corporation
D: Contributed floating-point to_chars.

N: Bruce Mitchener, Jr.
E: bruce.mitchener@gmail.com
D: Emscripten-related changes.
Expand Down Expand Up @@ -166,7 +152,6 @@ D: Minor bug fix.
N: Mark de Wever
E: koraq at xs4all dot nl
D: Format library support.
D: Finalized the porting of MSVC's to_chars to libc++.

N: Zhang Xiongpang
E: zhangxiongpang@gmail.com
Expand Down
4 changes: 0 additions & 4 deletions libcxx/docs/ReleaseNotes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,6 @@ New Features
behavior of standard algorithms (e.g. equal elements in ``std::sort`` or
randomization of both sides of partition for ``std::nth_element``)

- Floating-point support for ``std::to_chars`` support has been added.
Thanks to Stephan T. Lavavej and Microsoft for providing their implemention
to libc++.

API Changes
-----------

Expand Down
1 change: 0 additions & 1 deletion libcxx/docs/Status/Cxx17.rst
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ Paper Status

.. note::

.. [#note-P0067] P0067: ``std::(to|from)_chars`` for integrals has been available since version 7.0. ``std::to_chars`` for ``float`` and ``double`` since version 14.0 ``std::to_chars`` for ``long double`` uses the implementation for ``double``.
.. [#note-P0607] P0607: The parts of P0607 that are not done are the ``<regex>`` bits.
Expand Down
2 changes: 1 addition & 1 deletion libcxx/docs/Status/Cxx17Papers.csv
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
"`P0394r4 <https://wg21.link/P0394r4>`__","LWG","Hotel Parallelifornia: terminate() for Parallel Algorithms Exception Handling","Oulu","",""
"","","","","",""
"`P0003R5 <https://wg21.link/P0003R5>`__","LWG","Removing Deprecated Exception Specifications from C++17","Issaquah","|Complete|","5.0"
"`P0067R5 <https://wg21.link/P0067R5>`__","LWG","Elementary string conversions, revision 5","Issaquah","|Partial| [#note-P0067]",""
"`P0067R5 <https://wg21.link/P0067R5>`__","LWG","Elementary string conversions, revision 5","Issaquah","|Partial|",""
"`P0403R1 <https://wg21.link/P0403R1>`__","LWG","Literal suffixes for ``basic_string_view``\ ","Issaquah","|Complete|","4.0"
"`P0414R2 <https://wg21.link/P0414R2>`__","LWG","Merging shared_ptr changes from Library Fundamentals to C++17","Issaquah","|Complete|","11.0"
"`P0418R2 <https://wg21.link/P0418R2>`__","LWG","Fail or succeed: there is no atomic lattice","Issaquah","",""
Expand Down
7 changes: 0 additions & 7 deletions libcxx/include/__availability
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,6 @@
// This controls the availability of std::to_chars.
# define _LIBCPP_AVAILABILITY_TO_CHARS

// This controls the availability of floating-point std::to_chars functions.
// These overloads were added later than the integer overloads.
# define _LIBCPP_AVAILABILITY_TO_CHARS_FLOATING_POINT

// This controls the availability of the C++20 synchronization library,
// which requires shared library support for various operations
// (see libcxx/src/atomic.cpp).
Expand Down Expand Up @@ -226,9 +222,6 @@
# define _LIBCPP_AVAILABILITY_TO_CHARS \
_LIBCPP_AVAILABILITY_FILESYSTEM

# define _LIBCPP_AVAILABILITY_TO_CHARS_FLOATING_POINT \
__attribute__((unavailable))

# define _LIBCPP_AVAILABILITY_SYNC \
__attribute__((availability(macosx,strict,introduced=11.0))) \
__attribute__((availability(ios,strict,introduced=14.0))) \
Expand Down
32 changes: 0 additions & 32 deletions libcxx/include/charconv
Original file line number Diff line number Diff line change
Expand Up @@ -598,38 +598,6 @@ from_chars(const char* __first, const char* __last, _Tp& __value, int __base)
return __from_chars_integral(__first, __last, __value, __base);
}

// Floating-point implementation starts here.
// Unlike the other parts of charconv this is only available in C++17 and newer.
#if _LIBCPP_STD_VER > 14

_LIBCPP_AVAILABILITY_TO_CHARS_FLOATING_POINT _LIBCPP_FUNC_VIS
to_chars_result to_chars(char* __first, char* __last, float __value);

_LIBCPP_AVAILABILITY_TO_CHARS_FLOATING_POINT _LIBCPP_FUNC_VIS
to_chars_result to_chars(char* __first, char* __last, double __value);

_LIBCPP_AVAILABILITY_TO_CHARS_FLOATING_POINT _LIBCPP_FUNC_VIS
to_chars_result to_chars(char* __first, char* __last, long double __value);

_LIBCPP_AVAILABILITY_TO_CHARS_FLOATING_POINT _LIBCPP_FUNC_VIS
to_chars_result to_chars(char* __first, char* __last, float __value, chars_format __fmt);

_LIBCPP_AVAILABILITY_TO_CHARS_FLOATING_POINT _LIBCPP_FUNC_VIS
to_chars_result to_chars(char* __first, char* __last, double __value, chars_format __fmt);

_LIBCPP_AVAILABILITY_TO_CHARS_FLOATING_POINT _LIBCPP_FUNC_VIS
to_chars_result to_chars(char* __first, char* __last, long double __value, chars_format __fmt);

_LIBCPP_AVAILABILITY_TO_CHARS_FLOATING_POINT _LIBCPP_FUNC_VIS
to_chars_result to_chars(char* __first, char* __last, float __value, chars_format __fmt, int __precision);

_LIBCPP_AVAILABILITY_TO_CHARS_FLOATING_POINT _LIBCPP_FUNC_VIS
to_chars_result to_chars(char* __first, char* __last, double __value, chars_format __fmt, int __precision);

_LIBCPP_AVAILABILITY_TO_CHARS_FLOATING_POINT _LIBCPP_FUNC_VIS
to_chars_result to_chars(char* __first, char* __last, long double __value, chars_format __fmt, int __precision);

# endif // _LIBCPP_STD_VER > 14
#endif // _LIBCPP_CXX03_LANG

_LIBCPP_END_NAMESPACE_STD
Expand Down
42 changes: 0 additions & 42 deletions libcxx/lib/abi/CHANGELOG.TXT
Original file line number Diff line number Diff line change
Expand Up @@ -16,48 +16,6 @@ New entries should be added directly below the "Version" header.
Version 14.0
------------

* [libc++] `to_chars` for floating point.

This commit added the `to_chars` implementation for floating point values.
The entire implementation resides in the dylib and the functions specified
in the Standard are now part of the ABI.

arm64-apple-darwin
------------------
Symbol added: _ZNSt3__18to_charsEPcS0_d
Symbol added: _ZNSt3__18to_charsEPcS0_dNS_12chars_formatE
Symbol added: _ZNSt3__18to_charsEPcS0_dNS_12chars_formatEi
Symbol added: _ZNSt3__18to_charsEPcS0_e
Symbol added: _ZNSt3__18to_charsEPcS0_eNS_12chars_formatE
Symbol added: _ZNSt3__18to_charsEPcS0_eNS_12chars_formatEi
Symbol added: _ZNSt3__18to_charsEPcS0_f
Symbol added: _ZNSt3__18to_charsEPcS0_fNS_12chars_formatE
Symbol added: _ZNSt3__18to_charsEPcS0_fNS_12chars_formatEi

x86_64-apple-darwin
-------------------
Symbol added: _ZNSt3__18to_charsEPcS0_d
Symbol added: _ZNSt3__18to_charsEPcS0_dNS_12chars_formatE
Symbol added: _ZNSt3__18to_charsEPcS0_dNS_12chars_formatEi
Symbol added: _ZNSt3__18to_charsEPcS0_e
Symbol added: _ZNSt3__18to_charsEPcS0_eNS_12chars_formatE
Symbol added: _ZNSt3__18to_charsEPcS0_eNS_12chars_formatEi
Symbol added: _ZNSt3__18to_charsEPcS0_f
Symbol added: _ZNSt3__18to_charsEPcS0_fNS_12chars_formatE
Symbol added: _ZNSt3__18to_charsEPcS0_fNS_12chars_formatEi

x86_64-unknown-linux-gnu
------------------------
Symbol added: _ZNSt3__18to_charsEPcS0_d
Symbol added: _ZNSt3__18to_charsEPcS0_dNS_12chars_formatE
Symbol added: _ZNSt3__18to_charsEPcS0_dNS_12chars_formatEi
Symbol added: _ZNSt3__18to_charsEPcS0_e
Symbol added: _ZNSt3__18to_charsEPcS0_eNS_12chars_formatE
Symbol added: _ZNSt3__18to_charsEPcS0_eNS_12chars_formatEi
Symbol added: _ZNSt3__18to_charsEPcS0_f
Symbol added: _ZNSt3__18to_charsEPcS0_fNS_12chars_formatE
Symbol added: _ZNSt3__18to_charsEPcS0_fNS_12chars_formatEi

* [libc++] Resolve missing table_size symbol

This commit added an out-of-line definition for `table_size` in the library.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1879,15 +1879,6 @@
{'is_defined': True, 'name': '__ZNSt3__18time_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEE2idE', 'size': 0, 'type': 'OBJECT'}
{'is_defined': True, 'name': '__ZNSt3__18time_putIcNS_19ostreambuf_iteratorIcNS_11char_traitsIcEEEEE2idE', 'size': 0, 'type': 'OBJECT'}
{'is_defined': True, 'name': '__ZNSt3__18time_putIwNS_19ostreambuf_iteratorIwNS_11char_traitsIwEEEEE2idE', 'size': 0, 'type': 'OBJECT'}
{'is_defined': True, 'name': '__ZNSt3__18to_charsEPcS0_d', 'type': 'FUNC'}
{'is_defined': True, 'name': '__ZNSt3__18to_charsEPcS0_dNS_12chars_formatE', 'type': 'FUNC'}
{'is_defined': True, 'name': '__ZNSt3__18to_charsEPcS0_dNS_12chars_formatEi', 'type': 'FUNC'}
{'is_defined': True, 'name': '__ZNSt3__18to_charsEPcS0_e', 'type': 'FUNC'}
{'is_defined': True, 'name': '__ZNSt3__18to_charsEPcS0_eNS_12chars_formatE', 'type': 'FUNC'}
{'is_defined': True, 'name': '__ZNSt3__18to_charsEPcS0_eNS_12chars_formatEi', 'type': 'FUNC'}
{'is_defined': True, 'name': '__ZNSt3__18to_charsEPcS0_f', 'type': 'FUNC'}
{'is_defined': True, 'name': '__ZNSt3__18to_charsEPcS0_fNS_12chars_formatE', 'type': 'FUNC'}
{'is_defined': True, 'name': '__ZNSt3__18to_charsEPcS0_fNS_12chars_formatEi', 'type': 'FUNC'}
{'is_defined': True, 'name': '__ZNSt3__18valarrayImE6resizeEmm', 'type': 'FUNC'}
{'is_defined': True, 'name': '__ZNSt3__18valarrayImEC1Em', 'type': 'FUNC'}
{'is_defined': True, 'name': '__ZNSt3__18valarrayImEC2Em', 'type': 'FUNC'}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1879,15 +1879,6 @@
{'is_defined': True, 'name': '__ZNSt3__18time_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEE2idE', 'size': 0, 'type': 'OBJECT'}
{'is_defined': True, 'name': '__ZNSt3__18time_putIcNS_19ostreambuf_iteratorIcNS_11char_traitsIcEEEEE2idE', 'size': 0, 'type': 'OBJECT'}
{'is_defined': True, 'name': '__ZNSt3__18time_putIwNS_19ostreambuf_iteratorIwNS_11char_traitsIwEEEEE2idE', 'size': 0, 'type': 'OBJECT'}
{'is_defined': True, 'name': '__ZNSt3__18to_charsEPcS0_d', 'type': 'FUNC'}
{'is_defined': True, 'name': '__ZNSt3__18to_charsEPcS0_dNS_12chars_formatE', 'type': 'FUNC'}
{'is_defined': True, 'name': '__ZNSt3__18to_charsEPcS0_dNS_12chars_formatEi', 'type': 'FUNC'}
{'is_defined': True, 'name': '__ZNSt3__18to_charsEPcS0_e', 'type': 'FUNC'}
{'is_defined': True, 'name': '__ZNSt3__18to_charsEPcS0_eNS_12chars_formatE', 'type': 'FUNC'}
{'is_defined': True, 'name': '__ZNSt3__18to_charsEPcS0_eNS_12chars_formatEi', 'type': 'FUNC'}
{'is_defined': True, 'name': '__ZNSt3__18to_charsEPcS0_f', 'type': 'FUNC'}
{'is_defined': True, 'name': '__ZNSt3__18to_charsEPcS0_fNS_12chars_formatE', 'type': 'FUNC'}
{'is_defined': True, 'name': '__ZNSt3__18to_charsEPcS0_fNS_12chars_formatEi', 'type': 'FUNC'}
{'is_defined': True, 'name': '__ZNSt3__18valarrayImE6resizeEmm', 'type': 'FUNC'}
{'is_defined': True, 'name': '__ZNSt3__18valarrayImEC1Em', 'type': 'FUNC'}
{'is_defined': True, 'name': '__ZNSt3__18valarrayImEC2Em', 'type': 'FUNC'}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1573,15 +1573,6 @@
{'is_defined': True, 'name': '_ZNSt3__18time_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEE2idE', 'size': 16, 'type': 'OBJECT'}
{'is_defined': True, 'name': '_ZNSt3__18time_putIcNS_19ostreambuf_iteratorIcNS_11char_traitsIcEEEEE2idE', 'size': 16, 'type': 'OBJECT'}
{'is_defined': True, 'name': '_ZNSt3__18time_putIwNS_19ostreambuf_iteratorIwNS_11char_traitsIwEEEEE2idE', 'size': 16, 'type': 'OBJECT'}
{'is_defined': True, 'name': '_ZNSt3__18to_charsEPcS0_d', 'type': 'FUNC'}
{'is_defined': True, 'name': '_ZNSt3__18to_charsEPcS0_dNS_12chars_formatE', 'type': 'FUNC'}
{'is_defined': True, 'name': '_ZNSt3__18to_charsEPcS0_dNS_12chars_formatEi', 'type': 'FUNC'}
{'is_defined': True, 'name': '_ZNSt3__18to_charsEPcS0_e', 'type': 'FUNC'}
{'is_defined': True, 'name': '_ZNSt3__18to_charsEPcS0_eNS_12chars_formatE', 'type': 'FUNC'}
{'is_defined': True, 'name': '_ZNSt3__18to_charsEPcS0_eNS_12chars_formatEi', 'type': 'FUNC'}
{'is_defined': True, 'name': '_ZNSt3__18to_charsEPcS0_f', 'type': 'FUNC'}
{'is_defined': True, 'name': '_ZNSt3__18to_charsEPcS0_fNS_12chars_formatE', 'type': 'FUNC'}
{'is_defined': True, 'name': '_ZNSt3__18to_charsEPcS0_fNS_12chars_formatEi', 'type': 'FUNC'}
{'is_defined': True, 'name': '_ZNSt3__18valarrayImE6resizeEmm', 'type': 'FUNC'}
{'is_defined': True, 'name': '_ZNSt3__18valarrayImEC1Em', 'type': 'FUNC'}
{'is_defined': True, 'name': '_ZNSt3__18valarrayImEC2Em', 'type': 'FUNC'}
Expand Down
13 changes: 0 additions & 13 deletions libcxx/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,26 +19,13 @@ set(LIBCXX_SOURCES
include/atomic_support.h
include/config_elast.h
include/refstring.h
include/ryu/common.h
include/ryu/d2fixed.h
include/ryu/d2fixed_full_table.h
include/ryu/d2s.h
include/ryu/d2s_full_table.h
include/ryu/d2s_intrinsics.h
include/ryu/digit_table.h
include/ryu/f2s.h
include/ryu/ryu.h
include/to_chars_floating_point.h
legacy_pointer_safety.cpp
memory.cpp
mutex.cpp
mutex_destructor.cpp
new.cpp
optional.cpp
random_shuffle.cpp
ryu/d2fixed.cpp
ryu/d2s.cpp
ryu/f2s.cpp
shared_mutex.cpp
stdexcept.cpp
string.cpp
Expand Down
70 changes: 17 additions & 53 deletions libcxx/src/charconv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,27 @@
#include "charconv"
#include <string.h>

#include "include/ryu/digit_table.h"
#include "include/to_chars_floating_point.h"

_LIBCPP_BEGIN_NAMESPACE_STD

namespace __itoa
{

static constexpr char cDigitsLut[200] = {
'0', '0', '0', '1', '0', '2', '0', '3', '0', '4', '0', '5', '0', '6', '0',
'7', '0', '8', '0', '9', '1', '0', '1', '1', '1', '2', '1', '3', '1', '4',
'1', '5', '1', '6', '1', '7', '1', '8', '1', '9', '2', '0', '2', '1', '2',
'2', '2', '3', '2', '4', '2', '5', '2', '6', '2', '7', '2', '8', '2', '9',
'3', '0', '3', '1', '3', '2', '3', '3', '3', '4', '3', '5', '3', '6', '3',
'7', '3', '8', '3', '9', '4', '0', '4', '1', '4', '2', '4', '3', '4', '4',
'4', '5', '4', '6', '4', '7', '4', '8', '4', '9', '5', '0', '5', '1', '5',
'2', '5', '3', '5', '4', '5', '5', '5', '6', '5', '7', '5', '8', '5', '9',
'6', '0', '6', '1', '6', '2', '6', '3', '6', '4', '6', '5', '6', '6', '6',
'7', '6', '8', '6', '9', '7', '0', '7', '1', '7', '2', '7', '3', '7', '4',
'7', '5', '7', '6', '7', '7', '7', '8', '7', '9', '8', '0', '8', '1', '8',
'2', '8', '3', '8', '4', '8', '5', '8', '6', '8', '7', '8', '8', '8', '9',
'9', '0', '9', '1', '9', '2', '9', '3', '9', '4', '9', '5', '9', '6', '9',
'7', '9', '8', '9', '9'};

template <typename T>
inline _LIBCPP_INLINE_VISIBILITY char*
append1(char* buffer, T i) noexcept
Expand All @@ -29,7 +42,7 @@ template <typename T>
inline _LIBCPP_INLINE_VISIBILITY char*
append2(char* buffer, T i) noexcept
{
memcpy(buffer, &__DIGIT_TABLE[(i)*2], 2);
memcpy(buffer, &cDigitsLut[(i)*2], 2);
return buffer + 2;
}

Expand Down Expand Up @@ -144,53 +157,4 @@ __u64toa(uint64_t value, char* buffer) noexcept

} // namespace __itoa

// The original version of floating-point to_chars was written by Microsoft and
// contributed with the following license.

// Copyright (c) Microsoft Corporation.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

// This implementation is dedicated to the memory of Mary and Thavatchai.

to_chars_result to_chars(char* __first, char* __last, float __value) {
return _Floating_to_chars<_Floating_to_chars_overload::_Plain>(__first, __last, __value, chars_format{}, 0);
}

to_chars_result to_chars(char* __first, char* __last, double __value) {
return _Floating_to_chars<_Floating_to_chars_overload::_Plain>(__first, __last, __value, chars_format{}, 0);
}

to_chars_result to_chars(char* __first, char* __last, long double __value) {
return _Floating_to_chars<_Floating_to_chars_overload::_Plain>(__first, __last, static_cast<double>(__value),
chars_format{}, 0);
}

to_chars_result to_chars(char* __first, char* __last, float __value, chars_format __fmt) {
return _Floating_to_chars<_Floating_to_chars_overload::_Format_only>(__first, __last, __value, __fmt, 0);
}

to_chars_result to_chars(char* __first, char* __last, double __value, chars_format __fmt) {
return _Floating_to_chars<_Floating_to_chars_overload::_Format_only>(__first, __last, __value, __fmt, 0);
}

to_chars_result to_chars(char* __first, char* __last, long double __value, chars_format __fmt) {
return _Floating_to_chars<_Floating_to_chars_overload::_Format_only>(__first, __last, static_cast<double>(__value),
__fmt, 0);
}

to_chars_result to_chars(char* __first, char* __last, float __value, chars_format __fmt, int __precision) {
return _Floating_to_chars<_Floating_to_chars_overload::_Format_precision>(__first, __last, __value, __fmt,
__precision);
}

to_chars_result to_chars(char* __first, char* __last, double __value, chars_format __fmt, int __precision) {
return _Floating_to_chars<_Floating_to_chars_overload::_Format_precision>(__first, __last, __value, __fmt,
__precision);
}

to_chars_result to_chars(char* __first, char* __last, long double __value, chars_format __fmt, int __precision) {
return _Floating_to_chars<_Floating_to_chars_overload::_Format_precision>(
__first, __last, static_cast<double>(__value), __fmt, __precision);
}

_LIBCPP_END_NAMESPACE_STD
Loading

0 comments on commit ae53d02

Please sign in to comment.