Add OPENSSL_VERSION_AT_LEAST
authorMichael Richardson <mcr@sandelman.ca>
Thu, 1 Feb 2018 18:22:48 +0000 (13:22 -0500)
committerRich Salz <rsalz@openssl.org>
Thu, 1 Feb 2018 18:22:48 +0000 (13:22 -0500)
added macro to create version number
use the macro to build OPENSSL_VERSION_AT_LEAST(maj,min,fix) so that
customers of libssl (such as ruby-openssl) do not need to be so aware of
openssl version numbers.
includes updates to ssl(7) and OPENSSL_VERSION_NUMBER(3) man page

Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/5212)

doc/man3/OPENSSL_VERSION_NUMBER.pod
doc/man7/ssl.pod
include/openssl/opensslv.h

index 6eca1134b16149792aec50730c928001daa61759..d5842c0e35f5d0ed68603e35d52445e2ef0dedd0 100644 (file)
@@ -47,6 +47,11 @@ number was therefore 0x0090581f.
 
 OpenSSL_version_num() returns the version number.
 
 
 OpenSSL_version_num() returns the version number.
 
+The macro OPENSSL_VERSION_AT_LEAST(major,minor) can be used at compile
+time test if the current version is at least as new as the version provided.
+The arguments major, minor and fix correspond to the version information
+as given above.
+
 OpenSSL_version() returns different strings depending on B<t>:
 
 =over 4
 OpenSSL_version() returns different strings depending on B<t>:
 
 =over 4
index 724fc78b178d7b5344a4c5adca347c5c15ddcb6b..066b32508f01b897776bb98abf3e01fc7e36f3c4 100644 (file)
@@ -89,6 +89,12 @@ includes both more private SSL headers and headers from the B<crypto> library.
 Whenever you need hard-core details on the internals of the SSL API, look
 inside this header file.
 
 Whenever you need hard-core details on the internals of the SSL API, look
 inside this header file.
 
+OPENSSL_VERSION_AT_LEAST(major,minor) can be
+used in C<#if> statements in order to determine which version of the library is
+being used. This can be used to either enable optional features at compile
+time, or work around issues with a previous version.
+See L<OPENSSL_VERSION_NUMBER(3)>.
+
 =item B<ssl2.h>
 
 Unused. Present for backwards compatibility only.
 =item B<ssl2.h>
 
 Unused. Present for backwards compatibility only.
index c6e15a5aa3e7ef64eb9a97e1e84843f7cf61301e..420a1c96aaea9f9b4678ee33b11b35c225a59eba 100644 (file)
@@ -42,6 +42,11 @@ extern "C" {
 # define OPENSSL_VERSION_NUMBER  0x10101000L
 # define OPENSSL_VERSION_TEXT    "OpenSSL 1.1.1-dev  xx XXX xxxx"
 
 # define OPENSSL_VERSION_NUMBER  0x10101000L
 # define OPENSSL_VERSION_TEXT    "OpenSSL 1.1.1-dev  xx XXX xxxx"
 
+#define OPENSSL_MAKE_VERSION(maj,min,fix,patch) ((0x10000000L)+((maj&0xff)<<20)+((min&0xff)<<12)+((fix&0xff)<<4)+patch)
+
+/* use this for #if tests, should never depend upon fix/patch */
+#define OPENSSL_VERSION_AT_LEAST(maj,min) (OPENSSL_MAKE_VERSION(maj,min, 0, 0) >= OPENSSL_VERSION_NUMBER)
+
 /*-
  * The macros below are to be used for shared library (.so, .dll, ...)
  * versioning.  That kind of versioning works a bit differently between
 /*-
  * The macros below are to be used for shared library (.so, .dll, ...)
  * versioning.  That kind of versioning works a bit differently between