Patch to projects.html: glibc's string function macros

Joseph S. Myers jsm28@cam.ac.uk
Sun Oct 29 03:07:00 GMT 2000


I've now installed the following further patch which lists a couple of
caveats about optimizing string functions I forgot the first time.  (I'm
not trying to discourage beginners from working on these optimizations -
some of them are certainly suitable for beginners - but there are a lot of
ways the string functions can be got wrong (including places where glibc
has had bugs in the macros in the past) so it seems wise to warn about
what may need to be considered in implementation.

Index: projects.html
===================================================================
RCS file: /cvs/gcc/wwwdocs/htdocs/projects.html,v
retrieving revision 1.28
diff -u -r1.28 projects.html
--- projects.html	2000/10/28 23:53:33	1.28
+++ projects.html	2000/10/29 11:02:04
@@ -95,13 +95,18 @@
 <p>All the string functions act as if they access individual
 characters, so care may need to be taken that no
 <code>-fstrict-aliasing</code> problems occur when internal uses of
-other types are generated.</p>
+other types are generated.  Also, the arguments to the string function
+must be evaluated exactly once each (if they have any side effects),
+even though the call to the string function might be optimized away.</p>

 <p>Care must be taken that any optimizations in GCC are
 standards-conforming in terms of not possibly accessing beyond the
 arrays involved (possibly within a function call created in the
 optimization); whereas the glibc macros know the glibc implementation
-and how much memory it might access, GCC optimizations can't.</p>
+and how much memory it might access, GCC optimizations can't.  When
+<code>-fcheck-memory-usage</code> is used, calls to the checking
+functions from Checker may need to be emitted; see the existing
+builtin string functions in GCC for examples.</p>

 <p>There are some further optimizations in glibc not covered here,
 that either optimize calls to non-ISO C functions or call glibc

-- 
Joseph S. Myers
jsm28@cam.ac.uk



More information about the Gcc-patches mailing list