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 <flibitijibibo@gmail.com>
Co-authored-by: David Jacewicz <david.jacewicz@protonmail.com>
Co-authored-by: tieuchanlong <tieuchanlong@gmail.com>
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/19022>
This commit is contained in:
Caleb Cornett 2023-01-11 10:43:59 -05:00 committed by Marge Bot
parent d575fe8881
commit 7588164717
6 changed files with 27 additions and 1 deletions

View file

@ -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]))

View file

@ -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];

View file

@ -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

View file

@ -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);

View file

@ -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 */

View file

@ -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 */