File 1231-epp-Add-the-pre-defined-macro-OTP_RELEASE.patch of Package erlang

From 55e852080d459b9b2be18cf41de60c3338f266af Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bj=C3=B6rn=20Gustavsson?= <bjorn@erlang.org>
Date: Tue, 29 Sep 2015 08:40:09 +0200
Subject: [PATCH 1/4] epp: Add the pre-defined macro OTP_RELEASE

Add a new pre-defined macro called OTP_RELEASE that will expand
to an integer being the OTP version. Thus, in OTP 19 the value will
be the integer 19.

The OTP_RELEASE macro is particularly useful in order to have
different source code depending on new language features or new
features in the type specification syntax. Those features are only
introduced in major versions of OTP.

To be truly useful, the -if preprocessor directive need to be
implemented. That is the purpose of the next commit.

Code that will need to work in both OTP 18 and OTP 19 can be
structured in the following way:

-ifdef(OTP_RELEASE).
%% Code that only works in OTP 19 and later.
-else.
%% Code that will work in OTP 18.
-endif.
---
 lib/stdlib/src/epp.erl        | 4 +++-
 lib/stdlib/test/epp_SUITE.erl | 3 ++-
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/lib/stdlib/src/epp.erl b/lib/stdlib/src/epp.erl
index 77cc88eb08..e823156af1 100644
--- a/lib/stdlib/src/epp.erl
+++ b/lib/stdlib/src/epp.erl
@@ -571,6 +571,7 @@ init_server(Pid, Name, Options, St0) ->
 predef_macros(File) ->
     Machine = list_to_atom(erlang:system_info(machine)),
     Anno = line1(),
+    OtpVersion = list_to_integer(erlang:system_info(otp_release)),
     Defs = [{'FILE', 	           {none,[{string,Anno,File}]}},
 	    {'FUNCTION_NAME',      undefined},
 	    {'FUNCTION_ARITY',     undefined},
@@ -580,7 +581,8 @@ predef_macros(File) ->
 	    {'BASE_MODULE',	   undefined},
 	    {'BASE_MODULE_STRING', undefined},
 	    {'MACHINE',	           {none,[{atom,Anno,Machine}]}},
-	    {Machine,	           {none,[{atom,Anno,true}]}}
+	    {Machine,	           {none,[{atom,Anno,true}]}},
+	    {'OTP_RELEASE',	   {none,[{integer,Anno,OtpVersion}]}}
 	   ],
     maps:from_list(Defs).
 
diff --git a/lib/stdlib/test/epp_SUITE.erl b/lib/stdlib/test/epp_SUITE.erl
index 9123bf2f28..87e906a3d4 100644
--- a/lib/stdlib/test/epp_SUITE.erl
+++ b/lib/stdlib/test/epp_SUITE.erl
@@ -799,7 +799,8 @@ otp_8130(Config) when is_list(Config) ->
     PreDefMacs = macs(Epp),
     ['BASE_MODULE','BASE_MODULE_STRING','BEAM','FILE',
      'FUNCTION_ARITY','FUNCTION_NAME',
-     'LINE','MACHINE','MODULE','MODULE_STRING'] = PreDefMacs,
+     'LINE','MACHINE','MODULE','MODULE_STRING',
+     'OTP_RELEASE'] = PreDefMacs,
     {ok,[{'-',_},{atom,_,file}|_]} = epp:scan_erl_form(Epp),
     {ok,[{'-',_},{atom,_,module}|_]} = epp:scan_erl_form(Epp),
     {ok,[{atom,_,t}|_]} = epp:scan_erl_form(Epp),
-- 
2.16.3