Patch to projects.html: glibc's string function macros
Kaveh R. Ghazi
ghazi@caip.rutgers.edu
Tue Oct 31 12:18:00 GMT 2000
> From: "Joseph S. Myers" <jsm28@cam.ac.uk>
>
> > On another matter, I whipped up a patch for a builtin strstr based on
> > the desciption you posted to the "projects" page.
> > http://gcc.gnu.org/projects.html
> >
> > I can do some of the others, but for now how's this? It converts:
> > strstr(s1, "") -> s1
> > strstr(s1, "c") -> strchr(s1, c)
> > other calls to strstr are untouched.
>
> Assuming it's been tested to work (in which case, there should be a
> testcase added to gcc.dg (a) testing correct execution of both
> cases; (b) using scan-assembler-not to make sure that the
> references to strstr were optimized away), it seems fine to me, and
> obsoletes that particular glibc macro. (Of course, the web page
> should be updated as well once this is approved and in GCC.)
Hmm, I've never used scan-assembler-not, but from the examples already
written in the dg dir, I guess I could add something like:
/* { dg-final { scan-assembler-not foo.c "strstr" } } */
but is this really portable across all assembler formats?
Also, I don't like the dg framework because it doesn't cycle through
optimization levels. I'd rather use gcc.c-torture/execute if
possible.
How about something like this in the execute dir?
> int main()
> {
> strstr(testargs);
> strstr(testargs);
> }
> #ifdef __OPTIMIZE__
> void strstr()
> {
> abort();
> }
> #endif
Then if any references aren't transformed, running it will abort. (I
wrapped strstr in __OPTIMIZE__ because at -O0 builtins aren't done, so
in that case we want the real libc copy.)
Sound ok?
--Kaveh
--
Kaveh R. Ghazi Engagement Manager / Project Services
ghazi@caip.rutgers.edu Qwest Internet Solutions
More information about the Gcc-patches
mailing list