Move OPENSSL_FALLTHROUGH to internal headers.
Having it in base.h pollutes the global namespace a bit and, in
particular, causes clang to give unhelpful suggestions in consuming
projects.
Change-Id: I6ca1a88bdd1701f0c49192a0df56ac0953c7067c
Reviewed-on: https://boringssl-review.googlesource.com/25464
Commit-Queue: Steven Valdez <svaldez@google.com>
Reviewed-by: Steven Valdez <svaldez@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
diff --git a/crypto/bio/fd.c b/crypto/bio/fd.c
index ea5bfd8..fed5228 100644
--- a/crypto/bio/fd.c
+++ b/crypto/bio/fd.c
@@ -73,6 +73,7 @@
#include <openssl/mem.h>
#include "internal.h"
+#include "../internal.h"
static int bio_fd_non_fatal_error(int err) {
diff --git a/crypto/bio/file.c b/crypto/bio/file.c
index 278be18..f61dbe4 100644
--- a/crypto/bio/file.c
+++ b/crypto/bio/file.c
@@ -81,6 +81,8 @@
#include <openssl/err.h>
#include <openssl/mem.h>
+#include "../internal.h"
+
#define BIO_FP_READ 0x02
#define BIO_FP_WRITE 0x04
diff --git a/crypto/cipher_extra/e_rc2.c b/crypto/cipher_extra/e_rc2.c
index 0b2caf5..221a9c9 100644
--- a/crypto/cipher_extra/e_rc2.c
+++ b/crypto/cipher_extra/e_rc2.c
@@ -57,6 +57,8 @@
#include <openssl/cipher.h>
#include <openssl/nid.h>
+#include "../internal.h"
+
#define c2l(c, l) \
do { \
diff --git a/crypto/fipsmodule/des/internal.h b/crypto/fipsmodule/des/internal.h
index 4d65ff1..1ae3f22 100644
--- a/crypto/fipsmodule/des/internal.h
+++ b/crypto/fipsmodule/des/internal.h
@@ -59,6 +59,8 @@
#include <openssl/base.h>
+#include "../../internal.h"
+
#if defined(__cplusplus)
extern "C" {
#endif
diff --git a/crypto/internal.h b/crypto/internal.h
index 95b8d28..067f3bb 100644
--- a/crypto/internal.h
+++ b/crypto/internal.h
@@ -172,6 +172,20 @@
#define OPENSSL_ARRAY_SIZE(array) (sizeof(array) / sizeof((array)[0]))
+// Have a generic fall-through for different versions of C/C++.
+#if defined(__cplusplus) && __cplusplus >= 201703L
+#define OPENSSL_FALLTHROUGH [[fallthrough]]
+#elif defined(__cplusplus) && __cplusplus >= 201103L && defined(__clang__)
+#define OPENSSL_FALLTHROUGH [[clang::fallthrough]]
+#elif defined(__cplusplus) && __cplusplus >= 201103L && defined(__GNUC__) && \
+ __GNUC__ >= 7
+#define OPENSSL_FALLTHROUGH [[gnu::fallthrough]]
+#elif defined(__GNUC__) && __GNUC__ >= 7 // gcc 7
+#define OPENSSL_FALLTHROUGH __attribute__ ((fallthrough))
+#else // C++11 on gcc 6, and all other cases
+#define OPENSSL_FALLTHROUGH
+#endif
+
// buffers_alias returns one if |a| and |b| alias and zero otherwise.
static inline int buffers_alias(const uint8_t *a, size_t a_len,
const uint8_t *b, size_t b_len) {
diff --git a/decrepit/macros.h b/decrepit/macros.h
index c4ebeec..7888f0d 100644
--- a/decrepit/macros.h
+++ b/decrepit/macros.h
@@ -57,6 +57,8 @@
#ifndef OPENSSL_HEADER_DECREPIT_MACROS_H
#define OPENSSL_HEADER_DECREPIT_MACROS_H
+#include "../crypto/internal.h"
+
// NOTE - c is not incremented as per n2l
#define n2ln(c, l1, l2, n) \
diff --git a/include/openssl/base.h b/include/openssl/base.h
index dea069a..8db72d8 100644
--- a/include/openssl/base.h
+++ b/include/openssl/base.h
@@ -223,20 +223,6 @@
#endif
#endif
-// Have a generic fall-through for different versions of C/C++.
-#if defined(__cplusplus) && __cplusplus >= 201703L
-#define OPENSSL_FALLTHROUGH [[fallthrough]]
-#elif defined(__cplusplus) && __cplusplus >= 201103L && defined(__clang__)
-#define OPENSSL_FALLTHROUGH [[clang::fallthrough]]
-#elif defined(__cplusplus) && __cplusplus >= 201103L && defined(__GNUC__) && \
- __GNUC__ >= 7
-#define OPENSSL_FALLTHROUGH [[gnu::fallthrough]]
-#elif defined(__GNUC__) && __GNUC__ >= 7 // gcc 7
-#define OPENSSL_FALLTHROUGH __attribute__ ((fallthrough))
-#else // C++11 on gcc 6, and all other cases
-#define OPENSSL_FALLTHROUGH
-#endif
-
// CRYPTO_THREADID is a dummy value.
typedef int CRYPTO_THREADID;