Skip to content

Commit 1d25671

Browse files
michaelrj-googlemordante
authored andcommitted
address comments and create runtimes target
1 parent da3b02f commit 1d25671

File tree

7 files changed

+37
-52
lines changed

7 files changed

+37
-52
lines changed

libcxx/include/__charconv/from_chars_floating_point.h

Lines changed: 12 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -31,33 +31,21 @@ _LIBCPP_BEGIN_NAMESPACE_STD
3131

3232
#if _LIBCPP_STD_VER >= 17
3333

34-
from_chars_result from_chars_floating_point(
35-
const char* __first, const char* __last, float& __value, chars_format __fmt = chars_format::general);
34+
_LIBCPP_EXPORTED_FROM_ABI from_chars_result
35+
__from_chars_floating_point(const char* __first, const char* __last, float& __value, chars_format __fmt);
3636

37-
from_chars_result from_chars_floating_point(
38-
const char* __first, const char* __last, double& __value, chars_format __fmt = chars_format::general);
37+
_LIBCPP_EXPORTED_FROM_ABI from_chars_result
38+
__from_chars_floating_point(const char* __first, const char* __last, double& __value, chars_format __fmt);
3939

40-
// template <typename _Tp, __enable_if_t<is_floating_point<_Tp>::value, int> = 0>
41-
// inline from_chars_result
42-
// from_chars(const char* __first, const char* __last, _Tp& __value, chars_format fmt = chars_format::general) {
43-
// return std::from_chars_floating_point(__first, __last, __value, fmt);
44-
// }
40+
_LIBCPP_HIDE_FROM_ABI inline from_chars_result
41+
from_chars(const char* __first, const char* __last, float& __value, chars_format __fmt = chars_format::general) {
42+
return std::__from_chars_floating_point(__first, __last, __value, __fmt);
43+
}
4544

46-
// inline from_chars_result
47-
// from_chars(const char* __first, const char* __last, float& __value, chars_format fmt = chars_format::general) {
48-
// return std::from_chars_floating_point(__first, __last, __value, fmt);
49-
// }
50-
51-
// inline from_chars_result
52-
// from_chars(const char* __first, const char* __last, double& __value, chars_format fmt = chars_format::general) {
53-
// return std::from_chars_floating_point(__first, __last, __value, fmt);
54-
// }
55-
56-
from_chars_result
57-
from_chars(const char* __first, const char* __last, float& __value, chars_format fmt = chars_format::general);
58-
59-
from_chars_result
60-
from_chars(const char* __first, const char* __last, double& __value, chars_format fmt = chars_format::general);
45+
_LIBCPP_HIDE_FROM_ABI inline from_chars_result
46+
from_chars(const char* __first, const char* __last, double& __value, chars_format __fmt = chars_format::general) {
47+
return std::__from_chars_floating_point(__first, __last, __value, __fmt);
48+
}
6149

6250
#endif // _LIBCPP_STD_VER >= 17
6351

libcxx/include/charconv

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,12 @@ namespace std {
6565
constexpr from_chars_result from_chars(const char* first, const char* last,
6666
see below& value, int base = 10); // constexpr since C++23
6767
68+
constexpr from_chars_result from_chars(const char* first, const char* last,
69+
float& value, chars_format fmt);
70+
71+
constexpr from_chars_result from_chars(const char* first, const char* last,
72+
double& value, chars_format fmt);
73+
6874
} // namespace std
6975
7076
*/

libcxx/src/CMakeLists.txt

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -177,11 +177,13 @@ endif()
177177
split_list(LIBCXX_COMPILE_FLAGS)
178178
split_list(LIBCXX_LINK_FLAGS)
179179

