summaryrefslogtreecommitdiffstats
path: root/util
diff options
context:
space:
mode:
authorRichard Levitte <levitte@openssl.org>2019-11-05 17:00:33 +0100
committerRichard Levitte <levitte@openssl.org>2019-11-07 11:37:25 +0100
commita6a4d0acd23b3fc85041d9096b67bcf18ccb635c (patch)
treeb52b2d1a2110c46e5999128d5c6ba7b2c2279906 /util
parentccd9e70d4efeb2c7a258ba0a567b898174286b13 (diff)
Change the logic and behaviour surrounding '--api' and 'no-deprecated'
At some point in time, there was a 'no-deprecated' configuration option, which had the effect of hiding all declarations of deprecated stuff, i.e. make the public API look like they were all removed. At some point in time, there was a '--api' configuration option, which had the effect of having the public API look like it did in the version given as value, on a best effort basis. In practice, this was used to get different implementations of BN_zero(), depending on the desired API compatibility level. At some later point in time, '--api' was changed to mean the same as 'no-deprecated', but only for the deprecations up to and including the desired API compatibility level. BN_zero() has been set to the pre-1.0.0 implementation ever since, unless 'no-deprecation' has been given. This change turns these options back to their original meaning, but with the slight twist that when combined, i.e. both '--api' and 'no-deprecated' is given, the declarations that are marked deprecated up to an including the desired API compatibility level are hidden, simulating that they have been removed. If no desired API compatibility level has been given, then configuration sets the current OpenSSL version by default. Furthermore, the macro OPENSSL_API_LEVEL is now used exclusively to check what API compatibility level is desired. For checking in code if `no-deprecated` has been configured for the desired API compatibility level, macros for each supported level is generated, such as OPENSSL_NO_DEPRECATED_1_1_1, corresponding to the use of DEPRECATEDIN_ macros, such as DEPRECATEDIN_1_1_1(). Just like before, to set an API compatibility level when building an application, define OPENSSL_API_COMPAT with an appropriate value. If it's desirable to hide deprecated functions up to and including that level, additionally define OPENSSL_NO_DEPRECATED (the value is ignored). Reviewed-by: Tim Hudson <tjh@openssl.org> (Merged from https://github.com/openssl/openssl/pull/10364)
Diffstat (limited to 'util')
-rwxr-xr-xutil/mkdef.pl14
-rw-r--r--util/perl/OpenSSL/ParseC.pm11
2 files changed, 13 insertions, 12 deletions
diff --git a/util/mkdef.pl b/util/mkdef.pl
index 11471499df..b923cb62c3 100755
--- a/util/mkdef.pl
+++ b/util/mkdef.pl
@@ -100,10 +100,6 @@ die "Please supply arguments\n"
#
(my $SO_VARIANT = uc($target{"shlib_variant"} // '')) =~ s/\W/_/g;
-my $apiv = undef;
-$apiv = sprintf "%x%02x%02x", split(/\./, $config{api})
- if $config{api};
-
my $libname = platform->sharedname($name);
my %OS_data = (
@@ -191,11 +187,13 @@ sub feature_filter {
my $verdict = ! grep { $disabled_uc{$_} } @features;
- if ($apiv) {
+ if ($disabled{deprecated}) {
foreach (@features) {
- next unless /^DEPRECATEDIN_(\d+)(?:_(\d+)_(\d+))?$/;
- my $symdep = sprintf "%x%02x%02x", $1, ($2 // 0), ($3 // 0);
- $verdict = 0 if $apiv ge $symdep;
+ next unless /^DEPRECATEDIN_(\d+)_(\d+)(?:_(\d+))?$/;
+ my $symdep = $1 * 10000 + $2 * 100 + ($3 // 0);
+ $verdict = 0 if $config{api} >= $symdep;
+ print STDERR "DEBUG: \$symdep = $symdep, \$verdict = $verdict\n"
+ if $1 == 0;
}
}
diff --git a/util/perl/OpenSSL/ParseC.pm b/util/perl/OpenSSL/ParseC.pm
index 286fa7e0ef..2db43e2a61 100644
--- a/util/perl/OpenSSL/ParseC.pm
+++ b/util/perl/OpenSSL/ParseC.pm
@@ -65,11 +65,14 @@ my @opensslcpphandlers = (
# These are used to convert certain pre-precessor expressions into
# others that @cpphandlers have a better chance to understand.
- { regexp => qr/#if (!?)OPENSSL_API_([0-9_]+)$/,
+ # This changes any OPENSSL_NO_DEPRECATED_x_y[_z] check to a check of
+ # OPENSSL_NO_DEPRECATEDIN_x_y[_z]. That's due to <openssl/macros.h>
+ # creating OPENSSL_NO_DEPRECATED_x_y[_z], but the ordinals files using
+ # DEPRECATEDIN_x_y[_z].
+ { regexp => qr/#if(def|ndef) OPENSSL_NO_DEPRECATED_(\d+_\d+(?:_\d+)?)$/,
massager => sub {
- my $cnd = $1 eq '!' ? 'ndef' : 'def';
return (<<"EOF");
-#if$cnd DEPRECATEDIN_$2
+#if$1 OPENSSL_NO_DEPRECATEDIN_$2
EOF
}
}
@@ -261,7 +264,7 @@ my @opensslchandlers = (
# We trick the parser by pretending that the declaration is wrapped in a
# check if the DEPRECATEDIN macro is defined or not. Callers of parse()
# will have to decide what to do with it.
- { regexp => qr/(DEPRECATEDIN_\d+(?:_\d+_\d+)?)<<<\((.*)\)>>>/,
+ { regexp => qr/(DEPRECATEDIN_\d+_\d+(?:_\d+)?)<<<\((.*)\)>>>/,
massager => sub { return (<<"EOF");
#ifndef $1
$2;