forked from Ports/goldeneye-pc-port
Swept all 178 getenv sites; 97 were uncached. The load-time/one-shot ones stay as-is. The 25 on per-frame/per-node/per-string/audio-thread paths (langGet, modelGetNodeRwData, modelRenderNodeGundl, skyRender and its poly path, chrpropRender, frozen-camera tick, amDmaCallback, alRaw16Pull, _decodeChunk, __CSPHandleMIDIMsg, sndHandleEvent, audioSetNextBuffer, configGetInputLog/configGetFrameDump) now go through GE_ENVFLAG/GE_ENVSTR (port/include/envflag.h): one getenv per site per process, exact since the env is fixed. All sites are inside PORT probe blocks; no game logic touched. Windows + Linux builds clean (only pre-existing, D324-audited warnings); bunker1 golden 3/3; GE_INPUTLOG still gates on (12 lines with scripted input).
21 lines
806 B
C
21 lines
806 B
C
#ifndef _ENVFLAG_H_
|
|
#define _ENVFLAG_H_
|
|
|
|
/* Cached env-var probes for hot paths (D250/D302: an uncached getenv() per
|
|
* node/poly/audio event is a measurable per-frame cost on Windows). Each
|
|
* expansion site gets its own static, read once on first use; the env is
|
|
* fixed for the process lifetime, so this is exact. The TU must already have
|
|
* a real getenv() prototype (see D324). GCC/Clang statement expressions. */
|
|
#define GE_ENVFLAG(name) __extension__({ \
|
|
static int _ge_envflag = -1; \
|
|
if (_ge_envflag < 0) _ge_envflag = getenv(name) != NULL; \
|
|
_ge_envflag; })
|
|
|
|
#define GE_ENVSTR(name) __extension__({ \
|
|
static int _ge_envstr_init = 0; \
|
|
static const char *_ge_envstr; \
|
|
if (!_ge_envstr_init) { _ge_envstr = getenv(name); _ge_envstr_init = 1; } \
|
|
_ge_envstr; })
|
|
|
|
#endif
|