src/SDL_assert.c
author Sam Lantinga <slouken@libsdl.org>
Fri, 14 Jun 2019 13:56:42 -0700
changeset 12860 0f52dd40abe5
parent 12849 5cd9ce1d28f2
child 12864 a3253dcaf18f
permissions -rw-r--r--
Worked around "Undefined symbol: ___isPlatformVersionAtLeast()" link error on Xcode 11 beta
slouken@3647
     1
/*
slouken@5535
     2
  Simple DirectMedia Layer
slouken@12503
     3
  Copyright (C) 1997-2019 Sam Lantinga <slouken@libsdl.org>
slouken@3647
     4
slouken@5535
     5
  This software is provided 'as-is', without any express or implied
slouken@5535
     6
  warranty.  In no event will the authors be held liable for any damages
slouken@5535
     7
  arising from the use of this software.
slouken@3647
     8
slouken@5535
     9
  Permission is granted to anyone to use this software for any purpose,
slouken@5535
    10
  including commercial applications, and to alter it and redistribute it
slouken@5535
    11
  freely, subject to the following restrictions:
slouken@3647
    12
slouken@5535
    13
  1. The origin of this software must not be misrepresented; you must not
slouken@5535
    14
     claim that you wrote the original software. If you use this software
slouken@5535
    15
     in a product, an acknowledgment in the product documentation would be
slouken@5535
    16
     appreciated but is not required.
slouken@5535
    17
  2. Altered source versions must be plainly marked as such, and must not be
slouken@5535
    18
     misrepresented as being the original software.
slouken@5535
    19
  3. This notice may not be removed or altered from any source distribution.
slouken@3647
    20
*/
icculus@8093
    21
#include "./SDL_internal.h"
slouken@3647
    22
slouken@7828
    23
#if defined(__WIN32__)
slouken@7828
    24
#include "core/windows/SDL_windows.h"
slouken@7828
    25
#endif
slouken@7828
    26
slouken@3651
    27
#include "SDL.h"
slouken@5006
    28
#include "SDL_atomic.h"
slouken@6621
    29
#include "SDL_messagebox.h"
slouken@6621
    30
#include "SDL_video.h"
slouken@3647
    31
#include "SDL_assert.h"
slouken@4472
    32
#include "SDL_assert_c.h"
slouken@3671
    33
#include "video/SDL_sysvideo.h"
slouken@3647
    34
slouken@5086
    35
#ifdef __WIN32__
slouken@5086
    36
#ifndef WS_OVERLAPPEDWINDOW
slouken@5086
    37
#define WS_OVERLAPPEDWINDOW 0
slouken@5086
    38
#endif
slouken@3647
    39
#else  /* fprintf, _exit(), etc. */
slouken@3647
    40
#include <stdio.h>
slouken@3647
    41
#include <stdlib.h>
dludwig@8341
    42
#if ! defined(__WINRT__)
icculus@3648
    43
#include <unistd.h>
slouken@3647
    44
#endif
dludwig@8341
    45
#endif
slouken@3647
    46
icculus@11017
    47
#if defined(__EMSCRIPTEN__)
icculus@11017
    48
#include <emscripten.h>
icculus@11017
    49
#endif
icculus@11017
    50
icculus@11017
    51
slouken@11272
    52
static SDL_assert_state SDLCALL
icculus@3670
    53
SDL_PromptAssertion(const SDL_assert_data *data, void *userdata);
icculus@3670
    54
icculus@3670
    55
/*
icculus@3670
    56
 * We keep all triggered assertions in a singly-linked list so we can
slouken@3647
    57
 *  generate a report later.
slouken@3647
    58
 */
icculus@5541
    59
static SDL_assert_data *triggered_assertions = NULL;
icculus@3670
    60
icculus@11015
    61
#ifndef SDL_THREADS_DISABLED
icculus@3670
    62
