forked from DevSolar/pdclib
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
xbox: Replace assert() with system-specific version
- Loading branch information
Showing
4 changed files
with
58 additions
and
121 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#include <assert.h> | ||
#include <debug.h> | ||
#include <stdlib.h> | ||
#include "xboxkrnl/xboxkrnl.h" | ||
|
||
void _xbox_assert(char const * const expression, char const * const file_name, char const * const function_name, unsigned long line) | ||
{ | ||
#ifdef DEBUG_CONSOLE | ||
char buffer[512]; | ||
snprintf(buffer, 512, "In function '%s': ", function_name); | ||
RtlAssert((PVOID)expression, (PVOID)file_name, line, buffer); | ||
#else | ||
debugPrint("\nAssertion failed: '%s' in function '%s', file '%s', line %u\n", expression, function_name, file_name, line); | ||
__asm__ ("cli\n" | ||
".l:\n" | ||
"hlt\n" | ||
"jmp .l\n"); | ||
#endif | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* Diagnostics <assert.h> | ||
This file is part of the Public Domain C Library (PDCLib). | ||
Permission is granted to use, modify, and / or redistribute at will. | ||
*/ | ||
|
||
#include "pdclib/_PDCLIB_aux.h" | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
#ifndef _PDCLIB_ASSERT_H | ||
#define _PDCLIB_ASSERT_H | ||
void _xbox_assert(char const * const expression, char const * const file_name, char const * const function_name, unsigned long line); | ||
#endif | ||
|
||
/* If NDEBUG is set, assert() is a null operation. */ | ||
#undef assert | ||
|
||
#ifdef NDEBUG | ||
#define assert(ignore) ((void)0) | ||
#else | ||
#define assert(expression) \ | ||
do { \ | ||
if(!(expression)) { \ | ||
_xbox_assert(_PDCLIB_symbol2string(expression), \ | ||
__FILE__, \ | ||
__func__, \ | ||
__LINE__); \ | ||
} \ | ||
} while(0) | ||
#endif | ||
|
||
#define static_assert _Static_assert | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif |