]> git.ipfire.org Git - thirdparty/openssl.git/commit - include/openssl/rsa.h
Header file cleanup for C++20 header-units
authorNathan Sidwell <nathan@acm.org>
Mon, 25 Apr 2022 17:50:36 +0000 (10:50 -0700)
committerPauli <pauli@openssl.org>
Mon, 9 May 2022 00:04:58 +0000 (10:04 +1000)
commiteab9dbbdd1f102dc1a26549a77fcc5c167385cd5
treed56f6ec8748baecf686526fa4e0c198c4b28fc50
parent4e720f12fade8d433e5a0eb3ead9017193dac6e7
Header file cleanup for C++20 header-units

C++20 adds 'header units' as a stepping-stone to modules.  Header
units are regular header-files that have a 'self-contained' property
-- they do not require previously-included headers to provide typedefs
and what not.

This addresses 2 problems discovered when using clang modules (as a
proxy for C++20 header-units).

a) Some headers that pay attention to OPENSSL_NO_STDIO to determine
whether to declare certain FILE*-taking functions do not #include
<stdio.h> themselves, relying on their includer already having done
that.  That breaks the above mentioned encapuslation requirement.
Fixed by conditionally including stdio.h in those headers.  I chose to
always include stdio.h in such headers, even when they included
another such header that transitively included stdio.  That way they
do not rely on an artifact of that intermediate header's behaviour.

b) Some headers have #includes inside 'extern "C" { ... }' regions.
That has a bad code-smell, but GCC and clang have extensions to permit
it with implementation-defined effects.  Clang needs annotation on the
included files to know that they themselves are entirely inside a
similar region.  GCC behavesq as-if there's an extern "C++" region
wrapping the included header (which must therefore wrap its contents
in extern "C", if that is what it wants.  In effect the includer's
extern "C" region is just misleading. I didn't audit all the headers
for this, only those I noticed when addressing #a.

\#a is necessary to build the headers as a set of clang-modules.  #b
is not necessary, but as I mentioned, avoids potentially
implementation-defined behaviour.

Reviewed-by: Todd Short <todd.short@me.com>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/18221)
14 files changed:
include/openssl/asn1.h.in
include/openssl/conf.h.in
include/openssl/dh.h
include/openssl/dsa.h
include/openssl/ec.h
include/openssl/lhash.h.in
include/openssl/pem.h
include/openssl/pkcs12.h.in
include/openssl/pkcs7.h.in
include/openssl/rsa.h
include/openssl/ssl.h.in
include/openssl/ts.h
include/openssl/x509.h.in
include/openssl/x509v3.h.in