[pstl] Setup the _PSTL_VERSION macro like _LIBCPP_VERSION, and add release notes

Reviewers: rodgert, MikeDvorskiy

Subscribers: mgorny, jkorous, dexonsmith, libcxx-commits

Tags: #libc

Differential Revision: https://reviews.llvm.org/D60464

llvm-svn: 358193
GitOrigin-RevId: ab38599bb1240066ece60f0b1f38d96c9901691b
diff --git a/CMakeLists.txt b/CMakeLists.txt
index f4b14f7..e72c85f 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -9,12 +9,13 @@
 list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
 
 set(PARALLELSTL_VERSION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/include/pstl/internal/pstl_config.h")
-file(STRINGS "${PARALLELSTL_VERSION_FILE}" PARALLELSTL_VERSION_SOURCE REGEX "#define PSTL_VERSION .*$")
-string(REGEX REPLACE "#define PSTL_VERSION (.*)$" "\\1" PARALLELSTL_VERSION_SOURCE "${PARALLELSTL_VERSION_SOURCE}")
-math(EXPR VERSION_MAJOR "${PARALLELSTL_VERSION_SOURCE} / 100")
-math(EXPR VERSION_MINOR "${PARALLELSTL_VERSION_SOURCE} % 100")
+file(STRINGS "${PARALLELSTL_VERSION_FILE}" PARALLELSTL_VERSION_SOURCE REGEX "#define _PSTL_VERSION .*$")
+string(REGEX REPLACE "#define _PSTL_VERSION (.*)$" "\\1" PARALLELSTL_VERSION_SOURCE "${PARALLELSTL_VERSION_SOURCE}")
+math(EXPR VERSION_MAJOR "(${PARALLELSTL_VERSION_SOURCE} / 1000)")
+math(EXPR VERSION_MINOR "((${PARALLELSTL_VERSION_SOURCE} % 1000) / 10)")
+math(EXPR VERSION_PATCH "(${PARALLELSTL_VERSION_SOURCE} % 10)")
 
-project(ParallelSTL VERSION ${VERSION_MAJOR}.${VERSION_MINOR} LANGUAGES CXX)
+project(ParallelSTL VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH} LANGUAGES CXX)
 
 option(PARALLELSTL_USE_PARALLEL_POLICIES "Enable parallel policies" OFF)
 set(PARALLELSTL_BACKEND "tbb" CACHE STRING "Threading backend; defaults to TBB")
diff --git a/docs/ReleaseNotes.rst b/docs/ReleaseNotes.rst
new file mode 100644
index 0000000..b889c55
--- /dev/null
+++ b/docs/ReleaseNotes.rst
@@ -0,0 +1,40 @@
+========================================
+PSTL 9.0.0 (In-Progress) Release Notes
+========================================
+
+.. contents::
+   :local:
+   :depth: 2
+
+Written by the `PSTL Team <https://pstl.llvm.org>`_
+
+.. warning::
+
+   These are in-progress notes for the upcoming pstl 9 release.
+   Release notes for previous releases can be found on
+   `the Download Page <https://releases.llvm.org/download.html>`_.
+
+Introduction
+============
+
+This document contains the release notes for the PSTL parallel algorithms
+library, part of the LLVM Compiler Infrastructure, release 9.0.0. Here we
+describe the status of the library in some detail, including major improvements
+from the previous release and new feature work. For the general LLVM release
+notes, see `the LLVM documentation <https://llvm.org/docs/ReleaseNotes.html>`_.
+All LLVM releases may be downloaded from the `LLVM releases web site
+<https://llvm.org/releases/>`_.
+
+Note that if you are reading this file from a source checkout or the main PSTL
+web page, this document applies to the *next* release, not the current one.
+To see the release notes for a specific release, please see the `releases
+page <https://llvm.org/releases/>`_.
+
+What's New in PSTL 9.0.0?
+=========================
+
+New Features
+------------
+
+API Changes
+-----------
diff --git a/include/pstl/internal/pstl_config.h b/include/pstl/internal/pstl_config.h
index 8d6dd9d..e6728d3 100644
--- a/include/pstl/internal/pstl_config.h
+++ b/include/pstl/internal/pstl_config.h
@@ -10,9 +10,11 @@
 #ifndef _PSTL_CONFIG_H
 #define _PSTL_CONFIG_H
 
-#define PSTL_VERSION 203
-#define PSTL_VERSION_MAJOR (PSTL_VERSION / 100)
-#define PSTL_VERSION_MINOR (PSTL_VERSION - PSTL_VERSION_MAJOR * 100)
+// The version is XYYZ, where X is major, YY is minor, and Z is patch (i.e. X.YY.Z)
+#define _PSTL_VERSION 9000
+#define _PSTL_VERSION_MAJOR (_PSTL_VERSION / 1000)
+#define _PSTL_VERSION_MINOR ((_PSTL_VERSION % 1000) / 10)
+#define _PSTL_VERSION_PATCH (_PSTL_VERSION % 10)
 
 // Check the user-defined macro for parallel policies
 #if defined(PSTL_USE_PARALLEL_POLICIES)
diff --git a/test/pstl/version.pass.cpp b/test/pstl/version.pass.cpp
new file mode 100644
index 0000000..15f6aeb
--- /dev/null
+++ b/test/pstl/version.pass.cpp
@@ -0,0 +1,17 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include <pstl/internal/pstl_config.h>
+
+
+static_assert(_PSTL_VERSION == 9000);
+static_assert(_PSTL_VERSION_MAJOR == 9);
+static_assert(_PSTL_VERSION_MINOR == 00);
+static_assert(_PSTL_VERSION_PATCH == 0);
+
+int main() { }