This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


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

Re: [PATCH] Fix PR ada/33857 on Mac OS X 10.5.2


> Is this change correct on all versions of darwin or only recent ones ?
> >From what you're saying above, "Apple *changed* the behavior of
> putenv", so could you clarify which versions will work and which won't
> (i.e. will no longer be properly supported after your proposed change) ?

The behavior of setenv is not changed.  Apple recommends setenv over
putenv in their 10.5.2 manpage.

COMPATIBILITY
     putenv() no longer copies its input buffer.  This often appears in crash
     logs as a crash in getenv().  Avoid passing local buffers or freeing the
     memory that is passed to putenv().  Use setenv(), which still makes an
     internal copy of its buffers.

BUGS
     Successive calls to setenv() or putenv() assigning a differently sized
     value to the same name will result in a memory leak.  The FreeBSD seman-
     tics for these functions (namely, that the contents of value are copied
     and that old values remain accessible indefinitely) make this bug
     unavoidable.  Future versions may eliminate one or both of these semantic
     guarantees in order to fix the bug.

I believe the change to be correct on all versions of darwin but I don't
have the capability to test the change on other than 10.5.2.

> Isn't there a way (as done for freebsd) to differentiate between versions
> of darwin ?

There doesn't appear to be a macro define to distinguish different
versions at compile time.  At runtime, the sysctl() function could
be used to get the os version.  However, this seems overly complicated.

Dave
-- 
J. David Anglin                                  dave.anglin@nrc-cnrc.gc.ca
National Research Council of Canada              (613) 990-0752 (FAX: 952-6602)


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