static SDL_mutex *assertion_mutex = NULL;
icculus@11015
    63
#endif
icculus@11015
    64
icculus@3670
    65
static SDL_AssertionHandler assertion_handler = SDL_PromptAssertion;
icculus@3670
    66
static void *assertion_userdata = NULL;
slouken@3647
    67
icculus@3648
    68
#ifdef __GNUC__
icculus@3661
    69
static void
icculus@3661
    70
debug_print(const char *fmt, ...) __attribute__((format (printf, 1, 2)));
icculus@3648
    71
#endif
icculus@3648
    72
icculus@3648
    73
static void
icculus@3648
    74
debug_print(const char *fmt, ...)
slouken@3647
    75
{
slouken@3647
    76
    va_list ap;
slouken@3647
    77
    va_start(ap, fmt);
slouken@6621
    78
    SDL_LogMessageV(SDL_LOG_CATEGORY_ASSERT, SDL_LOG_PRIORITY_WARN, fmt, ap);
slouken@3647
    79
    va_end(ap);
slouken@3647
    80
}
slouken@3647
    81
slouken@3647
    82
slouken@3647
    83
static void SDL_AddAssertionToReport(SDL_assert_data *data)
slouken@3647
    84
{
slouken@3647
    85
    /* (data) is always a static struct defined with the assert macros, so
slouken@3647
    86
       we don't have to worry about copying or allocating them. */
icculus@5541
    87
    data->trigger_count++;
icculus@5541
    88
    if (data->trigger_count == 1) {  /* not yet added? */
slouken@3647
    89
        data->next = triggered_assertions;
slouken@3647
    90
        triggered_assertions = data;
slouken@3647
    91
    }
slouken@3647
    92
}
slouken@3647
    93
icculus@3670
    94
slouken@3647
    95
static void SDL_GenerateAssertionReport(void)
slouken@3647
    96
{
icculus@5541
    97
    const SDL_assert_data *item = triggered_assertions;
icculus@3670
    98
icculus@3670
    99
    /* only do this if the app hasn't assigned an assertion handler. */
icculus@5541
   100
    if ((item != NULL) && (assertion_handler != SDL_PromptAssertion)) {
slouken@3647
   101
        debug_print("\n\nSDL assertion report.\n");
slouken@3647
   102
        debug_print("All SDL assertions between last init/quit:\n\n");
slouken@3647
   103
icculus@5541
   104
        while (item != NULL) {
slouken@3647
   105
            debug_print(
slouken@3647
   106
                "'%s'\n"
slouken@3647
   107
                "    * %s (%s:%d)\n"
slouken@3647
   108
                "    * triggered %u time%s.\n"
slouken@3647
   109
                "    * always ignore: %s.\n",
slouken@3647
   110
                item->condition, item->function, item->filename,
slouken@3647
   111
                item->linenum, item->trigger_count,
slouken@3647
   112
                (item->trigger_count == 1) ? "" : "s",
slouken@3647
   113
                item->always_ignore ? "yes" : "no");
slouken@3647
   114
            item = item->next;
slouken@3647
   115
        }
slouken@3647
   116
        debug_print("\n");
slouken@3647
   117
icculus@3670
   118
        SDL_ResetAssertionReport();
slouken@3647
   119
    }
slouken@3647
   120
}
slouken@3647
   121
slouken@10616
   122
sezeroz@12018
   123
#if defined(__WATCOMC__)
sezeroz@12018
   124
#pragma aux SDL_ExitProcess aborts;
sezeroz@12018
   125
#endif
icculus@12841
   126
