mesa: Drop _mesa_getenv() wrapper.

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Jose Fonseca <jfonseca@vmware.com>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
This commit is contained in:
Matt Turner
2014-09-21 22:53:04 -07:00
parent 209eba42eb
commit 5980fc35c9
17 changed files with 47 additions and 66 deletions

View File

@@ -176,7 +176,7 @@ save_glx_visual( Display *dpy, XVisualInfo *vinfo,
if (dbFlag) { if (dbFlag) {
/* Check if the MESA_BACK_BUFFER env var is set */ /* Check if the MESA_BACK_BUFFER env var is set */
char *backbuffer = _mesa_getenv("MESA_BACK_BUFFER"); char *backbuffer = getenv("MESA_BACK_BUFFER");
if (backbuffer) { if (backbuffer) {
if (backbuffer[0]=='p' || backbuffer[0]=='P') { if (backbuffer[0]=='p' || backbuffer[0]=='P') {
ximageFlag = GL_FALSE; ximageFlag = GL_FALSE;
@@ -200,13 +200,13 @@ save_glx_visual( Display *dpy, XVisualInfo *vinfo,
/* Comparing IDs uses less memory but sometimes fails. */ /* Comparing IDs uses less memory but sometimes fails. */
/* XXX revisit this after 3.0 is finished. */ /* XXX revisit this after 3.0 is finished. */
if (_mesa_getenv("MESA_GLX_VISUAL_HACK")) if (getenv("MESA_GLX_VISUAL_HACK"))
comparePointers = GL_TRUE; comparePointers = GL_TRUE;
else else
comparePointers = GL_FALSE; comparePointers = GL_FALSE;
/* Force the visual to have an alpha channel */ /* Force the visual to have an alpha channel */
if (rgbFlag && _mesa_getenv("MESA_GLX_FORCE_ALPHA")) if (rgbFlag && getenv("MESA_GLX_FORCE_ALPHA"))
alphaFlag = GL_TRUE; alphaFlag = GL_TRUE;
/* First check if a matching visual is already in the list */ /* First check if a matching visual is already in the list */
@@ -272,7 +272,7 @@ static GLint
default_depth_bits(void) default_depth_bits(void)
{ {
int zBits; int zBits;
const char *zEnv = _mesa_getenv("MESA_GLX_DEPTH_BITS"); const char *zEnv = getenv("MESA_GLX_DEPTH_BITS");
if (zEnv) if (zEnv)
zBits = atoi(zEnv); zBits = atoi(zEnv);
else else
@@ -284,7 +284,7 @@ static GLint
default_alpha_bits(void) default_alpha_bits(void)
{ {
int aBits; int aBits;
const char *aEnv = _mesa_getenv("MESA_GLX_ALPHA_BITS"); const char *aEnv = getenv("MESA_GLX_ALPHA_BITS");
if (aEnv) if (aEnv)
aBits = atoi(aEnv); aBits = atoi(aEnv);
else else
@@ -432,11 +432,11 @@ get_env_visual(Display *dpy, int scr, const char *varname)
int depth, xclass = -1; int depth, xclass = -1;
XVisualInfo *vis; XVisualInfo *vis;
if (!_mesa_getenv( varname )) { if (!getenv( varname )) {
return NULL; return NULL;
} }
strncpy( value, _mesa_getenv(varname), 100 ); strncpy( value, getenv(varname), 100 );
value[99] = 0; value[99] = 0;
sscanf( value, "%s %d", type, &depth ); sscanf( value, "%s %d", type, &depth );
@@ -1313,7 +1313,7 @@ glXDestroyGLXPixmap( Display *dpy, GLXPixmap pixmap )
if (b) { if (b) {
XMesaDestroyBuffer(b); XMesaDestroyBuffer(b);
} }
else if (_mesa_getenv("MESA_DEBUG")) { else if (getenv("MESA_DEBUG")) {
_mesa_warning(NULL, "Mesa: glXDestroyGLXPixmap: invalid pixmap\n"); _mesa_warning(NULL, "Mesa: glXDestroyGLXPixmap: invalid pixmap\n");
} }
} }
@@ -1391,7 +1391,7 @@ glXSwapBuffers( Display *dpy, GLXDrawable drawable )
if (buffer) { if (buffer) {
XMesaSwapBuffers(buffer); XMesaSwapBuffers(buffer);
} }
else if (_mesa_getenv("MESA_DEBUG")) { else if (getenv("MESA_DEBUG")) {
_mesa_warning(NULL, "glXSwapBuffers: invalid drawable 0x%x\n", _mesa_warning(NULL, "glXSwapBuffers: invalid drawable 0x%x\n",
(int) drawable); (int) drawable);
} }
@@ -1409,7 +1409,7 @@ glXCopySubBufferMESA(Display *dpy, GLXDrawable drawable,
if (buffer) { if (buffer) {
XMesaCopySubBuffer(buffer, x, y, width, height); XMesaCopySubBuffer(buffer, x, y, width, height);
} }
else if (_mesa_getenv("MESA_DEBUG")) { else if (getenv("MESA_DEBUG")) {
_mesa_warning(NULL, "Mesa: glXCopySubBufferMESA: invalid drawable\n"); _mesa_warning(NULL, "Mesa: glXCopySubBufferMESA: invalid drawable\n");
} }
} }

View File

@@ -592,7 +592,7 @@ initialize_visual_and_buffer(XMesaVisual v, XMesaBuffer b,
* which can help Brian figure out what's going on when a user * which can help Brian figure out what's going on when a user
* reports bugs. * reports bugs.
*/ */
if (_mesa_getenv("MESA_INFO")) { if (getenv("MESA_INFO")) {
printf("X/Mesa visual = %p\n", (void *) v); printf("X/Mesa visual = %p\n", (void *) v);
printf("X/Mesa level = %d\n", v->mesa_visual.level); printf("X/Mesa level = %d\n", v->mesa_visual.level);
printf("X/Mesa depth = %d\n", v->visinfo->depth); printf("X/Mesa depth = %d\n", v->visinfo->depth);
@@ -686,7 +686,7 @@ XMesaVisual XMesaCreateVisual( Display *display,
return NULL; return NULL;
/* For debugging only */ /* For debugging only */
if (_mesa_getenv("MESA_XSYNC")) { if (getenv("MESA_XSYNC")) {
/* This makes debugging X easier. /* This makes debugging X easier.
* In your debugger, set a breakpoint on _XError to stop when an * In your debugger, set a breakpoint on _XError to stop when an
* X protocol error is generated. * X protocol error is generated.

View File

@@ -258,7 +258,7 @@ save_glx_visual( Display *dpy, XVisualInfo *vinfo,
if (dbFlag) { if (dbFlag) {
/* Check if the MESA_BACK_BUFFER env var is set */ /* Check if the MESA_BACK_BUFFER env var is set */
char *backbuffer = _mesa_getenv("MESA_BACK_BUFFER"); char *backbuffer = getenv("MESA_BACK_BUFFER");
if (backbuffer) { if (backbuffer) {
if (backbuffer[0]=='p' || backbuffer[0]=='P') { if (backbuffer[0]=='p' || backbuffer[0]=='P') {
ximageFlag = GL_FALSE; ximageFlag = GL_FALSE;
@@ -279,13 +279,13 @@ save_glx_visual( Display *dpy, XVisualInfo *vinfo,
/* Comparing IDs uses less memory but sometimes fails. */ /* Comparing IDs uses less memory but sometimes fails. */
/* XXX revisit this after 3.0 is finished. */ /* XXX revisit this after 3.0 is finished. */
if (_mesa_getenv("MESA_GLX_VISUAL_HACK")) if (getenv("MESA_GLX_VISUAL_HACK"))
comparePointers = GL_TRUE; comparePointers = GL_TRUE;
else else
comparePointers = GL_FALSE; comparePointers = GL_FALSE;
/* Force the visual to have an alpha channel */ /* Force the visual to have an alpha channel */
if (_mesa_getenv("MESA_GLX_FORCE_ALPHA")) if (getenv("MESA_GLX_FORCE_ALPHA"))
alphaFlag = GL_TRUE; alphaFlag = GL_TRUE;
/* First check if a matching visual is already in the list */ /* First check if a matching visual is already in the list */
@@ -350,7 +350,7 @@ static GLint
default_depth_bits(void) default_depth_bits(void)
{ {
int zBits; int zBits;
const char *zEnv = _mesa_getenv("MESA_GLX_DEPTH_BITS"); const char *zEnv = getenv("MESA_GLX_DEPTH_BITS");
if (zEnv) if (zEnv)
zBits = atoi(zEnv); zBits = atoi(zEnv);
else else
@@ -362,7 +362,7 @@ static GLint
default_alpha_bits(void) default_alpha_bits(void)
{ {
int aBits; int aBits;
const char *aEnv = _mesa_getenv("MESA_GLX_ALPHA_BITS"); const char *aEnv = getenv("MESA_GLX_ALPHA_BITS");
if (aEnv) if (aEnv)
aBits = atoi(aEnv); aBits = atoi(aEnv);
else else
@@ -559,11 +559,11 @@ get_env_visual(Display *dpy, int scr, const char *varname)
int depth, xclass = -1; int depth, xclass = -1;
XVisualInfo *vis; XVisualInfo *vis;
if (!_mesa_getenv( varname )) { if (!getenv( varname )) {
return NULL; return NULL;
} }
strncpy( value, _mesa_getenv(varname), 100 ); strncpy( value, getenv(varname), 100 );
value[99] = 0; value[99] = 0;
sscanf( value, "%s %d", type, &depth ); sscanf( value, "%s %d", type, &depth );
@@ -1428,7 +1428,7 @@ Fake_glXDestroyGLXPixmap( Display *dpy, GLXPixmap pixmap )
if (b) { if (b) {
XMesaDestroyBuffer(b); XMesaDestroyBuffer(b);
} }
else if (_mesa_getenv("MESA_DEBUG")) { else if (getenv("MESA_DEBUG")) {
_mesa_warning(NULL, "Mesa: glXDestroyGLXPixmap: invalid pixmap\n"); _mesa_warning(NULL, "Mesa: glXDestroyGLXPixmap: invalid pixmap\n");
} }
} }
@@ -1504,7 +1504,7 @@ Fake_glXSwapBuffers( Display *dpy, GLXDrawable drawable )
if (buffer) { if (buffer) {
XMesaSwapBuffers(buffer); XMesaSwapBuffers(buffer);
} }
else if (_mesa_getenv("MESA_DEBUG")) { else if (getenv("MESA_DEBUG")) {
_mesa_warning(NULL, "glXSwapBuffers: invalid drawable 0x%x\n", _mesa_warning(NULL, "glXSwapBuffers: invalid drawable 0x%x\n",
(int) drawable); (int) drawable);
} }
@@ -1522,7 +1522,7 @@ Fake_glXCopySubBufferMESA( Display *dpy, GLXDrawable drawable,
if (buffer) { if (buffer) {
XMesaCopySubBuffer(buffer, x, y, width, height); XMesaCopySubBuffer(buffer, x, y, width, height);
} }
else if (_mesa_getenv("MESA_DEBUG")) { else if (getenv("MESA_DEBUG")) {
_mesa_warning(NULL, "Mesa: glXCopySubBufferMESA: invalid drawable\n"); _mesa_warning(NULL, "Mesa: glXCopySubBufferMESA: invalid drawable\n");
} }
} }

View File

@@ -582,7 +582,7 @@ initialize_visual_and_buffer(XMesaVisual v, XMesaBuffer b,
} }
v->mesa_visual.indexBits = 0; v->mesa_visual.indexBits = 0;
if (_mesa_getenv("MESA_NO_DITHER")) { if (getenv("MESA_NO_DITHER")) {
v->dithered_pf = v->undithered_pf; v->dithered_pf = v->undithered_pf;
} }
@@ -592,7 +592,7 @@ initialize_visual_and_buffer(XMesaVisual v, XMesaBuffer b,
* which can help Brian figure out what's going on when a user * which can help Brian figure out what's going on when a user
* reports bugs. * reports bugs.
*/ */
if (_mesa_getenv("MESA_INFO")) { if (getenv("MESA_INFO")) {
printf("X/Mesa visual = %p\n", (void *) v); printf("X/Mesa visual = %p\n", (void *) v);
printf("X/Mesa dithered pf = %u\n", v->dithered_pf); printf("X/Mesa dithered pf = %u\n", v->dithered_pf);
printf("X/Mesa undithered pf = %u\n", v->undithered_pf); printf("X/Mesa undithered pf = %u\n", v->undithered_pf);
@@ -760,7 +760,7 @@ XMesaVisual XMesaCreateVisual( XMesaDisplay *display,
GLint red_bits, green_bits, blue_bits, alpha_bits; GLint red_bits, green_bits, blue_bits, alpha_bits;
/* For debugging only */ /* For debugging only */
if (_mesa_getenv("MESA_XSYNC")) { if (getenv("MESA_XSYNC")) {
/* This makes debugging X easier. /* This makes debugging X easier.
* In your debugger, set a breakpoint on _XError to stop when an * In your debugger, set a breakpoint on _XError to stop when an
* X protocol error is generated. * X protocol error is generated.
@@ -791,7 +791,7 @@ XMesaVisual XMesaCreateVisual( XMesaDisplay *display,
memcpy(v->visinfo, visinfo, sizeof(*visinfo)); memcpy(v->visinfo, visinfo, sizeof(*visinfo));
/* check for MESA_GAMMA environment variable */ /* check for MESA_GAMMA environment variable */
gamma = _mesa_getenv("MESA_GAMMA"); gamma = getenv("MESA_GAMMA");
if (gamma) { if (gamma) {
v->RedGamma = v->GreenGamma = v->BlueGamma = 0.0; v->RedGamma = v->GreenGamma = v->BlueGamma = 0.0;
sscanf( gamma, "%f %f %f", &v->RedGamma, &v->GreenGamma, &v->BlueGamma ); sscanf( gamma, "%f %f %f", &v->RedGamma, &v->GreenGamma, &v->BlueGamma );

View File

@@ -1090,10 +1090,10 @@ _mesa_initialize_context(struct gl_context *ctx,
ctx->CurrentDispatch = ctx->OutsideBeginEnd; ctx->CurrentDispatch = ctx->OutsideBeginEnd;
ctx->FragmentProgram._MaintainTexEnvProgram ctx->FragmentProgram._MaintainTexEnvProgram
= (_mesa_getenv("MESA_TEX_PROG") != NULL); = (getenv("MESA_TEX_PROG") != NULL);
ctx->VertexProgram._MaintainTnlProgram ctx->VertexProgram._MaintainTnlProgram
= (_mesa_getenv("MESA_TNL_PROG") != NULL); = (getenv("MESA_TNL_PROG") != NULL);
if (ctx->VertexProgram._MaintainTnlProgram) { if (ctx->VertexProgram._MaintainTnlProgram) {
/* this is required... */ /* this is required... */
ctx->FragmentProgram._MaintainTexEnvProgram = GL_TRUE; ctx->FragmentProgram._MaintainTexEnvProgram = GL_TRUE;
@@ -1537,7 +1537,7 @@ handle_first_current(struct gl_context *ctx)
* first time each context is made current we'll print some useful * first time each context is made current we'll print some useful
* information. * information.
*/ */
if (_mesa_getenv("MESA_INFO")) { if (getenv("MESA_INFO")) {
_mesa_print_info(ctx); _mesa_print_info(ctx);
} }
} }

View File

@@ -215,8 +215,8 @@ set_debug_flags(const char *str)
void void
_mesa_init_debug( struct gl_context *ctx ) _mesa_init_debug( struct gl_context *ctx )
{ {
set_debug_flags(_mesa_getenv("MESA_DEBUG")); set_debug_flags(getenv("MESA_DEBUG"));
set_verbose_flags(_mesa_getenv("MESA_VERBOSE")); set_verbose_flags(getenv("MESA_VERBOSE"));
} }

View File

@@ -1170,7 +1170,7 @@ output_if_debug(const char *prefixString, const char *outputString,
/* If MESA_LOG_FILE env var is set, log Mesa errors, warnings, /* If MESA_LOG_FILE env var is set, log Mesa errors, warnings,
* etc to the named file. Otherwise, output to stderr. * etc to the named file. Otherwise, output to stderr.
*/ */
const char *logFile = _mesa_getenv("MESA_LOG_FILE"); const char *logFile = getenv("MESA_LOG_FILE");
if (logFile) if (logFile)
fout = fopen(logFile, "w"); fout = fopen(logFile, "w");
if (!fout) if (!fout)
@@ -1183,7 +1183,7 @@ output_if_debug(const char *prefixString, const char *outputString,
debug = 1; debug = 1;
#else #else
/* in release builds, be silent unless MESA_DEBUG is set */ /* in release builds, be silent unless MESA_DEBUG is set */
debug = _mesa_getenv("MESA_DEBUG") != NULL; debug = getenv("MESA_DEBUG") != NULL;
#endif #endif
} }
@@ -1288,7 +1288,7 @@ should_output(struct gl_context *ctx, GLenum error, const char *fmtString)
/* Check debug environment variable only once: /* Check debug environment variable only once:
*/ */
if (debug == -1) { if (debug == -1) {
const char *debugEnv = _mesa_getenv("MESA_DEBUG"); const char *debugEnv = getenv("MESA_DEBUG");
#ifdef DEBUG #ifdef DEBUG
if (debugEnv && strstr(debugEnv, "silent")) if (debugEnv && strstr(debugEnv, "silent"))

View File

@@ -588,7 +588,7 @@ free_unknown_extensions_strings(void)
void void
_mesa_one_time_init_extension_overrides(void) _mesa_one_time_init_extension_overrides(void)
{ {
const char *env_const = _mesa_getenv("MESA_EXTENSION_OVERRIDE"); const char *env_const = getenv("MESA_EXTENSION_OVERRIDE");
char *env; char *env;
char *ext; char *ext;
int len; int len;

View File

@@ -474,22 +474,6 @@ _mesa_half_to_float(GLhalfARB val)
/*@}*/ /*@}*/
/**********************************************************************/
/** \name Environment vars */
/*@{*/
/**
* Wrapper for getenv().
*/
char *
_mesa_getenv( const char *var )
{
return getenv(var);
}
/*@}*/
/**********************************************************************/ /**********************************************************************/
/** \name String */ /** \name String */
/*@{*/ /*@{*/

View File

@@ -534,9 +534,6 @@ _mesa_half_is_negative(GLhalfARB h)
return h & 0x8000; return h & 0x8000;
} }
extern char *
_mesa_getenv( const char *var );
extern char * extern char *
_mesa_strdup( const char *s ); _mesa_strdup( const char *s );

View File

@@ -70,7 +70,7 @@ GLbitfield
_mesa_get_shader_flags(void) _mesa_get_shader_flags(void)
{ {
GLbitfield flags = 0x0; GLbitfield flags = 0x0;
const char *env = _mesa_getenv("MESA_GLSL"); const char *env = getenv("MESA_GLSL");
if (env) { if (env) {
if (strstr(env, "dump_on_error")) if (strstr(env, "dump_on_error"))

View File

@@ -355,7 +355,7 @@ void _math_test_all_cliptest_functions( char *description )
if ( first_time ) { if ( first_time ) {
first_time = 0; first_time = 0;
mesa_profile = _mesa_getenv( "MESA_PROFILE" ); mesa_profile = getenv( "MESA_PROFILE" );
} }
#ifdef RUN_DEBUG_BENCHMARK #ifdef RUN_DEBUG_BENCHMARK

View File

@@ -339,7 +339,7 @@ void _math_test_all_normal_transform_functions( char *description )
if ( first_time ) { if ( first_time ) {
first_time = 0; first_time = 0;
mesa_profile = _mesa_getenv( "MESA_PROFILE" ); mesa_profile = getenv( "MESA_PROFILE" );
} }
#ifdef RUN_DEBUG_BENCHMARK #ifdef RUN_DEBUG_BENCHMARK

View File

@@ -285,7 +285,7 @@ void _math_test_all_transform_functions( char *description )
if ( first_time ) { if ( first_time ) {
first_time = 0; first_time = 0;
mesa_profile = _mesa_getenv( "MESA_PROFILE" ); mesa_profile = getenv( "MESA_PROFILE" );
} }
#ifdef RUN_DEBUG_BENCHMARK #ifdef RUN_DEBUG_BENCHMARK

View File

@@ -543,7 +543,7 @@ void _tnl_init_vertices( struct gl_context *ctx,
vtx->codegen_emit = NULL; vtx->codegen_emit = NULL;
#ifdef USE_SSE_ASM #ifdef USE_SSE_ASM
if (!_mesa_getenv("MESA_NO_CODEGEN")) if (!getenv("MESA_NO_CODEGEN"))
vtx->codegen_emit = _tnl_generate_sse_emit; vtx->codegen_emit = _tnl_generate_sse_emit;
#endif #endif
} }

View File

@@ -64,7 +64,7 @@ extern void _mesa_x86_64_transform_points4_2d( XFORM_ARGS );
#ifdef USE_X86_64_ASM #ifdef USE_X86_64_ASM
static void message( const char *msg ) static void message( const char *msg )
{ {
if (_mesa_getenv("MESA_DEBUG")) { if (getenv("MESA_DEBUG")) {
_mesa_debug( NULL, "%s", msg ); _mesa_debug( NULL, "%s", msg );
} }
} }
@@ -76,7 +76,7 @@ void _mesa_init_all_x86_64_transform_asm(void)
#ifdef USE_X86_64_ASM #ifdef USE_X86_64_ASM
unsigned int regs[4]; unsigned int regs[4];
if ( _mesa_getenv( "MESA_NO_ASM" ) ) { if ( getenv( "MESA_NO_ASM" ) ) {
return; return;
} }

View File

@@ -224,7 +224,7 @@ _mesa_get_x86_features(void)
#ifdef USE_X86_ASM #ifdef USE_X86_ASM
_mesa_x86_cpu_features = 0x0; _mesa_x86_cpu_features = 0x0;
if (_mesa_getenv( "MESA_NO_ASM")) { if (getenv( "MESA_NO_ASM")) {
return; return;
} }
@@ -307,7 +307,7 @@ _mesa_get_x86_features(void)
#ifdef USE_MMX_ASM #ifdef USE_MMX_ASM
if ( cpu_has_mmx ) { if ( cpu_has_mmx ) {
if ( _mesa_getenv( "MESA_NO_MMX" ) == 0 ) { if ( getenv( "MESA_NO_MMX" ) == 0 ) {
if (detection_debug) if (detection_debug)
_mesa_debug(NULL, "MMX cpu detected.\n"); _mesa_debug(NULL, "MMX cpu detected.\n");
} else { } else {
@@ -318,7 +318,7 @@ _mesa_get_x86_features(void)
#ifdef USE_3DNOW_ASM #ifdef USE_3DNOW_ASM
if ( cpu_has_3dnow ) { if ( cpu_has_3dnow ) {
if ( _mesa_getenv( "MESA_NO_3DNOW" ) == 0 ) { if ( getenv( "MESA_NO_3DNOW" ) == 0 ) {
if (detection_debug) if (detection_debug)
_mesa_debug(NULL, "3DNow! cpu detected.\n"); _mesa_debug(NULL, "3DNow! cpu detected.\n");
} else { } else {
@@ -329,10 +329,10 @@ _mesa_get_x86_features(void)
#ifdef USE_SSE_ASM #ifdef USE_SSE_ASM
if ( cpu_has_xmm ) { if ( cpu_has_xmm ) {
if ( _mesa_getenv( "MESA_NO_SSE" ) == 0 ) { if ( getenv( "MESA_NO_SSE" ) == 0 ) {
if (detection_debug) if (detection_debug)
_mesa_debug(NULL, "SSE cpu detected.\n"); _mesa_debug(NULL, "SSE cpu detected.\n");
if ( _mesa_getenv( "MESA_FORCE_SSE" ) == 0 ) { if ( getenv( "MESA_FORCE_SSE" ) == 0 ) {
_mesa_check_os_sse_support(); _mesa_check_os_sse_support();
} }
} else { } else {