On Sun, Jan 28, 2001 at 11:59:43PM +0000, Nix wrote:
> On Sun, 28 Jan 2001, Alexander Mai stipulated:
> > On 28 Jan 2001 14:17:02 +0000, Nix wrote:
> > If you don't add the explicit initialization, so I would assume that
> > on runtime the program has to dig out what kind of variable it is
> > and then assign the 0 value. Isn't there a trade-off between
> > memory space and performance?
>
> Not on most platforms, no. If we diff the assembly, we get...
>
> --- notInitZero.S Sun Jan 28 14:15:30 2001
> +++ initZero.S Sun Jan 28 14:15:16 2001
> @@ -1,6 +1,13 @@
> .file "initZero.c"
> .version "01.01"
> gcc2_compiled.:
> +.globl foo
> +.data
> + .align 4
> + .type foo,@object
> + .size foo,4
> +foo:
> + .long 0
> .section .rodata
> .LC0:
> .string "%i"
> @@ -21,5 +28,4 @@
> ret
> .Lfe1:
> .size main,.Lfe1-main
> - .comm foo,4,4
> .ident "GCC: (GNU) 2.95.2 19991024 (release)"
>
> so initializing puts the initialization into .data, while not
> initializing makes it a .comm symbol, which on most platforms puts it in
> BSS. On most platforms, *that* is initialized by the kernel out of (the
> equivalent of) /dev/zero. No performance loss.
Interesting.
My experience with assembler is dated even before the 80286
so I can't discuss on the result if we count single
processor cycles on executing this ...
(initializing some memory to something also needs some time,
doesn't it?)
> > Can't follow here. Those vars were never initialized upon running
> > main() or loading the libXm, but during some internal Xm routine
> > deep inside our libXm.
> > My conclusion that it has never hurt should refer to the code that
> > does the initialization.
>
> It just bloats the code a bit, that's all.
[...]
I wrote earlier I can't understand this.
Nothing guarantees us those vars to have any value
if we don't initialize them. "nothing" here refers to
a) X11R5/6, b) ANSI C89, c) the mixture of un*x _programming_
standards which feature the API beyond ANSI C - SUSV2 should be
ok here. I won't claim that LessTif relies on anything else.
One might easily run into problems which appear long before
those routines which do the initialization have been called.
Then you will benefit if you can compare the actual values
of the vars with the initial value.
--
Alexander Mai
[EMAIL PROTECTED]