[PATCH 1/9] Add vectorized getenv for glibc use

Rich Felker dalias@aerifal.cx
Fri May 3 00:18:00 GMT 2013


On Thu, May 02, 2013 at 04:27:24PM -0700, Andi Kleen wrote:
> From: Andi Kleen <ak@linux.intel.com>
> 
> This adds a general "vectorized getenv" for glibc internal use.
> The motivation is to allow subsystems to access environment variables
> cheaply without having to rescan the environment completely.
> 
> The dynamic linker already walks the environment to look for its
> LD_* variables. Extend this code to look for a number of
> pre-registered GLIBC_* variables too. This can be done at basically
> no additional cost. The only two variables currently pre-registered
> are for the lock elision code.
> 
> For static builds which do not use the dynamic linker a similar
> environment walking function is called at init time.
> 
> The variable values are saved in a global array that can be directly
> accessed by libc and related libraries like libpthread.

Doesn't this change behavior if environment variables are later set at
runtime? I don't think such use should be supported anyway, but it
seems this is an observable functional change, not just an
optimization.

Rich



More information about the Libc-alpha mailing list