static SDL_NORETURN void SDL_ExitProcess(int exitcode)
slouken@3647
   127
{
slouken@5086
   128
#ifdef __WIN32__
slouken@11920
   129
    /* "if you do not know the state of all threads in your process, it is
slouken@11920
   130
       better to call TerminateProcess than ExitProcess"
slouken@11920
   131
       https://msdn.microsoft.com/en-us/library/windows/desktop/ms682658(v=vs.85).aspx */
slouken@11920
   132
    TerminateProcess(GetCurrentProcess(), exitcode);
icculus@12841
   133
    /* MingW doesn't have TerminateProcess marked as noreturn, so add an
icculus@12841
   134
       ExitProcess here that will never be reached but make MingW happy. */
icculus@12841
   135
    ExitProcess(exitcode);
icculus@11017
   136
#elif defined(__EMSCRIPTEN__)
icculus@11017
   137
    emscripten_cancel_main_loop();  /* this should "kill" the app. */
icculus@11017
   138
    emscripten_force_exit(exitcode);  /* this should "kill" the app. */
icculus@11017
   139
    exit(exitcode);
icculus@12849
   140
#elif defined(__HAIKU__)  /* Haiku has _Exit, but it's not marked noreturn. */
icculus@12849
   141
    _exit(exitcode);
icculus@12849
   142
#elif defined(HAVE__EXIT) /* Upper case _Exit() */
slouken@12714
   143
    _Exit(exitcode);
slouken@12714
   144
#else
icculus@6305
   145
    _exit(exitcode);
slouken@3647
   146
#endif
slouken@3647
   147
}
icculus@3661
   148
slouken@10616
   149
sezeroz@12018
   150
#if defined(__WATCOMC__)
sezeroz@12018
   151
#pragma aux SDL_AbortAssertion aborts;
sezeroz@12018
   152
#endif
icculus@12849
   153
static SDL_NORETURN void SDL_AbortAssertion(void)
icculus@3661
   154
{
icculus@3661
   155
    SDL_Quit();
icculus@3661
   156
    SDL_ExitProcess(42);
icculus@3661
   157
}
icculus@3661
   158
slouken@3647
   159
slouken@11272
   160
static SDL_assert_state SDLCALL
icculus@3670
   161
