Add GCC options pop
Reduce the scope of target pragma to meet
behavior of clang.
Signed-off-by: Jerry Yu <jerry.h.yu@arm.com>
diff --git a/library/sha256.c b/library/sha256.c
index 49a233d..81c011b 100644
--- a/library/sha256.c
+++ b/library/sha256.c
@@ -57,7 +57,9 @@
# if __GNUC__ < 6 /* TODO: check sha256 compatible for GCC */
# error "A more recent GCC is required for MBEDTLS_SHA256_USE_A64_CRYPTO_*"
# else
+# pragma GCC push_options
# pragma GCC target ("arch=armv8-a+crypto")
+# define MBEDTLS_POP_TARGET_PRAGMA
# endif
# else
# error "Only GCC and Clang supported for MBEDTLS_SHA256_USE_A64_CRYPTO_*"
@@ -381,7 +383,11 @@
}
#if defined(MBEDTLS_POP_TARGET_PRAGMA)
+#if defined(__clang__)
#pragma clang attribute pop
+#elif defined(__GNUC__)
+#pragma GCC pop_options
+#endif
#undef MBEDTLS_POP_TARGET_PRAGMA
#endif
diff --git a/library/sha512.c b/library/sha512.c
index 827c08f..df8c5a9 100644
--- a/library/sha512.c
+++ b/library/sha512.c
@@ -86,7 +86,9 @@
# if __GNUC__ < 8
# error "A more recent GCC is required for MBEDTLS_SHA512_USE_A64_CRYPTO_*"
# else
+# pragma GCC push_options
# pragma GCC target ("arch=armv8.2-a+sha3")
+# define MBEDTLS_POP_TARGET_PRAGMA
# endif
# else
# error "Only GCC and Clang supported for MBEDTLS_SHA512_USE_A64_CRYPTO_*"
@@ -567,7 +569,11 @@
}
#if defined(MBEDTLS_POP_TARGET_PRAGMA)
+#if defined(__clang__)
#pragma clang attribute pop
+#elif defined(__GNUC__)
+#pragma GCC pop_options
+#endif
#undef MBEDTLS_POP_TARGET_PRAGMA
#endif