Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* RFA: use xcalloc for zalloc.
@ 2009-03-18 19:40 Joern Rennecke
  2009-03-19  7:17 ` Doug Evans
  2009-03-19 14:54 ` Joel Brobecker
  0 siblings, 2 replies; 5+ messages in thread
From: Joern Rennecke @ 2009-03-18 19:40 UTC (permalink / raw)
  To: gdb-patches

[-- Attachment #1: Type: text/plain, Size: 97 bytes --]

This patch speeds up simulators that use the sim/common infrastructure
to allocate their memory.

[-- Attachment #2: zalloc-diff-cvs --]
[-- Type: text/plain, Size: 1633 bytes --]

regression tested for m32r-elf with check-gcc and check-gdb on gcc11 in
gcc svn & sourceware cvs from 20090317.
A simple test shows that speed for allocating large memory areas is indeed
improved on gcc11:
amylaar@gcc11:~/20090317-z$ uname -a
Linux gcc11 2.6.18-6-vserver-amd64 #1 SMP Fri Jun 6 05:50:26 UTC 2008 x86_64 GNU/Linux
amylaar@gcc11:~/20090317/bld-m32r/gcc/testsuite/gcc$ time ~/20090317/bld-m32r/sim/m32r/run  --memory-region 0,0x80000000  big.x

real    0m3.180s
user    0m1.488s
sys     0m1.692s
amylaar@gcc11:~/20090317/bld-m32r/gcc/testsuite/gcc$ time ~/20090317-z/bld-m32r/sim/m32r/run  --memory-region 0,0x80000000  big.x

real    0m0.069s
user    0m0.060s
sys     0m0.012s

2007-04-30  J"orn Rennecke  <joern.rennecke@arc.com>

	Speed up simulator startup:
	* sim-utils.c (zalloc): Use xcalloc.

Index: sim/common/sim-utils.c
===================================================================
RCS file: /cvs/src/src/sim/common/sim-utils.c,v
retrieving revision 1.9
diff -p -u -r1.9 sim-utils.c
--- sim/common/sim-utils.c	14 Jan 2009 10:53:06 -0000	1.9
+++ sim/common/sim-utils.c	18 Mar 2009 18:42:18 -0000
@@ -52,15 +52,13 @@ along with this program.  If not, see <h
    Set by sim_resume.  */
 struct sim_state *current_state;
 
-/* Allocate zero filled memory with xmalloc - xmalloc aborts of the
+/* Allocate zero filled memory with xcalloc - xcalloc aborts if the
    allocation fails.  */
 
 void *
 zalloc (unsigned long size)
 {
-  void *memory = (void *) xmalloc (size);
-  memset (memory, 0, size);
-  return memory;
+  return xcalloc (1, size);
 }
 
 void

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: RFA: use xcalloc for zalloc.
  2009-03-18 19:40 RFA: use xcalloc for zalloc Joern Rennecke
@ 2009-03-19  7:17 ` Doug Evans
  2009-03-19 14:54 ` Joel Brobecker
  1 sibling, 0 replies; 5+ messages in thread
From: Doug Evans @ 2009-03-19  7:17 UTC (permalink / raw)
  To: Joern Rennecke; +Cc: gdb-patches

On Wed, Mar 18, 2009 at 12:24 PM, Joern Rennecke <amylaar@spamcop.net> wrote:
> This patch speeds up simulators that use the sim/common infrastructure
> to allocate their memory.
>

This is ok with me (fwiw).

Thanks!


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: RFA: use xcalloc for zalloc.
  2009-03-18 19:40 RFA: use xcalloc for zalloc Joern Rennecke
  2009-03-19  7:17 ` Doug Evans
@ 2009-03-19 14:54 ` Joel Brobecker
  2009-03-19 15:08   ` Joern Rennecke
  1 sibling, 1 reply; 5+ messages in thread
From: Joel Brobecker @ 2009-03-19 14:54 UTC (permalink / raw)
  To: Joern Rennecke; +Cc: gdb-patches

Joern,

> 2007-04-30  J"orn Rennecke  <joern.rennecke@arc.com>
> 
> 	Speed up simulator startup:
> 	* sim-utils.c (zalloc): Use xcalloc.

You patch is approved by Franck Ch. Eigler (he sent the approval in
a private email to me)

There is one issue, though: It appears that you do not have a copyright
assignment in file for GDB? I think I located you, but it only says
that you have assigned changes to GCC.

This is a very small and fairly simple change, so I'll check it in
as a "not legally significant change" (aka "tiny change"). But if
you think you might contribute more patches to GDB, you might want to
consider filing copyright assignment papers for GDB as well.

-- 
Joel


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: RFA: use xcalloc for zalloc.
  2009-03-19 14:54 ` Joel Brobecker
@ 2009-03-19 15:08   ` Joern Rennecke
  2009-03-19 17:39     ` Joel Brobecker
  0 siblings, 1 reply; 5+ messages in thread
From: Joern Rennecke @ 2009-03-19 15:08 UTC (permalink / raw)
  To: Joel Brobecker; +Cc: gdb-patches

Quoting Joel Brobecker <brobecker@adacore.com>:

> This is a very small and fairly simple change, so I'll check it in
> as a "not legally significant change" (aka "tiny change"). But if
> you think you might contribute more patches to GDB, you might want to
> consider filing copyright assignment papers for GDB as well.

ARC has a copyright assignment from 2001 on file for newlib, GCC, binutils
and gdb.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: RFA: use xcalloc for zalloc.
  2009-03-19 15:08   ` Joern Rennecke
@ 2009-03-19 17:39     ` Joel Brobecker
  0 siblings, 0 replies; 5+ messages in thread
From: Joel Brobecker @ 2009-03-19 17:39 UTC (permalink / raw)
  To: Joern Rennecke; +Cc: gdb-patches

> ARC has a copyright assignment from 2001 on file for newlib, GCC, binutils
> and gdb.

Ah - missed that (I search for arc.com email addresses, and then "arc",
but forgot to make the search case-insensitive).

This is great. Thanks for letting me know.

-- 
Joel


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2009-03-19 15:27 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-03-18 19:40 RFA: use xcalloc for zalloc Joern Rennecke
2009-03-19  7:17 ` Doug Evans
2009-03-19 14:54 ` Joel Brobecker
2009-03-19 15:08   ` Joern Rennecke
2009-03-19 17:39     ` Joel Brobecker

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox