On Mon, Jul 21, 2025 at 11:03:08PM +0800, Xi Ruoyao wrote: > On Mon, 2025-07-21 at 16:57 +0200, Stefan Schulze Frielinghaus wrote: > > The generated file tm-preds.h contains now: > > > > static inline size_t > > insn_constraint_len (char fc, const char *str) > > { > > ... > > > > if (str[0] == '{') > > return ((const char *) rawmemchr (str + 1, '}') - str) + 1; > > return 1; > > } > > > > For some reason on all targets I tested, string.h is included. I will > > have a look and see whether string.h may be included easily here, too. > > If the dependency to string.h is not wanted, I could also come up with a > > simple loop. > > It's not if string.h is included. It's if string.h provides rawmemchr. > > rawmemchr is not a standard C function. It's a GNU extension and GCC is > expected to work on various non-GNU systems.
Yea, I didn't have that on my radar and hadn't seen Rainer's mail until now. I will bootstrap the following patch and post it shortly: diff --git a/gcc/genpreds.cc b/gcc/genpreds.cc index c6a2983419a..4f8beeb0514 100644 --- a/gcc/genpreds.cc +++ b/gcc/genpreds.cc @@ -1184,7 +1184,12 @@ write_insn_constraint_len (void) puts (" default: break;\n" " }\n" " if (str[0] == '{')\n" - " return ((const char *) rawmemchr (str + 1, '}') - str) + 1;\n" + " {\n" + " size_t len = 1;\n" + " while (str[len] != '}' && str[len] != '\\0')\n" + " ++len;\n" + " return len + 1;\n" + " }\n" " return 1;\n" "}\n"); }