mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-16 16:18:06 +02:00
Fixes: 2771eb39fd ("util: Add function os_unset_option/os_set_option for latter use")
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/14805
```
FAILED: [code=1] src/util/libmesa_util.a.p/u_process.c.obj
"cc" "-Isrc/util/libmesa_util.a.p" "-Isrc/util" "-I../../src/util" "-Iinclude" "-I../../include" "-Isrc" "-I../../src" "-Isrc/util/format" "-I../../src/util/format" "-IC:/msys64/clang64/bin/../include" "-fvisibility=hidden" "-fdiagnostics-color=always" "-D_FILE_OFFSET_BITS=64" "-Wall" "-Winvalid-pch" "-std=c11" "-O2" "-g" "-D__STDC_CONSTANT_MACROS" "-D__STDC_FORMAT_MACROS" "-D__STDC_LIMIT_MACROS" "-DPACKAGE_VERSION=\"26.0.0-rc3\"" "-DPACKAGE_BUGREPORT=\"https://gitlab.freedesktop.org/mesa/mesa/-/issues\"" "-DHAVE_OPENGL=1" "-DHAVE_OPENGL_ES_1=1" "-DHAVE_OPENGL_ES_2=1" "-DHAVE_SOFTPIPE" "-DHAVE_LLVMPIPE" "-DHAVE_ZINK" "-DHAVE_D3D12" "-DHAVE_VIRGL" "-DHAVE_SWRAST" "-DMESA_SYSTEM_HAS_KMS_DRM=0" "-DVIDEO_CODEC_VC1DEC=1" "-DVIDEO_CODEC_H264DEC=1" "-DVIDEO_CODEC_H264ENC=1" "-DVIDEO_CODEC_H265DEC=1" "-DVIDEO_CODEC_H265ENC=1" "-DVIDEO_CODEC_AV1DEC=1" "-DVIDEO_CODEC_AV1ENC=1" "-DVIDEO_CODEC_VP9DEC=1" "-DVIDEO_CODEC_MPEG12DEC=1" "-DVIDEO_CODEC_JPEGDEC=1" "-DHAVE_WINDOWS_PLATFORM" "-DHAVE_SURFACELESS_PLATFORM" "-DUSE_LIBGLVND=0" "-DUSE_D3D12_PREVIEW_HEADERS=0" "-DHAVE_GALLIUM_D3D12_VIDEO" "-DHAVE_VA_SURFACE_ATTRIB_DRM_FORMAT_MODIFIERS" "-DGLAPI_EXPORT_PROTO_ENTRY_POINTS=1" "-DALLOW_KCMP" "-DMESA_DEBUG=0" "-DHAVE___BUILTIN_BSWAP32" "-DHAVE___BUILTIN_BSWAP64" "-DHAVE___BUILTIN_CLZ" "-DHAVE___BUILTIN_CLZLL" "-DHAVE___BUILTIN_CTZ" "-DHAVE___BUILTIN_EXPECT" "-DHAVE___BUILTIN_FFS" "-DHAVE___BUILTIN_FFSLL" "-DHAVE___BUILTIN_POPCOUNT" "-DHAVE___BUILTIN_POPCOUNTLL" "-DHAVE___BUILTIN_UNREACHABLE" "-DHAVE___BUILTIN_TYPES_COMPATIBLE_P" "-DHAVE___BUILTIN_ADD_OVERFLOW" "-DHAVE_FUNC_ATTRIBUTE_CONST" "-DHAVE_FUNC_ATTRIBUTE_FLATTEN" "-DHAVE_FUNC_ATTRIBUTE_MALLOC" "-DHAVE_FUNC_ATTRIBUTE_PURE" "-DHAVE_FUNC_ATTRIBUTE_UNUSED" "-DHAVE_FUNC_ATTRIBUTE_WARN_UNUSED_RESULT" "-DHAVE_FUNC_ATTRIBUTE_WEAK" "-DHAVE_FUNC_ATTRIBUTE_FORMAT" "-DHAVE_FUNC_ATTRIBUTE_PACKED" "-DHAVE_FUNC_ATTRIBUTE_RETURNS_NONNULL" "-DHAVE_FUNC_ATTRIBUTE_ALIAS" "-DHAVE_FUNC_ATTRIBUTE_NORETURN" "-DHAVE_FUNC_ATTRIBUTE_COLD" "-DHAVE_FUNC_ATTRIBUTE_VISIBILITY" "-DHAVE_UINT128" "-D_WIN32_WINNT=0x0A00" "-DWINVER=0x0A00" "-D_GNU_SOURCE" "-DUSE_SSE41" "-DHAVE___BUILTIN_IA32_CLFLUSHOPT" "-DUSE_GCC_ATOMIC_BUILTINS" "-DHAS_SCHED_H" "-DHAVE_DLFCN_H" "-DHAVE_CET_H" "-DHAVE_STRTOF" "-DHAVE_STRTOK_R" "-DHAVE_QSORT_S" "-DHAVE_STRUCT_TIMESPEC" "-DHAVE_ZLIB" "-DHAVE_ZSTD" "-DHAVE_COMPRESSION" "-DWIN32_LEAN_AND_MEAN" "-DWINDOWS_NO_FUTEX" "-DMESA_LLVM_VERSION_STRING=\"21.1.8\"" "-DLLVM_IS_SHARED=0" "-DDRAW_LLVM_AVAILABLE=1" "-DAMD_LLVM_AVAILABLE=1" "-DGALLIVM_USE_ORCJIT=0" "-DHAVE_SPIRV_TOOLS" "-DUSE_LIBELF" "-DTHREAD_SANITIZER=0" "-DHAVE_RENDERDOC_INTEGRATION=false" "-Werror=implicit-function-declaration" "-Werror=missing-prototypes" "-Werror=return-type" "-Werror=empty-body" "-Werror=incompatible-pointer-types" "-Werror=int-conversion" "-Wimplicit-fallthrough" "-Wmisleading-indentation" "-Wno-missing-field-initializers" "-Wno-format-truncation" "-fno-math-errno" "-fno-trapping-math" "-Qunused-arguments" "-fno-common" "-Wno-unknown-pragmas" "-Wno-microsoft-enum-value" "-Wno-unused-function" "-Werror=thread-safety" "-ffunction-sections" "-fdata-sections" "-pipe" "-Wp,-D_FORTIFY_SOURCE=2" "-fstack-protector-strong" "-Wp,-D__USE_MINGW_ANSI_STDIO=1" "-march=core2" "-Werror=pointer-arith" "-Werror=vla" "-Werror=gnu-empty-initializer" "-Wgnu-pointer-arith" -MD -MQ src/util/libmesa_util.a.p/u_process.c.obj -MF "src/util/libmesa_util.a.p/u_process.c.obj.d" -o src/util/libmesa_util.a.p/u_process.c.obj "-c" ../../src/util/u_process.c
In file included from ../../src/util/u_process.c:28:
../../src/util/os_misc.h:151:24: error: use of undeclared identifier 'NULL'
151 | os_set_option(name, NULL, true);
| ^~~~
1 error generated.
```
Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Reviewed-by: Yonggang Luo <luoyonggang@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/40548>
179 lines
5 KiB
C
179 lines
5 KiB
C
/**************************************************************************
|
|
*
|
|
* Copyright 2010 VMware, Inc.
|
|
* All Rights Reserved.
|
|
*
|
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
* copy of this software and associated documentation files (the
|
|
* "Software"), to deal in the Software without restriction, including
|
|
* without limitation the rights to use, copy, modify, merge, publish,
|
|
* distribute, sub license, and/or sell copies of the Software, and to
|
|
* permit persons to whom the Software is furnished to do so, subject to
|
|
* the following conditions:
|
|
*
|
|
* The above copyright notice and this permission notice (including the
|
|
* next paragraph) shall be included in all copies or substantial portions
|
|
* of the Software.
|
|
*
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
|
|
* IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
|
|
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
*
|
|
**************************************************************************/
|
|
|
|
|
|
/*
|
|
* Miscellaneous OS services.
|
|
*/
|
|
|
|
|
|
#ifndef _OS_MISC_H_
|
|
#define _OS_MISC_H_
|
|
|
|
#include <stdint.h>
|
|
#include <stdbool.h>
|
|
#include <stddef.h>
|
|
|
|
#include "util/detect.h"
|
|
|
|
|
|
#if DETECT_OS_POSIX
|
|
# include <signal.h> /* for kill() */
|
|
# include <unistd.h> /* getpid() */
|
|
#endif
|
|
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
|
|
/*
|
|
* Trap into the debugger.
|
|
*/
|
|
#if (DETECT_ARCH_X86 || DETECT_ARCH_X86_64) && DETECT_CC_GCC
|
|
# define os_break() __asm("int3")
|
|
#elif DETECT_CC_MSVC
|
|
# define os_break() __debugbreak()
|
|
#elif DETECT_OS_POSIX
|
|
# define os_break() kill(getpid(), SIGTRAP)
|
|
#else
|
|
# define os_break() abort()
|
|
#endif
|
|
|
|
|
|
/*
|
|
* Abort the program.
|
|
*/
|
|
#if MESA_DEBUG
|
|
# define os_abort() do { os_break(); abort(); } while(0)
|
|
#else
|
|
# define os_abort() abort()
|
|
#endif
|
|
|
|
|
|
/*
|
|
* Output a message. Message should preferably end in a newline.
|
|
*/
|
|
void
|
|
os_log_message(const char *message);
|
|
|
|
|
|
/*
|
|
* Get an option(environment variable or os property) in a platform independent way.
|
|
* Should return NULL if specified option for @name is not set.
|
|
* It has the same disadvantage as getenv, see
|
|
* https://wiki.sei.cmu.edu/confluence/display/c/ENV34-C.+Do+not+store+pointers+returned+by+certain+functions
|
|
*/
|
|
const char *
|
|
os_get_option(const char *name);
|
|
|
|
/*
|
|
* Equivalent to os_get_option except the return value need to be `free()`
|
|
* os_get_option is not safe when the returned value is not immediately used.
|
|
* E.g.
|
|
* 1. when multiple consecutive calls to os_get_option are performed before using the returned values
|
|
* 2. when the value returned by os_get_option is assigned to a struct member
|
|
*/
|
|
char *
|
|
os_get_option_dup(const char *name);
|
|
|
|
/*
|
|
* Get an option(environment variable or os property) in a platform independent way.
|
|
* Should return NULL if specified option for @name is not set.
|
|
* Same as `os_get_option()` but uses `secure_getenv()` instead of `getenv()`
|
|
*/
|
|
const char *
|
|
os_get_option_secure(const char *name);
|
|
|
|
/*
|
|
* Equivalent to os_get_option_secure except the return value need to be `free()`
|
|
* os_get_option_secure is not safe when the returned value is not immediately used.
|
|
* E.g.
|
|
* 1. when multiple consecutive calls to os_get_option_secure are performed before using the returned values
|
|
* 2. when the value returned by os_get_option_secure is assigned to a struct member
|
|
*/
|
|
char *
|
|
os_get_option_secure_dup(const char *name);
|
|
|
|
/*
|
|
* Get an option(environment variable or os property) in a platform independent way.
|
|
* Should return NULL if specified option for @name is not set.
|
|
* It's will save the option into hash table for the first time, and
|
|
* for latter calling, it's will return the value comes from hash table
|
|
* directly, and the returned value will always be valid before program exit
|
|
* The disadvantage is that os_set_option won't take effect after this
|
|
* function is called
|
|
*/
|
|
const char *
|
|
os_get_option_cached(const char *name);
|
|
|
|
/*
|
|
* Set an option(environment variable or os property) in a platform independent way.
|
|
* If @overwrite is true:
|
|
* On windows, equivalent to SetEnvironmentVariableA.
|
|
* On non-windows, when @value is NULL, equivalent to unsetenv, otherwise setenv(override=1).
|
|
* If @overwrite is false:
|
|
* When name already exist, do nothing, otherwise, equivalent to @overwrite is true
|
|
*/
|
|
void
|
|
os_set_option(const char *name, const char *value, bool override);
|
|
|
|
/**
|
|
* Unset an option through os_set_option
|
|
*/
|
|
static inline void
|
|
os_unset_option(const char *name)
|
|
{
|
|
os_set_option(name, NULL, true);
|
|
}
|
|
|
|
/*
|
|
* Get the total amount of physical memory available on the system.
|
|
*/
|
|
bool
|
|
os_get_total_physical_memory(uint64_t *size);
|
|
|
|
/*
|
|
* Amount of physical memory available to a process
|
|
*/
|
|
bool
|
|
os_get_available_system_memory(uint64_t *size);
|
|
|
|
/*
|
|
* Size of a page
|
|
*/
|
|
bool
|
|
os_get_page_size(uint64_t *size);
|
|
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
|
|
#endif /* _OS_MISC_H_ */
|