summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--libcxx/include/__config7
-rw-r--r--libcxx/include/__libcpp_version1
-rw-r--r--libcxx/lib/abi/CHANGELOG.TXT5
-rw-r--r--libcxx/lib/abi/x86_64-linux-gnu.abilist1
-rw-r--r--libcxx/src/libcpp_version.cpp14
-rw-r--r--libcxx/test/libcxx/version.pass.cpp29
6 files changed, 57 insertions, 0 deletions
diff --git a/libcxx/include/__config b/libcxx/include/__config
index 5b3c6947c5d..19377b17b12 100644
--- a/libcxx/include/__config
+++ b/libcxx/include/__config
@@ -908,6 +908,13 @@ extern "C" void __sanitizer_annotate_contiguous_container(
#define _LIBCPP_HAS_NO_BUILTIN_ADDRESSOF
#endif
+_LIBCPP_BEGIN_NAMESPACE_STD
+_LIBCPP_FUNC_VIS _LIBCPP_WEAK int __libcpp_library_version();
+_LIBCPP_END_NAMESPACE_STD
+
+#define _LIBCPP_LIBRARY_VERSION \
+ (_VSTD::__libcpp_library_version ? _VSTD::__libcpp_library_version() : -1)
+
#endif // __cplusplus
#endif // _LIBCPP_CONFIG
diff --git a/libcxx/include/__libcpp_version b/libcxx/include/__libcpp_version
new file mode 100644
index 00000000000..a2113715a3e
--- /dev/null
+++ b/libcxx/include/__libcpp_version
@@ -0,0 +1 @@
+4000 \ No newline at end of file
diff --git a/libcxx/lib/abi/CHANGELOG.TXT b/libcxx/lib/abi/CHANGELOG.TXT
index e71f09273d5..84a383ecc6d 100644
--- a/libcxx/lib/abi/CHANGELOG.TXT
+++ b/libcxx/lib/abi/CHANGELOG.TXT
@@ -16,6 +16,11 @@ New entries should be added directly below the "Version" header.
Version 4.0
-----------
+* rTBD - Add __libcpp_library_version
+
+ all platforms
+ -------------
+ Symbol added: _ZNSt3__124__libcpp_library_versionEv
* r285101 - Add -fvisibility-inlines-hidden when building libc++.
diff --git a/libcxx/lib/abi/x86_64-linux-gnu.abilist b/libcxx/lib/abi/x86_64-linux-gnu.abilist
index b6e7ce4c040..fd03c68417b 100644
--- a/libcxx/lib/abi/x86_64-linux-gnu.abilist
+++ b/libcxx/lib/abi/x86_64-linux-gnu.abilist
@@ -1141,6 +1141,7 @@
{'type': 'FUNC', 'name': '_ZNSt3__121recursive_timed_mutexD1Ev'}
{'type': 'FUNC', 'name': '_ZNSt3__121recursive_timed_mutexD2Ev'}
{'type': 'FUNC', 'name': '_ZNSt3__121undeclare_no_pointersEPcm'}
+{'type': 'FUNC', 'name': '_ZNSt3__124__libcpp_library_versionEv'}
{'type': 'FUNC', 'name': '_ZNSt3__125__num_get_signed_integralIlEET_PKcS3_Rji'}
{'type': 'FUNC', 'name': '_ZNSt3__125__num_get_signed_integralIxEET_PKcS3_Rji'}
{'type': 'FUNC', 'name': '_ZNSt3__125notify_all_at_thread_exitERNS_18condition_variableENS_11unique_lockINS_5mutexEEE'}
diff --git a/libcxx/src/libcpp_version.cpp b/libcxx/src/libcpp_version.cpp
new file mode 100644
index 00000000000..b63f8558ca4
--- /dev/null
+++ b/libcxx/src/libcpp_version.cpp
@@ -0,0 +1,14 @@
+#include "__config"
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+// Test that _LIBCPP_VERSION and __libcpp_version are in sync.
+// The __libcpp_version file stores only a number representing the libc++
+// version so it can be easily parsed by clang.
+static_assert(_LIBCPP_VERSION ==
+#include "__libcpp_version"
+ , "version file does not match");
+
+int __libcpp_library_version() { return _LIBCPP_VERSION; }
+
+_LIBCPP_END_NAMESPACE_STD
diff --git a/libcxx/test/libcxx/version.pass.cpp b/libcxx/test/libcxx/version.pass.cpp
new file mode 100644
index 00000000000..8a29c5bcd36
--- /dev/null
+++ b/libcxx/test/libcxx/version.pass.cpp
@@ -0,0 +1,29 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// Test the _LIBCPP_VERSION and _LIBCPP_LIBRARY_VERSION macros
+
+#include <__config>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION must be defined
+#endif
+
+#ifndef _LIBCPP_LIBRARY_VERSION
+#error _LIBCPP_LIBRARY_VERSION must be defined
+#endif
+
+#include <cassert>
+
+int main() {
+ assert(_LIBCPP_VERSION == _LIBCPP_LIBRARY_VERSION);
+ assert(std::__libcpp_library_version);
+ assert(_LIBCPP_LIBRARY_VERSION == std::__libcpp_library_version());
+}
OpenPOWER on IntegriCloud