--- src/mapi/glapi/gen/gl_enums.py | 4 ++-- src/mesa/drivers/common/meta.c | 6 +++--- src/mesa/main/debug.c | 8 ++++---- src/mesa/main/dlist.c | 5 +++-- src/mesa/main/errors.c | 7 +++---- src/mesa/main/imports.c | 14 -------------- src/mesa/main/imports.h | 3 --- src/mesa/main/teximage.c | 16 ++++++++-------- src/mesa/main/uniform_query.cpp | 7 ++++--- src/mesa/main/version.c | 18 +++++++++--------- src/mesa/program/prog_instruction.c | 5 +++-- src/mesa/program/prog_print.c | 9 +++++---- src/mesa/program/program_parse.y | 17 +++++++++-------- 13 files changed, 53 insertions(+), 66 deletions(-)
diff --git a/src/mapi/glapi/gen/gl_enums.py b/src/mapi/glapi/gen/gl_enums.py index 00f8134bae2..4f4feaf3f88 100644 --- a/src/mapi/glapi/gen/gl_enums.py +++ b/src/mapi/glapi/gen/gl_enums.py @@ -52,8 +52,8 @@ class PrintGlEnums(gl_XML.gl_print_base): def printRealHeader(self): print('#include "main/glheader.h"') print('#include "main/enums.h"') - print('#include "main/imports.h"') print('#include "main/mtypes.h"') + print('#include "util/u_string.h"') print('') print('typedef struct PACKED {') print(' uint32_t offset;') @@ -103,7 +103,7 @@ _mesa_enum_to_string(int nr) } else { /* this is not re-entrant safe, no big deal here */ - _mesa_snprintf(token_tmp, sizeof(token_tmp) - 1, "0x%x", nr); + util_snprintf(token_tmp, sizeof(token_tmp) - 1, "0x%x", nr); token_tmp[sizeof(token_tmp) - 1] = '\\0'; return token_tmp; } diff --git a/src/mesa/drivers/common/meta.c b/src/mesa/drivers/common/meta.c index 4392c4bbd88..89dc8b26d52 100644 --- a/src/mesa/drivers/common/meta.c +++ b/src/mesa/drivers/common/meta.c @@ -33,7 +33,6 @@ #include "main/glheader.h" #include "main/mtypes.h" -#include "main/imports.h" #include "main/arbprogram.h" #include "main/arrayobj.h" #include "main/blend.h" @@ -90,6 +89,7 @@ #include "util/ralloc.h" #include "compiler/nir/nir.h" #include "util/u_math.h" +#include "util/u_string.h" /** Return offset in bytes of the field within a vertex struct */ #define OFFSET(FIELD) ((void *) offsetof(struct vertex, FIELD)) @@ -2047,7 +2047,7 @@ init_draw_stencil_pixels(struct gl_context *ctx) texTarget = "RECT"; else texTarget = "2D"; - _mesa_snprintf(program2, sizeof(program2), program, texTarget); + util_snprintf(program2, sizeof(program2), program, texTarget); _mesa_GenProgramsARB(1, &drawpix->StencilFP); _mesa_BindProgramARB(GL_FRAGMENT_PROGRAM_ARB, drawpix->StencilFP); @@ -2081,7 +2081,7 @@ init_draw_depth_pixels(struct gl_context *ctx) texTarget = "RECT"; else texTarget = "2D"; - _mesa_snprintf(program2, sizeof(program2), program, texTarget); + util_snprintf(program2, sizeof(program2), program, texTarget); _mesa_GenProgramsARB(1, &drawpix->DepthFP); _mesa_BindProgramARB(GL_FRAGMENT_PROGRAM_ARB, drawpix->DepthFP); diff --git a/src/mesa/main/debug.c b/src/mesa/main/debug.c index b1fa1f067ff..a3905c2b4ab 100644 --- a/src/mesa/main/debug.c +++ b/src/mesa/main/debug.c @@ -30,13 +30,13 @@ #include "enums.h" #include "formats.h" #include "hash.h" -#include "imports.h" #include "macros.h" #include "debug.h" #include "get.h" #include "pixelstore.h" #include "readpix.h" #include "texobj.h" +#include "util/u_string.h" static const char * @@ -285,7 +285,7 @@ write_texture_image(struct gl_texture_object *texObj, GL_RGBA, GL_UNSIGNED_BYTE, buffer, img); /* make filename */ - _mesa_snprintf(s, sizeof(s), "/tmp/tex%u.l%u.f%u.ppm", texObj->Name, level, face); + util_snprintf(s, sizeof(s), "/tmp/tex%u.l%u.f%u.ppm", texObj->Name, level, face); printf(" Writing image level %u to %s\n", level, s); write_ppm(s, buffer, img->Width, img->Height, 4, 0, 1, 2, GL_FALSE); @@ -331,8 +331,8 @@ _mesa_write_renderbuffer_image(const struct gl_renderbuffer *rb) format, type, &ctx->DefaultPacking, buffer); /* make filename */ - _mesa_snprintf(s, sizeof(s), "/tmp/renderbuffer%u.ppm", rb->Name); - _mesa_snprintf(s, sizeof(s), "C:\\renderbuffer%u.ppm", rb->Name); + util_snprintf(s, sizeof(s), "/tmp/renderbuffer%u.ppm", rb->Name); + util_snprintf(s, sizeof(s), "C:\\renderbuffer%u.ppm", rb->Name); printf(" Writing renderbuffer image to %s\n", s); diff --git a/src/mesa/main/dlist.c b/src/mesa/main/dlist.c index 97461cede34..c530e118dd3 100644 --- a/src/mesa/main/dlist.c +++ b/src/mesa/main/dlist.c @@ -31,7 +31,6 @@ #include "c99_math.h" #include "glheader.h" -#include "imports.h" #include "api_arrayelt.h" #include "api_exec.h" #include "api_loopback.h" @@ -71,6 +70,8 @@ #include "vbo/vbo.h" +#include "util/u_string.h" + #define USE_BITMAP_ATLAS 1 @@ -10736,7 +10737,7 @@ execute_list(struct gl_context *ctx, GLuint list) default: { char msg[1000]; - _mesa_snprintf(msg, sizeof(msg), "Error in execute_list: opcode=%d", + util_snprintf(msg, sizeof(msg), "Error in execute_list: opcode=%d", (int) opcode); _mesa_problem(ctx, "%s", msg); } diff --git a/src/mesa/main/errors.c b/src/mesa/main/errors.c index 18dff1ce3cc..cebab9431e4 100644 --- a/src/mesa/main/errors.c +++ b/src/mesa/main/errors.c @@ -32,7 +32,6 @@ #include <stdio.h> #include "errors.h" #include "enums.h" -#include "imports.h" #include "context.h" #include "debug_output.h" #include "util/u_string.h" @@ -87,7 +86,7 @@ output_if_debug(const char *prefixString, const char *outputString, * visible, so communicate with the debugger instead */ { char buf[4096]; - _mesa_snprintf(buf, sizeof(buf), "%s: %s%s", prefixString, outputString, newline ? "\n" : ""); + util_snprintf(buf, sizeof(buf), "%s: %s%s", prefixString, outputString, newline ? "\n" : ""); OutputDebugStringA(buf); } #endif @@ -117,7 +116,7 @@ flush_delayed_errors( struct gl_context *ctx ) char s[MAX_DEBUG_MESSAGE_LENGTH]; if (ctx->ErrorDebugCount) { - _mesa_snprintf(s, MAX_DEBUG_MESSAGE_LENGTH, "%d similar %s errors", + util_snprintf(s, MAX_DEBUG_MESSAGE_LENGTH, "%d similar %s errors", ctx->ErrorDebugCount, _mesa_enum_to_string(ctx->ErrorValue)); @@ -307,7 +306,7 @@ _mesa_error( struct gl_context *ctx, GLenum error, const char *fmtString, ... ) return; } - len = _mesa_snprintf(s2, MAX_DEBUG_MESSAGE_LENGTH, "%s in %s", + len = util_snprintf(s2, MAX_DEBUG_MESSAGE_LENGTH, "%s in %s", _mesa_enum_to_string(error), s); if (len >= MAX_DEBUG_MESSAGE_LENGTH) { /* Same as above. */ diff --git a/src/mesa/main/imports.c b/src/mesa/main/imports.c index edb5f8fde4e..7a770d42b73 100644 --- a/src/mesa/main/imports.c +++ b/src/mesa/main/imports.c @@ -211,17 +211,3 @@ _mesa_align_realloc(void *oldBuffer, size_t oldSize, size_t newSize, } /*@}*/ - -/** Wrapper around vsnprintf() */ -int -_mesa_snprintf( char *str, size_t size, const char *fmt, ... ) -{ - int r; - va_list args; - va_start( args, fmt ); - r = vsnprintf( str, size, fmt, args ); - va_end( args ); - return r; -} - - diff --git a/src/mesa/main/imports.h b/src/mesa/main/imports.h index 2535dd23ba8..59133643442 100644 --- a/src/mesa/main/imports.h +++ b/src/mesa/main/imports.h @@ -163,9 +163,6 @@ extern void * _mesa_align_realloc(void *oldBuffer, size_t oldSize, size_t newSize, unsigned long alignment); -extern int -_mesa_snprintf( char *str, size_t size, const char *fmt, ... ) PRINTFLIKE(3, 4); - #if defined(_WIN32) && !defined(strtok_r) #define strtok_r strtok_s diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c index ab1473653c5..bc784a6419c 100644 --- a/src/mesa/main/teximage.c +++ b/src/mesa/main/teximage.c @@ -38,7 +38,6 @@ #include "framebuffer.h" #include "hash.h" #include "image.h" -#include "imports.h" #include "macros.h" #include "mipmap.h" #include "multisample.h" @@ -55,6 +54,7 @@ #include "glformats.h" #include "texstore.h" #include "pbo.h" +#include "util/u_string.h" /** @@ -1911,7 +1911,7 @@ texture_error_check( struct gl_context *ctx, * requires GL_OES_texture_float) are filtered elsewhere. */ char bufCallerName[20]; - _mesa_snprintf(bufCallerName, 20, "glTexImage%dD", dimensions); + util_snprintf(bufCallerName, 20, "glTexImage%dD", dimensions); if (_mesa_is_gles(ctx) && texture_format_error_check_gles(ctx, format, type, internalFormat, bufCallerName)) { @@ -1940,9 +1940,9 @@ texture_error_check( struct gl_context *ctx, if (type != GL_UNSIGNED_SHORT_8_8_MESA && type != GL_UNSIGNED_SHORT_8_8_REV_MESA) { char message[100]; - _mesa_snprintf(message, sizeof(message), - "glTexImage%dD(format/type YCBCR mismatch)", - dimensions); + util_snprintf(message, sizeof(message), + "glTexImage%dD(format/type YCBCR mismatch)", + dimensions); _mesa_error(ctx, GL_INVALID_ENUM, "%s", message); return GL_TRUE; /* error */ } @@ -1957,9 +1957,9 @@ texture_error_check( struct gl_context *ctx, } if (border != 0) { char message[100]; - _mesa_snprintf(message, sizeof(message), - "glTexImage%dD(format=GL_YCBCR_MESA and border=%d)", - dimensions, border); + util_snprintf(message, sizeof(message), + "glTexImage%dD(format=GL_YCBCR_MESA and border=%d)", + dimensions, border); _mesa_error(ctx, GL_INVALID_VALUE, "%s", message); return GL_TRUE; } diff --git a/src/mesa/main/uniform_query.cpp b/src/mesa/main/uniform_query.cpp index de594fcc3d7..1f7132d5675 100644 --- a/src/mesa/main/uniform_query.cpp +++ b/src/mesa/main/uniform_query.cpp @@ -37,6 +37,7 @@ #include "compiler/glsl/glsl_parser_extras.h" #include "compiler/glsl/program.h" #include "util/bitscan.h" +#include "util/u_string.h" extern "C" void GLAPIENTRY @@ -1594,9 +1595,9 @@ _mesa_sampler_uniforms_are_valid(const struct gl_shader_program *shProg, return true; if (!shProg->SamplersValidated) { - _mesa_snprintf(errMsg, errMsgLength, - "active samplers with a different type " - "refer to the same texture image unit"); + util_snprintf(errMsg, errMsgLength, + "active samplers with a different type " + "refer to the same texture image unit"); return false; } return true; diff --git a/src/mesa/main/version.c b/src/mesa/main/version.c index 610ba2f08c5..216ba9d518d 100644 --- a/src/mesa/main/version.c +++ b/src/mesa/main/version.c @@ -25,10 +25,10 @@ #include <stdio.h> #include "context.h" -#include "imports.h" #include "mtypes.h" #include "version.h" #include "git_sha1.h" +#include "util/u_string.h" /** * Scans 'string' to see if it ends with 'ending'. @@ -120,14 +120,14 @@ create_version_string(struct gl_context *ctx, const char *prefix) ctx->VersionString = malloc(max); if (ctx->VersionString) { - _mesa_snprintf(ctx->VersionString, max, - "%s%u.%u%s Mesa " PACKAGE_VERSION MESA_GIT_SHA1, - prefix, - ctx->Version / 10, ctx->Version % 10, - (ctx->API == API_OPENGL_CORE) ? " (Core Profile)" : - (ctx->API == API_OPENGL_COMPAT && ctx->Version >= 32) ? - " (Compatibility Profile)" : "" - ); + util_snprintf(ctx->VersionString, max, + "%s%u.%u%s Mesa " PACKAGE_VERSION MESA_GIT_SHA1, + prefix, + ctx->Version / 10, ctx->Version % 10, + (ctx->API == API_OPENGL_CORE) ? " (Core Profile)" : + (ctx->API == API_OPENGL_COMPAT && ctx->Version >= 32) ? + " (Compatibility Profile)" : "" + ); } } diff --git a/src/mesa/program/prog_instruction.c b/src/mesa/program/prog_instruction.c index 91830d87f25..3d4d86a2935 100644 --- a/src/mesa/program/prog_instruction.c +++ b/src/mesa/program/prog_instruction.c @@ -24,10 +24,11 @@ */ +#include <stdbool.h> #include "main/glheader.h" -#include "main/imports.h" #include "prog_instruction.h" #include "prog_parameter.h" +#include "util/u_string.h" /** @@ -250,7 +251,7 @@ _mesa_opcode_string(enum prog_opcode opcode) return InstInfo[opcode].Name; else { static char s[20]; - _mesa_snprintf(s, sizeof(s), "OP%u", opcode); + util_snprintf(s, sizeof(s), "OP%u", opcode); return s; } } diff --git a/src/mesa/program/prog_print.c b/src/mesa/program/prog_print.c index e8d087c506b..082566069d4 100644 --- a/src/mesa/program/prog_print.c +++ b/src/mesa/program/prog_print.c @@ -33,11 +33,12 @@ #include "main/glheader.h" #include "main/context.h" -#include "main/imports.h" #include "prog_instruction.h" #include "prog_parameter.h" #include "prog_print.h" #include "prog_statevars.h" +#include "util/u_string.h" +#include "util/bitscan.h" // For ffs definition @@ -83,7 +84,7 @@ _mesa_register_file_name(gl_register_file f) default: { static char s[20]; - _mesa_snprintf(s, sizeof(s), "FILE%u", f); + util_snprintf(s, sizeof(s), "FILE%u", f); return s; } } @@ -986,7 +987,7 @@ _mesa_write_shader_to_file(const struct gl_shader *shader) break; } - _mesa_snprintf(filename, sizeof(filename), "shader_%u.%s", shader->Name, type); + util_snprintf(filename, sizeof(filename), "shader_%u.%s", shader->Name, type); f = fopen(filename, "w"); if (!f) { fprintf(stderr, "Unable to open %s for writing\n", filename); @@ -1029,7 +1030,7 @@ _mesa_append_uniforms_to_file(const struct gl_program *prog) else type = "vert"; - _mesa_snprintf(filename, sizeof(filename), "shader.%s", type); + util_snprintf(filename, sizeof(filename), "shader.%s", type); f = fopen(filename, "a"); /* append */ if (!f) { fprintf(stderr, "Unable to open %s for appending\n", filename); diff --git a/src/mesa/program/program_parse.y b/src/mesa/program/program_parse.y index 7398f5f507a..1a5b3f90f3d 100644 --- a/src/mesa/program/program_parse.y +++ b/src/mesa/program/program_parse.y @@ -40,6 +40,7 @@ #include "program/program_parser.h" #include "util/u_math.h" +#include "util/u_string.h" extern void *yy_scan_string(char *); extern void yy_delete_buffer(void *); @@ -889,8 +890,8 @@ addrRegPosOffset: INTEGER { if (($1 < 0) || ($1 > (state->limits->MaxAddressOffset - 1))) { char s[100]; - _mesa_snprintf(s, sizeof(s), - "relative address offset too large (%d)", $1); + util_snprintf(s, sizeof(s), + "relative address offset too large (%d)", $1); yyerror(& @1, state, s); YYERROR; } else { @@ -903,8 +904,8 @@ addrRegNegOffset: INTEGER { if (($1 < 0) || ($1 > state->limits->MaxAddressOffset)) { char s[100]; - _mesa_snprintf(s, sizeof(s), - "relative address offset too large (%d)", $1); + util_snprintf(s, sizeof(s), + "relative address offset too large (%d)", $1); yyerror(& @1, state, s); YYERROR; } else { @@ -1120,9 +1121,9 @@ optArraySize: { if (($1 < 1) || ((unsigned) $1 > state->limits->MaxParameters)) { char msg[100]; - _mesa_snprintf(msg, sizeof(msg), - "invalid parameter array size (size=%d max=%u)", - $1, state->limits->MaxParameters); + util_snprintf(msg, sizeof(msg), + "invalid parameter array size (size=%d max=%u)", + $1, state->limits->MaxParameters); yyerror(& @1, state, msg); YYERROR; } else { @@ -2033,7 +2034,7 @@ ALIAS_statement: ALIAS IDENTIFIER '=' USED_IDENTIFIER if (exist != NULL) { char m[1000]; - _mesa_snprintf(m, sizeof(m), "redeclared identifier: %s", $2); + util_snprintf(m, sizeof(m), "redeclared identifier: %s", $2); free($2); yyerror(& @2, state, m); YYERROR; -- 2.19.1 _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev