public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Predefine __STRICT_ALIGN__ if STRICT_ALIGNMENT
@ 2024-03-17  5:46 YunQiang Su
  2024-03-17  6:04 ` Sam James
  2024-03-18  7:32 ` Richard Biener
  0 siblings, 2 replies; 4+ messages in thread
From: YunQiang Su @ 2024-03-17  5:46 UTC (permalink / raw)
  To: gcc-patches; +Cc: pinskia, i, rguenther

Arm32 predefines __ARM_FEATURE_UNALIGNED if -mno-unaligned-access,
and RISC-V predefines __riscv_misaligned_avoid, while other ports
that support -mstrict-align/-mno-unaligned-access don't have such
macro, and these backend macros are only avaiable for c-family.
Note: Arm64 always predefine __ARM_FEATURE_UNALIGNED: See #111555.

Let's add a generic one.

__STRICT_ALIGN__ is used instead of __STRICT_ALIGNMENT__, due to that
the later is used by some softwares, such as lzo2, syslinux etc.

gcc
	* cppbuiltin.cc: Predefine __STRICT_ALIGNMENT__ if
	STRICT_ALIGNMENT.
---
 gcc/cppbuiltin.cc | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/gcc/cppbuiltin.cc b/gcc/cppbuiltin.cc
index c4bfc2917dc..d32efdf9a07 100644
--- a/gcc/cppbuiltin.cc
+++ b/gcc/cppbuiltin.cc
@@ -123,6 +123,9 @@ define_builtin_macros_for_compilation_flags (cpp_reader *pfile)
 
   cpp_define_formatted (pfile, "__FINITE_MATH_ONLY__=%d",
 			flag_finite_math_only);
+
+  if (STRICT_ALIGNMENT)
+    cpp_define (pfile, "__STRICT_ALIGNMENT__");
 }
 
 
-- 
2.39.2


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-03-18  7:32 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-17  5:46 [PATCH] Predefine __STRICT_ALIGN__ if STRICT_ALIGNMENT YunQiang Su
2024-03-17  6:04 ` Sam James
2024-03-17  7:27   ` YunQiang Su
2024-03-18  7:32 ` Richard Biener

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).