This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc 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: [RFC] Make getenv O(1)


On Mon, 21 Oct 2013, OndÅej BÃlka wrote:
> Why, following does not need synchronization.
> 
> #define GETENV(x) ({ \
>   static char *__ret = NULL; \
>   if (__builtin_constant_p (x) && !__cached) \
>     __ret = getenv (x) + 1; \
>   __builtin_constant_p (x) ? __ret - 1: getenv (x);})

This wouldn't compile as __cached is not defined (and I'll admit I don't see
what approach you're trying to convey).

Alexander

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