But it unconditionally calls a memory barrier, which is most of the cost of an un-contended futex-style lock already.
And I'd be interested in your ideas on removing the lock - as I can't see any paths that don't change semantics (e.g. unconditionally doing the init work at process start time when you know there's not multiple threads, for example)
> a memory barrier, which is most of the cost of an un-contended futex-style lock already
Yes, but it's not a lock.
> unconditionally doing the init work at process start time when you know there's not multiple threads
That's the most obvious fix, yes. I was thinking (but I've not checked yet) that when `my_environ` is not set up yet then `getenv()` can use `_environ` directly.