SDL_PromptAssertion(const SDL_assert_data *data, void *userdata)
slouken@3647
   162
{
icculus@6759
   163
#ifdef __WIN32__
icculus@6759
   164
    #define ENDLINE "\r\n"
icculus@6759
   165
#else
icculus@6759
   166
    #define ENDLINE "\n"
icculus@6759
   167
#endif
icculus@6759
   168
slouken@3647
   169
    const char *envr;
slouken@3657
   170
    SDL_assert_state state = SDL_ASSERTION_ABORT;
slouken@3685
   171
    SDL_Window *window;
slouken@6621
   172
    SDL_MessageBoxData messagebox;
slouken@6621
   173
    SDL_MessageBoxButtonData buttons[] = {
slouken@6621
   174
        {   0,  SDL_ASSERTION_RETRY,            "Retry" },
slouken@6621
   175
        {   0,  SDL_ASSERTION_BREAK,            "Break" },
slouken@6621
   176
        {   0,  SDL_ASSERTION_ABORT,            "Abort" },
slouken@6621
   177
        {   SDL_MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT,
slouken@6621
   178
                SDL_ASSERTION_IGNORE,           "Ignore" },
slouken@6621
   179
        {   SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT,
slouken@6621
   180
                SDL_ASSERTION_ALWAYS_IGNORE,    "Always Ignore" }
slouken@6621
   181
    };
slouken@6621
   182
    char *message;
slouken@6621
   183
    int selected;
slouken@3647
   184
icculus@3670
   185
    (void) userdata;  /* unused in default handler. */
icculus@3670
   186
icculus@12349
   187
    /* !!! FIXME: why is this using SDL_stack_alloc and not just "char message[SDL_MAX_LOG_MESSAGE];" ? */
slouken@6621
   188
    message = SDL_stack_alloc(char, SDL_MAX_LOG_MESSAGE);
slouken@6621
   189
    if (!message) {
slouken@6621
   190
        /* Uh oh, we're in real trouble now... */
slouken@6621
   191
        return SDL_ASSERTION_ABORT;
slouken@6621
   192
    }
slouken@6621
   193
    SDL_snprintf(message, SDL_MAX_LOG_MESSAGE,
icculus@6759
   194
                 "Assertion failure at %s (%s:%d), triggered %u %s:" ENDLINE
icculus@6759
   195
                    "  '%s'",
slouken@6621
   196
                 data->function, data->filename, data->linenum,
slouken@6621
   197
                 data->trigger_count, (data->trigger_count == 1) ? "time" : "times",
slouken@6621
   198
                 data->condition);
slouken@6621
   199
slouken@6621
   200
    debug_print("\n\n%s\n\n", message);
slouken@3647
   201
slouken@3655
   202
    /* let env. variable override, so unit tests won't block in a GUI. */
slouken@3647
   203
    envr = SDL_getenv("SDL_ASSERT");
slouken@3647
   204
    if (envr != NULL) {
slouken@6621
   205
        SDL_stack_free(message);
slouken@6621
   206
slouken@3647
   207
        if (SDL_strcmp(envr, "abort") == 0) {
slouken@3647
   208
            return SDL_ASSERTION_ABORT;
slouken@3647
   209
        } else if (SDL_strcmp(envr, "break") == 0) {
slouken@3647
   210
            return SDL_ASSERTION_BREAK;
slouken@3647
   211
        } else if (SDL_strcmp(envr, "retry") == 0) {
slouken@3647
   212
            return SDL_ASSERTION_RETRY;
slouken@3647
   213
        } else if (SDL_strcmp(envr, "ignore") == 0) {
slouken@3647
   214
            return SDL_ASSERTION_IGNORE;
slouken@3647
   215
        } else if (SDL_strcmp(envr, "always_ignore") == 0) {
slouken@3647
   216
            return SDL_ASSERTION_ALWAYS_IGNORE;
slouken@3647
   217
        } else {
slouken@3647
   218
            return SDL_ASSERTION_ABORT;  /* oh well. */
slouken@3647
   219
        }
slouken@3647
   220
    }
slouken@3647
   221
slouken@3657
   222
    /* Leave fullscreen mode, if possible (scary!) */
slouken@3657
   223
    window = SDL_GetFocusWindow();
slouken@3657
   224
    if (window) {
slouken@3657
   225
        if (SDL_GetWindowFlags(window) & SDL_WINDOW_FULLSCREEN) {
slouken@3657
   226
            SDL_MinimizeWindow(window);
slouken@3657
   227
        } else {
icculus@3670
   228
            /* !!! FIXME: ungrab the input if we're not fullscreen? */
slouken@3657
   229
            /* No need to mess with the window */
slouken@6621
   230
            window = NULL;
slouken@3657
   231
        }
slouken@3657
   232
    }
slouken@3657
   233
slouken@6621
   234
    /* Show a messagebox if we can, otherwise fall back to stdio */
slouken@6621
   235
    SDL_zero(messagebox);
slouken@6621
   236
    messagebox.flags = SDL_MESSAGEBOX_WARNING;
slouken@6621
   237
    messagebox.window = window;
slouken@6621
   238
    messagebox.title = "Assertion Failed";
slouken@6621
   239
    messagebox.message = message;
slouken@6621
   240
    messagebox.numbuttons = SDL_arraysize(buttons);
slouken@6621
   241
    messagebox.buttons = buttons;
slouken@3647
   242
slouken@6621
   243
    if (SDL_ShowMessageBox(&messagebox, &selected) == 0) {
slouken@6621
   244
        if (selected == -1) {
slouken@3657
   245
            state = SDL_ASSERTION_IGNORE;
slouken@6621
   246
        } else {
slouken@6621
   247
            state = (SDL_assert_state)selected;
slouken@3647
   248
        }
slouken@3647
   249
    }
icculus@11017
   250
slouken@6621
   251
    else
slouken@6621
   252
    {
icculus@11017
   253
#if defined(__EMSCRIPTEN__)
icculus@11017
   254
        /* This is nasty, but we can't block on a custom UI. */
icculus@11017
   255
        for ( ; ; ) {
icculus@11017
   256
            SDL_bool okay = SDL_TRUE;
icculus@11017
   257
            char *buf = (char *) EM_ASM_INT({
icculus@11017
   258
                var str =
charlie@12576
   259
                    UTF8ToString($0) + '\n\n' +
icculus@11017
   260
                    'Abort/Retry/Ignore/AlwaysIgnore? [ariA] :';
icculus@11017
   261
                var reply = window.prompt(str, "i");
icculus@11017
   262
                if (reply === null) {
icculus@11017
   263
                    reply = "i";
icculus@11017
   264
                }
icculus@11017
   265
                return allocate(intArrayFromString(reply), 'i8', ALLOC_NORMAL);
icculus@11017
   266
            }, message);
icculus@11017
   267
icculus@11017
   268
            if (SDL_strcmp(buf, "a") == 0) {
icculus@11017
   269
                state = SDL_ASSERTION_ABORT;
icculus@11017
   270
            /* (currently) no break functionality on Emscripten
icculus@11017
   271
            } else if (SDL_strcmp(buf, "b") == 0) {
icculus@11017
   272
                state = SDL_ASSERTION_BREAK; */
icculus@11017
   273
            } else if (SDL_strcmp(buf, "r") == 0) {
icculus@11017
   274
                state = SDL_ASSERTION_RETRY;
icculus@11017
   275
            } else if (SDL_strcmp(buf, "i") == 0) {
icculus@11017
   276
                state = SDL_ASSERTION_IGNORE;
icculus@11017
   277
            } else if (SDL_strcmp(buf, "A") == 0) {
icculus@11017
   278
                state = SDL_ASSERTION_ALWAYS_IGNORE;
icculus@11017
   279
            } else {
icculus@11017
   280
                okay = SDL_FALSE;
icculus@11017
   281
            }
icculus@11017
   282
            free(buf);
icculus@11017
   283
icculus@11017
   284
            if (okay) {
icculus@11017
   285
                break;
icculus@11017
   286
            }
icculus@11017
   287
        }
icculus@11017
   288
#elif defined(HAVE_STDIO_H)
slouken@6621
   289
        /* this is a little hacky. */
slouken@6621
   290
        for ( ; ; ) {
slouken@6621
   291
            char buf[32];
slouken@6621
   292
            fprintf(stderr, "Abort/Break/Retry/Ignore/AlwaysIgnore? [abriA] : ");
slouken@6621
   293
            fflush(stderr);
slouken@6621
   294
            if (fgets(buf, sizeof (buf), stdin) == NULL) {
slouken@6621
   295
                break;
slouken@6621
   296
            }
slouken@6621
   297
slouken@11626
   298
            if (SDL_strncmp(buf, "a", 1) == 0) {
slouken@6621
   299
                state = SDL_ASSERTION_ABORT;
slouken@6621
   300
                break;
slouken@11626
   301
            } else if (SDL_strncmp(buf, "b", 1) == 0) {
slouken@6621
   302
                state = SDL_ASSERTION_BREAK;
slouken@6621
   303
                break;
slouken@11626
   304
            } else if (SDL_strncmp(buf, "r", 1) == 0) {
slouken@6621
   305
                state = SDL_ASSERTION_RETRY;
slouken@6621
   306
                break;
slouken@11626
   307
            } else if (SDL_strncmp(buf, "i", 1) == 0) {
slouken@6621
   308
                state = SDL_ASSERTION_IGNORE;
slouken@6621
   309
                break;
slouken@11626
   310
            } else if (SDL_strncmp(buf, "A", 1) == 0) {
slouken@6621
   311
                state = SDL_ASSERTION_ALWAYS_IGNORE;
slouken@6621
   312
                break;
slouken@6621
   313
            }
slouken@6621
   314
        }
icculus@11017
   315
#endif /* HAVE_STDIO_H */
slouken@6621
   316
    }
slouken@3647
   317
slouken@3657
   318
    /* Re-enter fullscreen mode */
slouken@3657
   319
    if (window) {
slouken@3657
   320
        SDL_RestoreWindow(window);
slouken@3657
   321
    }
slouken@3657
   322
slouken@6621
   323
    SDL_stack_free(message);
slouken@6621
   324
slouken@3657
   325
    return state;
slouken@3647
   326
}
slouken@3647
   327
