include/internal: add a few missing #pragma once directives

Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com>
(Merged from https://github.com/openssl/openssl/pull/14096)
diff --git a/include/internal/asn1.h b/include/internal/asn1.h
index 8448786..36d90e2 100644
--- a/include/internal/asn1.h
+++ b/include/internal/asn1.h
@@ -9,6 +9,7 @@
 
 #ifndef OSSL_INTERNAL_ASN1_H
 # define OSSL_INTERNAL_ASN1_H
+# pragma once
 
 int asn1_d2i_read_bio(BIO *in, BUF_MEM **pb);
 
diff --git a/include/internal/bio.h b/include/internal/bio.h
index 2fb0d5c..12782c8 100644
--- a/include/internal/bio.h
+++ b/include/internal/bio.h
@@ -9,8 +9,9 @@
 
 #ifndef OSSL_INTERNAL_BIO_H
 # define OSSL_INTERNAL_BIO_H
+# pragma once
 
-#include <openssl/bio.h>
+# include <openssl/bio.h>
 
 struct bio_method_st {
     int type;
@@ -62,11 +63,11 @@
 # define BIO_clear_ktls_ctrl_msg_flag(b) \
     BIO_clear_flags(b, BIO_FLAGS_KTLS_TX_CTRL_MSG)
 
-#  define BIO_set_ktls(b, keyblob, is_tx)   \
+# define BIO_set_ktls(b, keyblob, is_tx)   \
      BIO_ctrl(b, BIO_CTRL_SET_KTLS, is_tx, keyblob)
-#  define BIO_set_ktls_ctrl_msg(b, record_type)   \
+# define BIO_set_ktls_ctrl_msg(b, record_type)   \
      BIO_ctrl(b, BIO_CTRL_SET_KTLS_TX_SEND_CTRL_MSG, record_type, NULL)
-#  define BIO_clear_ktls_ctrl_msg(b) \
+# define BIO_clear_ktls_ctrl_msg(b) \
      BIO_ctrl(b, BIO_CTRL_CLEAR_KTLS_TX_CTRL_MSG, 0, NULL)
 
 #endif
diff --git a/include/internal/conf.h b/include/internal/conf.h
index 1e7ab2c..4404361 100644
--- a/include/internal/conf.h
+++ b/include/internal/conf.h
@@ -9,10 +9,11 @@
 
 #ifndef OSSL_INTERNAL_CONF_H
 # define OSSL_INTERNAL_CONF_H
+# pragma once
 
-#include <openssl/conf.h>
+# include <openssl/conf.h>
 
-#define DEFAULT_CONF_MFLAGS \
+# define DEFAULT_CONF_MFLAGS \
     (CONF_MFLAGS_DEFAULT_SECTION | \
      CONF_MFLAGS_IGNORE_MISSING_FILE | \
      CONF_MFLAGS_IGNORE_RETURN_CODES)
diff --git a/include/internal/constant_time.h b/include/internal/constant_time.h
index dc75e31..b50b10b 100644
--- a/include/internal/constant_time.h
+++ b/include/internal/constant_time.h
@@ -9,6 +9,7 @@
 
 #ifndef OSSL_INTERNAL_CONSTANT_TIME_H
 # define OSSL_INTERNAL_CONSTANT_TIME_H
+# pragma once
 
 # include <stdlib.h>
 # include <string.h>
diff --git a/include/internal/core.h b/include/internal/core.h
index 8499f35..75bcfeb 100644
--- a/include/internal/core.h
+++ b/include/internal/core.h
@@ -9,6 +9,7 @@
 
 #ifndef OSSL_INTERNAL_CORE_H
 # define OSSL_INTERNAL_CORE_H
+# pragma once
 
 /*
  * namespaces:
diff --git a/include/internal/cryptlib.h b/include/internal/cryptlib.h
index 93dedda..5145178 100644
--- a/include/internal/cryptlib.h
+++ b/include/internal/cryptlib.h
@@ -9,6 +9,7 @@
 
 #ifndef OSSL_INTERNAL_CRYPTLIB_H
 # define OSSL_INTERNAL_CRYPTLIB_H
+# pragma once
 
 # include <stdlib.h>
 # include <string.h>
diff --git a/include/internal/dane.h b/include/internal/dane.h
index d9bae2b..6639d2d 100644
--- a/include/internal/dane.h
+++ b/include/internal/dane.h
@@ -9,8 +9,9 @@
 
 #ifndef OSSL_INTERNAL_DANE_H
 #define OSSL_INTERNAL_DANE_H
+# pragma once
 
-#include <openssl/safestack.h>
+# include <openssl/safestack.h>
 
 /*-
  * Certificate usages:
diff --git a/include/internal/deprecated.h b/include/internal/deprecated.h
index 16b0751..a6de395 100644
--- a/include/internal/deprecated.h
+++ b/include/internal/deprecated.h
@@ -18,6 +18,7 @@
 
 #ifndef OSSL_INTERNAL_DEPRECATED_H
 # define OSSL_INTERNAL_DEPRECATED_H
+# pragma once
 
 # include <openssl/configuration.h>
 
diff --git a/include/internal/dso.h b/include/internal/dso.h
index ec58926..d04a1c1 100644
--- a/include/internal/dso.h
+++ b/include/internal/dso.h
@@ -9,6 +9,7 @@
 
 #ifndef OSSL_INTERNAL_DSO_H
 # define OSSL_INTERNAL_DSO_H
+# pragma once
 
 # include <openssl/crypto.h>
 # include "internal/dsoerr.h"
diff --git a/include/internal/endian.h b/include/internal/endian.h
index b4e486d..01b926d 100644
--- a/include/internal/endian.h
+++ b/include/internal/endian.h
@@ -9,6 +9,7 @@
 
 #ifndef OSSL_INTERNAL_ENDIAN_H
 # define OSSL_INTERNAL_ENDIAN_H
+# pragma once
 
 /*
  * IS_LITTLE_ENDIAN and IS_BIG_ENDIAN can be used to detect the endiannes
diff --git a/include/internal/err.h b/include/internal/err.h
index 8cb72ae..d5ad9ab 100644
--- a/include/internal/err.h
+++ b/include/internal/err.h
@@ -9,6 +9,7 @@
 
 #ifndef OSSL_INTERNAL_ERR_H
 # define OSSL_INTERNAL_ERR_H
+# pragma once
 
 void err_free_strings_int(void);
 
diff --git a/include/internal/ffc.h b/include/internal/ffc.h
index 191f936..7653b6e 100644
--- a/include/internal/ffc.h
+++ b/include/internal/ffc.h
@@ -9,6 +9,7 @@
 
 #ifndef OSSL_INTERNAL_FFC_H
 # define OSSL_INTERNAL_FFC_H
+# pragma once
 
 # include <openssl/core.h>
 # include <openssl/bn.h>
diff --git a/include/internal/ktls.h b/include/internal/ktls.h
index 1f486e7..dae9422 100644
--- a/include/internal/ktls.h
+++ b/include/internal/ktls.h
@@ -22,6 +22,8 @@
 
 #ifndef HEADER_INTERNAL_KTLS
 # define HEADER_INTERNAL_KTLS
+# pragma once
+
 # ifndef OPENSSL_NO_KTLS
 
 #  if defined(__FreeBSD__)
diff --git a/include/internal/nelem.h b/include/internal/nelem.h
index 0c32483..f0a53c3 100644
--- a/include/internal/nelem.h
+++ b/include/internal/nelem.h
@@ -9,6 +9,7 @@
 
 #ifndef OSSL_INTERNAL_NELEM_H
 # define OSSL_INTERNAL_NELEM_H
+# pragma once
 
 # define OSSL_NELEM(x)    (sizeof(x)/sizeof((x)[0]))
 #endif
diff --git a/include/internal/numbers.h b/include/internal/numbers.h
index db65559..bade59f 100644
--- a/include/internal/numbers.h
+++ b/include/internal/numbers.h
@@ -9,6 +9,7 @@
 
 #ifndef OSSL_INTERNAL_NUMBERS_H
 # define OSSL_INTERNAL_NUMBERS_H
+# pragma once
 
 # include <limits.h>
 
diff --git a/include/internal/o_dir.h b/include/internal/o_dir.h
index 220cf17..90c247d 100644
--- a/include/internal/o_dir.h
+++ b/include/internal/o_dir.h
@@ -38,6 +38,7 @@
 
 #ifndef OSSL_INTERNAL_O_DIR_H
 # define OSSL_INTERNAL_O_DIR_H
+# pragma once
 
 typedef struct OPENSSL_dir_context_st OPENSSL_DIR_CTX;
 
diff --git a/include/internal/packet.h b/include/internal/packet.h
index 95aeb1c..efb1a70 100644
--- a/include/internal/packet.h
+++ b/include/internal/packet.h
@@ -9,6 +9,7 @@
 
 #ifndef OSSL_INTERNAL_PACKET_H
 # define OSSL_INTERNAL_PACKET_H
+# pragma once
 
 # include <string.h>
 # include <openssl/bn.h>
diff --git a/include/internal/param_build_set.h b/include/internal/param_build_set.h
index d1f1863..a037ab8 100644
--- a/include/internal/param_build_set.h
+++ b/include/internal/param_build_set.h
@@ -7,8 +7,12 @@
  * https://www.openssl.org/source/license.html
  */
 
-#include <openssl/safestack.h>
-#include <openssl/param_build.h>
+#ifndef OSSL_INTERNAL_PARAM_BUILD_SET_H
+# define OSSL_INTERNAL_PARAM_BUILD_SET_H
+# pragma once
+
+# include <openssl/safestack.h>
+# include <openssl/param_build.h>
 
 int ossl_param_build_set_int(OSSL_PARAM_BLD *bld, OSSL_PARAM *p,
                              const char *key, int num);
@@ -27,3 +31,5 @@
 int ossl_param_build_set_multi_key_bn(OSSL_PARAM_BLD *bld, OSSL_PARAM *p,
                                       const char *names[],
                                       STACK_OF(BIGNUM_const) *stk);
+
+#endif  /* OSSL_INTERNAL_PARAM_BUILD_SET_H */
diff --git a/include/internal/passphrase.h b/include/internal/passphrase.h
index 9077907..f2d2614 100644
--- a/include/internal/passphrase.h
+++ b/include/internal/passphrase.h
@@ -9,6 +9,7 @@
 
 #ifndef OSSL_INTERNAL_PASSPHRASE_H
 # define OSSL_INTERNAL_PASSPHRASE_H
+# pragma once
 
 /*
  * This is a passphrase reader bridge with bells and whistles.
diff --git a/include/internal/property.h b/include/internal/property.h
index f2682a1..a533511 100644
--- a/include/internal/property.h
+++ b/include/internal/property.h
@@ -10,8 +10,9 @@
 
 #ifndef OSSL_INTERNAL_PROPERTY_H
 # define OSSL_INTERNAL_PROPERTY_H
+# pragma once
 
-#include "internal/cryptlib.h"
+# include "internal/cryptlib.h"
 
 typedef struct ossl_method_store_st OSSL_METHOD_STORE;
 typedef struct ossl_property_list_st OSSL_PROPERTY_LIST;
diff --git a/include/internal/provider.h b/include/internal/provider.h
index 7a0fc84..dc064fd 100644
--- a/include/internal/provider.h
+++ b/include/internal/provider.h
@@ -9,6 +9,7 @@
 
 #ifndef OSSL_INTERNAL_PROVIDER_H
 # define OSSL_INTERNAL_PROVIDER_H
+# pragma once
 
 # include <openssl/core.h>
 # include <openssl/core_dispatch.h>
diff --git a/include/internal/refcount.h b/include/internal/refcount.h
index 5899e8c..e5c4aca 100644
--- a/include/internal/refcount.h
+++ b/include/internal/refcount.h
@@ -8,6 +8,7 @@
  */
 #ifndef OSSL_INTERNAL_REFCOUNT_H
 # define OSSL_INTERNAL_REFCOUNT_H
+# pragma once
 
 # include <openssl/e_os2.h>
 
diff --git a/include/internal/sha3.h b/include/internal/sha3.h
index 2fd7b20..f564549 100644
--- a/include/internal/sha3.h
+++ b/include/internal/sha3.h
@@ -10,6 +10,7 @@
 /* TODO(3.0) Move this header into provider when dependencies are removed */
 #ifndef OSSL_INTERNAL_SHA3_H
 # define OSSL_INTERNAL_SHA3_H
+# pragma once
 
 # include <openssl/e_os2.h>
 # include <stddef.h>
diff --git a/include/internal/sizes.h b/include/internal/sizes.h
index 00a5d3e..d9abb53 100644
--- a/include/internal/sizes.h
+++ b/include/internal/sizes.h
@@ -9,6 +9,7 @@
 
 #ifndef OSSL_INTERNAL_SIZES_H
 # define OSSL_INTERNAL_SIZES_H
+# pragma once
 
 /*
  * Max sizes used to allocate buffers with a fixed sizes, for example for
diff --git a/include/internal/sm3.h b/include/internal/sm3.h
index 51bb265..b9b0636 100644
--- a/include/internal/sm3.h
+++ b/include/internal/sm3.h
@@ -11,6 +11,7 @@
 /* TODO(3.0) Move this header into provider when dependencies are removed */
 #ifndef OSSL_INTERNAL_SM3_H
 # define OSSL_INTERNAL_SM3_H
+# pragma once
 
 # include <openssl/opensslconf.h>
 
diff --git a/include/internal/sockets.h b/include/internal/sockets.h
index e86ae8a..5d169b6 100644
--- a/include/internal/sockets.h
+++ b/include/internal/sockets.h
@@ -10,6 +10,7 @@
 
 #ifndef OSSL_INTERNAL_SOCKETS_H
 # define OSSL_INTERNAL_SOCKETS_H
+# pragma once
 
 # if defined(OPENSSL_SYS_VXWORKS) || defined(OPENSSL_SYS_UEFI)
 #  define NO_SYS_PARAM_H
diff --git a/include/internal/sslconf.h b/include/internal/sslconf.h
index 9e635da..2c2044c 100644
--- a/include/internal/sslconf.h
+++ b/include/internal/sslconf.h
@@ -9,6 +9,7 @@
 
 #ifndef OSSL_INTERNAL_SSLCONF_H
 # define OSSL_INTERNAL_SSLCONF_H
+# pragma once
 
 typedef struct ssl_conf_cmd_st SSL_CONF_CMD;
 
diff --git a/include/internal/symhacks.h b/include/internal/symhacks.h
index 6a5a187..425b644 100644
--- a/include/internal/symhacks.h
+++ b/include/internal/symhacks.h
@@ -9,6 +9,7 @@
 
 #ifndef OSSL_INTERNAL_SYMHACKS_H
 # define OSSL_INTERNAL_SYMHACKS_H
+# pragma once
 
 # include <openssl/e_os2.h>
 
diff --git a/include/internal/thread_once.h b/include/internal/thread_once.h
index 7b72700..d6cb2ee 100644
--- a/include/internal/thread_once.h
+++ b/include/internal/thread_once.h
@@ -7,7 +7,11 @@
  * https://www.openssl.org/source/license.html
  */
 
-#include <openssl/crypto.h>
+#ifndef OSSL_INTERNAL_THREAD_ONCE_H
+# define OSSL_INTERNAL_THREAD_ONCE_H
+# pragma once
+
+# include <openssl/crypto.h>
 
 /*
  * Initialisation of global data should never happen via "RUN_ONCE" inside the
@@ -15,7 +19,7 @@
  * OSSL_LIB_CTX object. In this way data will get cleaned up correctly when the
  * module gets unloaded.
  */
-#if !defined(FIPS_MODULE) || defined(ALLOW_RUN_ONCE_IN_FIPS)
+# if !defined(FIPS_MODULE) || defined(ALLOW_RUN_ONCE_IN_FIPS)
 /*
  * DEFINE_RUN_ONCE: Define an initialiser function that should be run exactly
  * once. It takes no arguments and returns an int result (1 for success or
@@ -30,7 +34,7 @@
  *     return 0;
  * }
  */
-# define DEFINE_RUN_ONCE(init)                   \
+#  define DEFINE_RUN_ONCE(init)                   \
     static int init(void);                     \
     int init##_ossl_ret_ = 0;                   \
     void init##_ossl_(void)                     \
@@ -43,7 +47,7 @@
  * DECLARE_RUN_ONCE: Declare an initialiser function that should be run exactly
  * once that has been defined in another file via DEFINE_RUN_ONCE().
  */
-# define DECLARE_RUN_ONCE(init)                  \
+#  define DECLARE_RUN_ONCE(init)                  \
     extern int init##_ossl_ret_;                \
     void init##_ossl_(void);
 
@@ -62,7 +66,7 @@
  *     return 0;
  * }
  */
-# define DEFINE_RUN_ONCE_STATIC(init)            \
+#  define DEFINE_RUN_ONCE_STATIC(init)            \
     static int init(void);                     \
     static int init##_ossl_ret_ = 0;            \
     static void init##_ossl_(void)              \
@@ -103,7 +107,7 @@
  *     return 0;
  * }
  */