180+
include(FindLibcUtils)
181+
180182
# Build the shared library.
181183
if (LIBCXX_ENABLE_SHARED)
182184
add_library(cxx_shared SHARED ${exclude_from_all} ${LIBCXX_SOURCES} ${LIBCXX_HEADERS})
183-
target_include_directories(cxx_shared PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/../../libc) #TODO: Do this properly
184-
target_link_libraries(cxx_shared PUBLIC cxx-headers libcxx-libc-shared
185+
target_include_directories(cxx_shared PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
186+
target_link_libraries(cxx_shared PUBLIC cxx-headers libcxx-libc-shared llvm-libc-shared-utilities
185187
PRIVATE ${LIBCXX_LIBRARIES})
186188
set_target_properties(cxx_shared
187189
PROPERTIES
@@ -273,8 +275,8 @@ set(CMAKE_STATIC_LIBRARY_PREFIX "lib")
273275
# Build the static library.
274276
if (LIBCXX_ENABLE_STATIC)
275277
add_library(cxx_static STATIC ${exclude_from_all} ${LIBCXX_SOURCES} ${LIBCXX_HEADERS})
276-
target_include_directories(cxx_static PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/../../libc) #TODO: Do this properly
277-
target_link_libraries(cxx_static PUBLIC cxx-headers libcxx-libc-static
278+
target_include_directories(cxx_static PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
279+
target_link_libraries(cxx_static PUBLIC cxx-headers libcxx-libc-static llvm-libc-shared-utilities
278280
PRIVATE ${LIBCXX_LIBRARIES}
279281
PRIVATE libcxx-abi-static)
280282
set_target_properties(cxx_static

libcxx/src/charconv.cpp

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -76,23 +76,13 @@ to_chars_result to_chars(char* __first, char* __last, long double __value, chars
7676
}
7777

7878
from_chars_result
79-
from_chars_floating_point(const char* __first, const char* __last, float& __value, chars_format __fmt) {
79+
__from_chars_floating_point(const char* __first, const char* __last, float& __value, chars_format __fmt) {
8080
return from_chars_floating_point<float>(__first, __last, __value, __fmt);
8181
}
8282

8383
from_chars_result
84-
from_chars_floating_point(const char* __first, const char* __last, double& __value, chars_format __fmt) {
84+
__from_chars_floating_point(const char* __first, const char* __last, double& __value, chars_format __fmt) {
8585
return from_chars_floating_point<double>(__first, __last, __value, __fmt);
8686
}
8787

88-
_LIBCPP_EXPORTED_FROM_ABI from_chars_result
89-
from_chars(const char* __first, const char* __last, float& __value, chars_format __fmt) {
90-
return from_chars_floating_point(__first, __last, __value, __fmt);
91-
}
92-
93-
_LIBCPP_EXPORTED_FROM_ABI from_chars_result
94-
from_chars(const char* __first, const char* __last, double& __value, chars_format __fmt) {
95-
return from_chars_floating_point(__first, __last, __value, __fmt);
96-
}
97-
9888
_LIBCPP_END_NAMESPACE_STD

libcxx/src/include/from_chars_floating_point.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,6 @@
99
#ifndef _LIBCPP_SRC_INCLUDE_FROM_CHARS_FLOATING_POINT_H
1010
#define _LIBCPP_SRC_INCLUDE_FROM_CHARS_FLOATING_POINT_H
1111

12-
// NEVER DO THIS FOR REAL, this is just for demonstration purposes.
13-
#define LIBC_NAMESPACE libc_namespace_in_libcxx
14-
1512
// This header is in the shared LLVM-libc header library.
1613
#include "shared/str_to_float.h"
1714

libcxx/test/std/utilities/charconv/charconv.from.chars/float.pass.cpp

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010

1111
// <charconv>
1212

13-
// constexpr from_chars_result from_chars(const char* first, const char* last,
14-
// Float& value, chars_format fmt = chars_format::general)
13+
// from_chars_result from_chars(const char* first, const char* last,
14+
// Float& value, chars_format fmt = chars_format::general)
1515

1616
#include <charconv>
1717
#include "test_macros.h"
@@ -57,14 +57,8 @@ struct test_basics {
5757
}
5858
};
5959

60-
bool test() {
61-
run<test_basics>(all_floats);
62-
63-
return true;
64-
}
65-
6660
int main(int, char**) {
67-
test();
61+
run<test_basics>(all_floats);
6862

6963
return 0;
7064
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
add_library(llvm-libc-shared-utilities INTERFACE)
2+
# TODO: Reorganize the libc shared section so that it can be included without
3+
# adding the root "libc" directory to the include path.
4+
# TODO: Find a better way to solve the problem that ${CMAKE_SOURCE_DIR} is
5+
# rooted in the runtimes directory, which is why we need the ".."
6+
target_include_directories(llvm-libc-shared-utilities INTERFACE ${CMAKE_SOURCE_DIR}/../libc)
7+
target_compile_definitions(llvm-libc-shared-utilities INTERFACE LIBC_NAMESPACE=__llvm_libc_shared_utils)
8+
target_compile_features(llvm-libc-shared-utilities INTERFACE cxx_std_17)

0 commit comments

Comments
 (0)