slouken@3647
   328
slouken@3647
   329
SDL_assert_state
slouken@3655
   330
SDL_ReportAssertion(SDL_assert_data *data, const char *func, const char *file,
slouken@3655
   331
                    int line)
slouken@3647
   332
{
icculus@11015
   333
    SDL_assert_state state = SDL_ASSERTION_IGNORE;
icculus@3661
   334
    static int assertion_running = 0;
icculus@11015
   335
icculus@11015
   336
#ifndef SDL_THREADS_DISABLED
icculus@3662
   337
    static SDL_SpinLock spinlock = 0;
icculus@3662
   338
    SDL_AtomicLock(&spinlock);
icculus@3662
   339
    if (assertion_mutex == NULL) { /* never called SDL_Init()? */
icculus@3662
   340
        assertion_mutex = SDL_CreateMutex();
icculus@3662
   341
        if (assertion_mutex == NULL) {
icculus@3662
   342
            SDL_AtomicUnlock(&spinlock);
icculus@3662
   343
            return SDL_ASSERTION_IGNORE;   /* oh well, I guess. */
icculus@3662
   344
        }
icculus@3662
   345
    }
icculus@3662
   346
    SDL_AtomicUnlock(&spinlock);
icculus@3662
   347
slouken@3647
   348
    if (SDL_LockMutex(assertion_mutex) < 0) {
slouken@3647
   349
        return SDL_ASSERTION_IGNORE;   /* oh well, I guess. */
slouken@3647
   350
    }
icculus@11015
   351
#endif
slouken@3647
   352
slouken@3647
   353
    /* doing this because Visual C is upset over assigning in the macro. */
slouken@3647
   354
    if (data->trigger_count == 0) {
slouken@3647
   355
        data->function = func;
slouken@3655
   356
        data->filename = file;
slouken@3655
   357
        data->linenum = line;
slouken@3647
   358
    }
slouken@3647
   359
slouken@3647
   360
    SDL_AddAssertionToReport(data);
slouken@3647
   361
icculus@3661
   362
    assertion_running++;
icculus@3661
   363
    if (assertion_running > 1) {   /* assert during assert! Abort. */
icculus@3661
   364
        if (assertion_running == 2) {
icculus@3661
   365
            SDL_AbortAssertion();
icculus@3661
   366
        } else if (assertion_running == 3) {  /* Abort asserted! */
icculus@3661
   367
            SDL_ExitProcess(42);
icculus@3661
   368
        } else {
icculus@3661
   369
            while (1) { /* do nothing but spin; what else can you do?! */ }
icculus@3661
   370
        }
slouken@3647
   371
    }
slouken@3647
   372
icculus@3661
   373
    if (!data->always_ignore) {
icculus@3670
   374
        state = assertion_handler(data, assertion_userdata);
icculus@3661
   375
    }
slouken@3647
   376
slouken@3647
   377
    switch (state)
slouken@3647
   378
    {
slouken@3647
   379
        case SDL_ASSERTION_ABORT:
slouken@3647
   380
            SDL_AbortAssertion();
slouken@3647
   381
            return SDL_ASSERTION_IGNORE;  /* shouldn't return, but oh well. */
slouken@3647
   382
slouken@3647
   383
        case SDL_ASSERTION_ALWAYS_IGNORE:
slouken@3647
   384
            state = SDL_ASSERTION_IGNORE;
slouken@3647
   385
            data->always_ignore = 1;
slouken@3647
   386
            break;
slouken@3647
   387
slouken@3647
   388
        case SDL_ASSERTION_IGNORE:
slouken@3647
   389
        case SDL_ASSERTION_RETRY:
slouken@3647
   390
        case SDL_ASSERTION_BREAK:
slouken@3647
   391
            break;  /* macro handles these. */
slouken@3647
   392
    }
slouken@3647
   393
icculus@3661
   394
    assertion_running--;
icculus@11015
   395
icculus@11015
   396
#ifndef SDL_THREADS_DISABLED
slouken@3647
   397
    SDL_UnlockMutex(assertion_mutex);
icculus@11015
   398
#endif
slouken@3647
   399
slouken@3647
   400
    return state;
slouken@3647
   401
}
slouken@3647
   402
