1eb8650a7SLouis Dionne //===----------------------------------------------------------------------===//
2d2748964SZhihao Yuan //
357b08b09SChandler Carruth // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
457b08b09SChandler Carruth // See https://llvm.org/LICENSE.txt for license information.
557b08b09SChandler Carruth // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6d2748964SZhihao Yuan //
7d2748964SZhihao Yuan //===----------------------------------------------------------------------===//
8d2748964SZhihao Yuan 
9bbb0f2c7SArthur O'Dwyer #include <charconv>
10d2748964SZhihao Yuan #include <string.h>
11d2748964SZhihao Yuan 
12abb5dd6eSMark de Wever #include "include/to_chars_floating_point.h"
13abb5dd6eSMark de Wever 
14d2748964SZhihao Yuan _LIBCPP_BEGIN_NAMESPACE_STD
15d2748964SZhihao Yuan 
1689818f2dSMark de Wever #ifndef _LIBCPP_ABI_DO_NOT_EXPORT_TO_CHARS_BASE_10
1789818f2dSMark de Wever 
18d2748964SZhihao Yuan namespace __itoa
19d2748964SZhihao Yuan {
20d2748964SZhihao Yuan 
21a15ae413SMark de Wever _LIBCPP_FUNC_VIS char*
__u32toa(uint32_t value,char * buffer)225601305fSLouis Dionne __u32toa(uint32_t value, char* buffer) noexcept
23d2748964SZhihao Yuan {
24*3561ee58SMark de Wever 	return __base_10_u32(buffer, value);
25d2748964SZhihao Yuan }
26d2748964SZhihao Yuan 
27a15ae413SMark de Wever _LIBCPP_FUNC_VIS char*
__u64toa(uint64_t value,char * buffer)285601305fSLouis Dionne __u64toa(uint64_t value, char* buffer) noexcept
29d2748964SZhihao Yuan {
30*3561ee58SMark de Wever 	return __base_10_u64(buffer, value);
31d2748964SZhihao Yuan }
32d2748964SZhihao Yuan 
33d2748964SZhihao Yuan }  // namespace __itoa
34d2748964SZhihao Yuan 
3589818f2dSMark de Wever #endif // _LIBCPP_ABI_DO_NOT_EXPORT_TO_CHARS_BASE_10
3689818f2dSMark de Wever 
37abb5dd6eSMark de Wever // The original version of floating-point to_chars was written by Microsoft and
38abb5dd6eSMark de Wever // contributed with the following license.
39abb5dd6eSMark de Wever 
40abb5dd6eSMark de Wever // Copyright (c) Microsoft Corporation.
41abb5dd6eSMark de Wever // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
42abb5dd6eSMark de Wever 
43abb5dd6eSMark de Wever // This implementation is dedicated to the memory of Mary and Thavatchai.
44abb5dd6eSMark de Wever 
to_chars(char * __first,char * __last,float __value)45abb5dd6eSMark de Wever to_chars_result to_chars(char* __first, char* __last, float __value) {
46abb5dd6eSMark de Wever   return _Floating_to_chars<_Floating_to_chars_overload::_Plain>(__first, __last, __value, chars_format{}, 0);
47abb5dd6eSMark de Wever }
48abb5dd6eSMark de Wever 
to_chars(char * __first,char * __last,double __value)49abb5dd6eSMark de Wever to_chars_result to_chars(char* __first, char* __last, double __value) {
50abb5dd6eSMark de Wever   return _Floating_to_chars<_Floating_to_chars_overload::_Plain>(__first, __last, __value, chars_format{}, 0);
51abb5dd6eSMark de Wever }
52abb5dd6eSMark de Wever 
to_chars(char * __first,char * __last,long double __value)53abb5dd6eSMark de Wever to_chars_result to_chars(char* __first, char* __last, long double __value) {
54abb5dd6eSMark de Wever   return _Floating_to_chars<_Floating_to_chars_overload::_Plain>(__first, __last, static_cast<double>(__value),
55abb5dd6eSMark de Wever                                                                  chars_format{}, 0);
56abb5dd6eSMark de Wever }
57abb5dd6eSMark de Wever 
to_chars(char * __first,char * __last,float __value,chars_format __fmt)58abb5dd6eSMark de Wever to_chars_result to_chars(char* __first, char* __last, float __value, chars_format __fmt) {
59abb5dd6eSMark de Wever   return _Floating_to_chars<_Floating_to_chars_overload::_Format_only>(__first, __last, __value, __fmt, 0);
60abb5dd6eSMark de Wever }
61abb5dd6eSMark de Wever 
to_chars(char * __first,char * __last,double __value,chars_format __fmt)62abb5dd6eSMark de Wever to_chars_result to_chars(char* __first, char* __last, double __value, chars_format __fmt) {
63abb5dd6eSMark de Wever   return _Floating_to_chars<_Floating_to_chars_overload::_Format_only>(__first, __last, __value, __fmt, 0);
64abb5dd6eSMark de Wever }
65abb5dd6eSMark de Wever 
to_chars(char * __first,char * __last,long double __value,chars_format __fmt)66abb5dd6eSMark de Wever to_chars_result to_chars(char* __first, char* __last, long double __value, chars_format __fmt) {
67abb5dd6eSMark de Wever   return _Floating_to_chars<_Floating_to_chars_overload::_Format_only>(__first, __last, static_cast<double>(__value),
68abb5dd6eSMark de Wever                                                                        __fmt, 0);
69abb5dd6eSMark de Wever }
70abb5dd6eSMark de Wever 
to_chars(char * __first,char * __last,float __value,chars_format __fmt,int __precision)71abb5dd6eSMark de Wever to_chars_result to_chars(char* __first, char* __last, float __value, chars_format __fmt, int __precision) {
72abb5dd6eSMark de Wever   return _Floating_to_chars<_Floating_to_chars_overload::_Format_precision>(__first, __last, __value, __fmt,
73abb5dd6eSMark de Wever                                                                             __precision);
74abb5dd6eSMark de Wever }
75abb5dd6eSMark de Wever 
to_chars(char * __first,char * __last,double __value,chars_format __fmt,int __precision)76abb5dd6eSMark de Wever to_chars_result to_chars(char* __first, char* __last, double __value, chars_format __fmt, int __precision) {
77abb5dd6eSMark de Wever   return _Floating_to_chars<_Floating_to_chars_overload::_Format_precision>(__first, __last, __value, __fmt,
78abb5dd6eSMark de Wever                                                                             __precision);
79abb5dd6eSMark de Wever }
80abb5dd6eSMark de Wever 
to_chars(char * __first,char * __last,long double __value,chars_format __fmt,int __precision)81abb5dd6eSMark de Wever to_chars_result to_chars(char* __first, char* __last, long double __value, chars_format __fmt, int __precision) {
82abb5dd6eSMark de Wever   return _Floating_to_chars<_Floating_to_chars_overload::_Format_precision>(
83abb5dd6eSMark de Wever       __first, __last, static_cast<double>(__value), __fmt, __precision);
84abb5dd6eSMark de Wever }
85abb5dd6eSMark de Wever 
86d2748964SZhihao Yuan _LIBCPP_END_NAMESPACE_STD
87