From 5a2a6db589786e69dea5c50c0430c62a4365cc4f Mon Sep 17 00:00:00 2001 From: libretroadmin Date: Wed, 26 Jun 2024 15:36:31 +0200 Subject: [PATCH] (glslang) use strtok_r instead of strtok --- gfx/drivers_shader/glslang.cpp | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/gfx/drivers_shader/glslang.cpp b/gfx/drivers_shader/glslang.cpp index 03d5cd3798..780d607d6e 100644 --- a/gfx/drivers_shader/glslang.cpp +++ b/gfx/drivers_shader/glslang.cpp @@ -1,6 +1,6 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2016 - Hans-Kristian Arntzen - * + * * RetroArch is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -46,8 +46,8 @@ struct SlangProcess }; /* We don't use glslang from multiple threads, but to be sure. - * Initializing TLS and freeing it for glslang works around - * a really bizarre issue where the TLS key is suddenly + * Initializing TLS and freeing it for glslang works around + * a really bizarre issue where the TLS key is suddenly * corrupted *somehow*. */ static std::mutex glslang_global_lock; @@ -69,6 +69,7 @@ struct SlangProcessHolder SlangProcess::SlangProcess() { + char *save = NULL; char DefaultConfig[] = "MaxLights 32\n" "MaxClipPlanes 6\n" @@ -101,7 +102,7 @@ SlangProcess::SlangProcess() "MaxComputeImageUniforms 8\n" "MaxComputeAtomicCounters 8\n" "MaxComputeAtomicCounterBuffers 1\n" - "MaxVaryingComponents 60\n" + "MaxVaryingComponents 60\n" "MaxVertexOutputComponents 64\n" "MaxGeometryInputComponents 64\n" "MaxGeometryOutputComponents 128\n" @@ -165,11 +166,11 @@ SlangProcess::SlangProcess() "generalConstantMatrixVectorIndexing 1\n"; const char *delims = " \t\n\r"; - char *token = strtok(DefaultConfig, delims); + char *token = strtok_r(DefaultConfig, delims, &save); while (token) { - const char *value_str = strtok(0, delims); + const char *value_str = strtok_r(0, delims, &save); int value = (int)strtoul(value_str, nullptr, 0); if (string_starts_with_size(token, "Max", STRLEN_CONST("Max"))) @@ -384,7 +385,7 @@ SlangProcess::SlangProcess() else if (string_is_equal(token, "doWhileLoops")) Resources.limits.doWhileLoops = (value != 0); - token = strtok(0, delims); + token = strtok_r(0, delims, &save); } } @@ -427,7 +428,7 @@ bool glslang::compile_spirv(const string &source, Stage stage, EShMessages messages = static_cast(EShMsgDefault | EShMsgVulkanRules | EShMsgSpvRules); - glslang::TShader::ForbidIncluder forbid_include = + glslang::TShader::ForbidIncluder forbid_include = glslang::TShader::ForbidIncluder(); if (!shader.preprocess(&process.GetResources(),