slouken@3647
   403
slouken@3647
   404
void SDL_AssertionsQuit(void)
slouken@3647
   405
{
slouken@3647
   406
    SDL_GenerateAssertionReport();
icculus@11015
   407
#ifndef SDL_THREADS_DISABLED
icculus@3664
   408
    if (assertion_mutex != NULL) {
icculus@3664
   409
        SDL_DestroyMutex(assertion_mutex);
icculus@3664
   410
        assertion_mutex = NULL;
icculus@3664
   411
    }
icculus@11015
   412
#endif
icculus@3670
   413
}
icculus@3670
   414
icculus@3670
   415
void SDL_SetAssertionHandler(SDL_AssertionHandler handler, void *userdata)
icculus@3670
   416
{
icculus@3670
   417
    if (handler != NULL) {
icculus@3670
   418
        assertion_handler = handler;
icculus@3670
   419
        assertion_userdata = userdata;
icculus@3670
   420
    } else {
icculus@3670
   421
        assertion_handler = SDL_PromptAssertion;
icculus@3670
   422
        assertion_userdata = NULL;
icculus@3670
   423
    }
icculus@3670
   424
}
icculus@3670
   425
icculus@3670
   426
const SDL_assert_data *SDL_GetAssertionReport(void)
icculus@3670
   427
{
icculus@3670
   428
    return triggered_assertions;
icculus@3670
   429
}
icculus@3670
   430
