Commit Graph

7 Commits

Author SHA1 Message Date
tron fbf4aa1699 Improve and simplify implementation of *env(3) functions:
- Use RB tree to keep track of memory allocated via setenv(3) as
  suggested by Enami Tsugutomo in private e-mail.
  This simplifies the code a lot as we no longer need to keep the size
  of "environ" in sync with an array of allocated environment variables.
  It also makes it possible to free environment variables in unsetenv(3)
  if something has changed the order of the "environ" array.
- Fix a bug in getenv(3) and getenv_r(3) which would return bogus
  results e.g. for " getenv("A=B") " if an environment variable "A"
  with value "B=C" exists.
- Clean up the internal functions:
  - Don't expose the read/write lock for the environment to other parts
    of "libc". Provide locking functions instead.
  - Use "bool" to report success or failure.
  - Use "ssize_t" or "size_t" instead of "int" for indexes.
  - Provide internal functions with simpler interfaces e.g. don't
    combine return values and reference arguments.
  - Don't copy "environ" into an allocated block unless we really need
    to grow it.

Code reviewed by Joerg Sonnenberger and Christos Zoulas, tested by
Joerg Sonnenberger and me. These changes also fix problems in
zsh 4.3.* and pam_ssh according to Joerg.
2010-11-14 18:11:42 +00:00
joerg e883e926df Ensure that initfini.c is referenced by exit.c. The start up code has to
reference the latter as a return of main() results in a call to exit(3),
so this ensures that the libc constructors are run for statically linked
programs. Fixes PR 37454.
2010-06-28 21:58:02 +00:00
martin ce099b4099 Remove clause 3 and 4 from TNF licenses 2008-04-28 20:22:51 +00:00
xtraeme 95157b046e Make the atexit mutex recursive and initialize it in __libc_init()
as suggested by ad@, based on the patch provided by Sverre Froyen
in lib/37654.

Reviewed by ad@ and jmcneill@.
2008-02-25 14:06:13 +00:00
ad b5b3e9fb51 Enable the atomic ops in userspace. 2008-02-10 18:45:40 +00:00
ad 46f5cd4fb9 - Make it pass lint.
- Add RCSID.
2007-11-13 15:33:55 +00:00
ad ec4d182d4a - stack_protector.c doesn't really belong under sys/. Add a new directory
for misc support routines and put it there.
- Add a libc constructor. Use this to initialize threading and the
  stack protector stuff. libpthread cannot be initialized safely using
  its own constructor because libc and libpthread are deeply intertwined.
  PR bin/37347
2007-11-13 15:21:19 +00:00