-# define DEFINE_RUN_ONCE_STATIC_ALT(initalt, init) \
+#  define DEFINE_RUN_ONCE_STATIC_ALT(initalt, init) \
     static int initalt(void);                     \
     static void initalt##_ossl_(void)             \
     {                                             \
@@ -122,7 +126,7 @@
  *
  * (*) by convention, since the init function must return 1 on success.
  */
-# define RUN_ONCE(once, init)                                            \
+#  define RUN_ONCE(once, init)                                            \
     (CRYPTO_THREAD_run_once(once, init##_ossl_) ? init##_ossl_ret_ : 0)
 
 /*
@@ -140,7 +144,8 @@
  *
  * (*) by convention, since the init function must return 1 on success.
  */
-# define RUN_ONCE_ALT(once, initalt, init)                               \
+#  define RUN_ONCE_ALT(once, initalt, init)                               \
     (CRYPTO_THREAD_run_once(once, initalt##_ossl_) ? init##_ossl_ret_ : 0)
 
-#endif /* FIPS_MODULE */
+# endif /* FIPS_MODULE */
+#endif /* OSSL_INTERNAL_THREAD_ONCE_H */
diff --git a/include/internal/tlsgroups.h b/include/internal/tlsgroups.h
index 0245563..c5653bd 100644
--- a/include/internal/tlsgroups.h
+++ b/include/internal/tlsgroups.h
@@ -9,6 +9,7 @@
 
 #ifndef OSSL_INTERNAL_TLSGROUPS_H
 # define OSSL_INTERNAL_TLSGROUPS_H
+# pragma once
 
 # define OSSL_TLS_GROUP_ID_sect163k1        0x0001
 # define OSSL_TLS_GROUP_ID_sect163r1        0x0002