public inbox for libc-hacker@sourceware.org
 help / color / mirror / Atom feed
From: Jakub Jelinek <jakub@redhat.com>
To: Ulrich Drepper <drepper@redhat.com>
Cc: Glibc hackers <libc-hacker@sources.redhat.com>
Subject: [PATCH] locarchive.c nested macros
Date: Tue, 30 Apr 2002 08:32:00 -0000	[thread overview]
Message-ID: <20020430173141.T32482@sunsite.ms.mff.cuni.cz> (raw)

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

             reply	other threads:[~2002-04-30 15:32 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-04-30  8:32 Jakub Jelinek [this message]
2002-05-01  9:48 ` Ulrich Drepper

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20020430173141.T32482@sunsite.ms.mff.cuni.cz \
    --to=jakub@redhat.com \
    --cc=drepper@redhat.com \
    --cc=libc-hacker@sources.redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).