Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 31 Mar 2002 00:32:54 -0800
From:      Terry Lambert <tlambert2@mindspring.com>
To:        Garance A Drosihn <drosih@rpi.edu>
Cc:        Kris Kennaway <kris@obsecurity.org>, current@FreeBSD.ORG
Subject:   Re: stdout changes break some ports
Message-ID:  <3CA6C9B6.D9F6614B@mindspring.com>
References:  <20020324173513.A75429@xor.obsecurity.org> <20020324.184313.30925676.imp@village.org> <20020324175436.A75804@xor.obsecurity.org> <20020330224648.A93819@xor.obsecurity.org> <p05101538b8cc765525ce@[128.113.24.47]>

next in thread | previous in thread | raw e-mail | index | archive | help
Garance A Drosihn wrote:
> >How does one fix this in a library?  I've been moving the
> >initialization to main() for applications.
> 
> If all else fails, have some global static variable, and check
> the value in the routine(s) which care.  if the flag variable
> is still zero, then initialize the stdout variable and change
> the flag variable to 1.
> 
> I imagine there's plenty of smarter ways to do it though.

The smartest way would be to have "all zeros" be the correct
default for the initial state data.

The next smartest way would be to pick the first zeroed value
as an "initialized" variable, and check it each time, setting
it to 1, once the initialization has taken place.

The next smartest way would be to treat it as if it were a static
class declaration that needed to be automatically constructed
before it could be used (see the code for this in my previous
posting).  This one is kind of a tossup, since it gets the
extra check out of the main path, but relies on weird glue code.

The least smartest way would be to create an init function which
had to be called by main() before you could use stdio, unlike all
other UNIX systems on the planet.

-- Terry

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-current" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3CA6C9B6.D9F6614B>