Module: Mesa Branch: main Commit: 75881647179f447d8cf009e91cb2699321bc341d URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=75881647179f447d8cf009e91cb2699321bc341d
Author: Caleb Cornett <[email protected]> Date: Wed Jan 11 10:43:59 2023 -0500 util: Add #ifdefs for Xbox GDK support. For the most part this just disables debug/console code, with the minor exception of u_memstream_open. Co-authored-by: Ethan Lee <[email protected]> Co-authored-by: David Jacewicz <[email protected]> Co-authored-by: tieuchanlong <[email protected]> Reviewed-by: Jesse Natalie <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/19022> --- src/util/macros.h | 7 +++++++ src/util/memstream.c | 8 +++++++- src/util/os_file.c | 3 +++ src/util/os_misc.c | 2 ++ src/util/u_debug.c | 2 ++ src/util/u_debug_symbol.c | 6 ++++++ 6 files changed, 27 insertions(+), 1 deletion(-) diff --git a/src/util/macros.h b/src/util/macros.h index 84b2cddfbae..b00c3d2001c 100644 --- a/src/util/macros.h +++ b/src/util/macros.h @@ -29,6 +29,13 @@ #include <stdint.h> #include <stdio.h> +#ifdef _GAMING_XBOX +#define strdup _strdup +#define stricmp _stricmp +#define unlink _unlink +#define access(a, b) _access(a, b) +#endif + /* Compute the size of an array */ #ifndef ARRAY_SIZE # define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) diff --git a/src/util/memstream.c b/src/util/memstream.c index faf70d3a379..afbf13fb7b8 100644 --- a/src/util/memstream.c +++ b/src/util/memstream.c @@ -34,7 +34,13 @@ bool u_memstream_open(struct u_memstream *mem, char **bufp, size_t *sizep) { -#if defined(_WIN32) +#ifdef _GAMING_XBOX + int err = tmpfile_s(&mem->f); + mem->bufp = bufp; + mem->sizep = sizep; + + return err == 0; +#elif defined(_WIN32) bool success = false; char path[MAX_PATH]; diff --git a/src/util/os_file.c b/src/util/os_file.c index 5f79284e083..18149b2a4fd 100644 --- a/src/util/os_file.c +++ b/src/util/os_file.c @@ -15,6 +15,9 @@ #include <io.h> #define open _open #define fdopen _fdopen +#define close _close +#define dup _dup +#define read _read #define O_CREAT _O_CREAT #define O_EXCL _O_EXCL #define O_WRONLY _O_WRONLY diff --git a/src/util/os_misc.c b/src/util/os_misc.c index 538b3f693c8..6ae97b983bb 100644 --- a/src/util/os_misc.c +++ b/src/util/os_misc.c @@ -107,6 +107,7 @@ os_log_message(const char *message) #if DETECT_OS_WINDOWS OutputDebugStringA(message); +#if !defined(_GAMING_XBOX) if(GetConsoleWindow() && !IsDebuggerPresent()) { fflush(stdout); fputs(message, fout); @@ -116,6 +117,7 @@ os_log_message(const char *message) fputs(message, fout); fflush(fout); } +#endif #else /* !DETECT_OS_WINDOWS */ fflush(stdout); fputs(message, fout); diff --git a/src/util/u_debug.c b/src/util/u_debug.c index a5f85120a98..d3bedcac5f0 100644 --- a/src/util/u_debug.c +++ b/src/util/u_debug.c @@ -85,6 +85,7 @@ debug_disable_win32_error_dialogs(void) */ UINT uMode = SetErrorMode(0); SetErrorMode(uMode); +#ifndef _GAMING_XBOX if (uMode & SEM_FAILCRITICALERRORS) { /* Disable assertion failure message box. * http://msdn.microsoft.com/en-us/library/sas1dkb2.aspx @@ -97,6 +98,7 @@ debug_disable_win32_error_dialogs(void) _set_abort_behavior(0, _WRITE_ABORT_MSG | _CALL_REPORTFAULT); #endif } +#endif /* _GAMING_XBOX */ } #endif /* _WIN32 */ diff --git a/src/util/u_debug_symbol.c b/src/util/u_debug_symbol.c index df3c886a425..b85ac05b9f7 100644 --- a/src/util/u_debug_symbol.c +++ b/src/util/u_debug_symbol.c @@ -133,10 +133,12 @@ DBGHELP_DISPATCH(SymSetOptions, (DWORD SymOptions), (SymOptions)) +#ifndef _GAMING_XBOX DBGHELP_DISPATCH(SymFromAddr, BOOL, FALSE, (HANDLE hProcess, DWORD64 Address, PDWORD64 Displacement, PSYMBOL_INFO Symbol), (hProcess, Address, Displacement, Symbol)) +#endif DBGHELP_DISPATCH(SymGetLineFromAddr64, BOOL, FALSE, @@ -152,6 +154,7 @@ DBGHELP_DISPATCH(SymCleanup, BOOL, FALSE, (HANDLE hProcess), (hProcess)) static inline bool debug_symbol_name_dbghelp(const void *addr, char* buf, unsigned size) { +#ifndef _GAMING_XBOX DWORD64 dwAddr = (DWORD64)(uintptr_t)addr; HANDLE hProcess = GetCurrentProcess(); @@ -225,6 +228,9 @@ debug_symbol_name_dbghelp(const void *addr, char* buf, unsigned size) } return true; +#else + return false; +#endif /* _GAMING_XBOX */ } #endif /* DETECT_OS_WINDOWS */
