This is the mail archive of the libc-hacker@sources.redhat.com mailing list for the glibc project.

Note that libc-hacker is a closed list. You may look at the archives of this list, but subscription and posting are not open.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] locarchive.c nested macros


Hi!

I have only 256MB of RAM on my workstation and compiling
locarchive.c takes lots of memory at least with gcc 2.96-RH
(230MB before I killed it), with gcc 3.1 it is slightly better (~ 100MB)
but anyway building glibc with -j3 is problematic then.
The thing is that stpcpy is extremely huge macro (we need to do something
for gcc 3.2, so that stpcpy is properly optimized by the compiler and
we don't have to do all this), and nesting it 5 times means the resulting
preprocessed source is ~6MB and the early compiler passes are fed lots of
data till most of it is optimized away. After following patch, locarchive.i
is ~ 730KB and compiling it eats way less memory.
At least with gcc-3.1, the generated code is identical.

2002-04-30  Jakub Jelinek  <jakub@redhat.com>

	* locale/programs/locarchive.c (add_locales_to_archive): Don't nest
	too many stpcpy macros.

--- libc/locale/programs/locarchive.c.jj	Thu Apr 18 09:55:47 2002
+++ libc/locale/programs/locarchive.c	Tue Apr 30 17:34:05 2002
@@ -711,11 +711,8 @@ add_locales_to_archive (nlist, list, rep
 			     directory and it therefore must contain a
 			     regular file with the same name except a
 			     "SYS_" prefix.  */
-			  strcpy (stpcpy (stpcpy (stpcpy (stpcpy (fullname,
-								  fname),
-							  "/"),
-						  d->d_name),
-					  "/SYS_"),
+			  char *t = stpcpy (stpcpy (fullname, fname), "/");
+			  strcpy (stpcpy (stpcpy (t, d->d_name), "/SYS_"),
 				  d->d_name);
 
 			  if (stat64 (fullname, &st) == -1)
@@ -765,11 +762,10 @@ add_locales_to_archive (nlist, list, rep
 
 	    if (S_ISDIR (st.st_mode))
 	      {
+		char *t;
 		close (fd);
-		strcpy (stpcpy (stpcpy (stpcpy (stpcpy (fullname, fname),
-						"/"),
-					locnames[cnt]),
-				"/SYS_"),
+		t = stpcpy (stpcpy (fullname, fname), "/");
+		strcpy (stpcpy (stpcpy (t, locnames[cnt]), "/SYS_"),
 			locnames[cnt]);
 
 		fd = open64 (fullname, O_RDONLY);

	Jakub


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]