icculus@3670
   431
void SDL_ResetAssertionReport(void)
icculus@3670
   432
{
icculus@3670
   433
    SDL_assert_data *next = NULL;
icculus@5541
   434
    SDL_assert_data *item;
icculus@5541
   435
    for (item = triggered_assertions; item != NULL; item = next) {
icculus@3670
   436
        next = (SDL_assert_data *) item->next;
icculus@3670
   437
        item->always_ignore = SDL_FALSE;
icculus@3670
   438
        item->trigger_count = 0;
icculus@3670
   439
        item->next = NULL;
icculus@3670
   440
    }
icculus@3670
   441
icculus@5541
   442
    triggered_assertions = NULL;
slouken@3647
   443
}
slouken@3647
   444
icculus@8167
   445
SDL_AssertionHandler SDL_GetDefaultAssertionHandler(void)
icculus@8167
   446
{
icculus@8167
   447
    return SDL_PromptAssertion;
icculus@8167
   448
}
icculus@8167
   449
icculus@8167
   450
SDL_AssertionHandler SDL_GetAssertionHandler(void **userdata)
icculus@8167
   451
{
icculus@8167
   452
    if (userdata != NULL) {
icculus@8167
   453
        *userdata = assertion_userdata;
icculus@8167
   454
    }
icculus@8167
   455
    return assertion_handler;
icculus@8167
   456
}
icculus@8167
   457
slouken@3647
   458
/* vi: set ts=4 sw=4 expandtab: */