[openssl/openssl] eab9db: Header file cleanup for C++20 header-units

pauli noreply at reply.github.openssl.org
Mon May 9 00:05:17 UTC 2022


  Branch: refs/heads/master
  Home:   https://github.openssl.org/openssl/openssl
  Commit: eab9dbbdd1f102dc1a26549a77fcc5c167385cd5
      https://github.openssl.org/openssl/openssl/commit/eab9dbbdd1f102dc1a26549a77fcc5c167385cd5
  Author: Nathan Sidwell <nathan at acm.org>
  Date:   2022-05-09 (Mon, 09 May 2022)

  Changed paths:
    M include/openssl/asn1.h.in
    M include/openssl/conf.h.in
    M include/openssl/dh.h
    M include/openssl/dsa.h
    M include/openssl/ec.h
    M include/openssl/lhash.h.in
    M include/openssl/pem.h
    M include/openssl/pkcs12.h.in
    M include/openssl/pkcs7.h.in
    M include/openssl/rsa.h
    M include/openssl/ssl.h.in
    M include/openssl/ts.h
    M include/openssl/x509.h.in
    M include/openssl/x509v3.h.in

  Log Message:
  -----------
  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 at me.com>
Reviewed-by: Paul Dale <pauli at openssl.org>
(Merged from https://github.com/openssl/openssl/pull/18221)




More information about the openssl-commits mailing list