include/SDL_gesture.h
author Sam Lantinga <slouken@libsdl.org>
Thu, 16 May 2013 00:43:22 -0700
changeset 7180 3733e68edbc3
parent 6885 700f1b25f77f
child 7191 75360622e65f
permissions -rw-r--r--
Fixed bug 1846 - _allmul implementation in SDL_stdlib.c doesn't clean up the stack

Colin Barrett

I see this manifest itself (VS2012 x86) as:

"Run-Time Check Failure #0 - The value of ESP was not properly saved across a function call. This is usually a result of calling a function declared with one calling convention with a function pointer declared with a different calling convention."

in the first call to SDL_GetTicks in my application. The disassembly at the problem line is:

hires_now.QuadPart *= 1000;
00AD0792 push 0
00AD0794 push 3E8h
00AD0799 mov eax,dword ptr [ebp-10h]
00AD079C push eax
00AD079D mov ecx,dword ptr [hires_now]
00AD07A0 push ecx
00AD07A1 call _allmul (0AE7D40h)
00AD07A6 mov dword ptr [hires_now],eax
00AD07A9 mov dword ptr [ebp-10h],edx

Apparently _allmul should be popping the stack but isn't (other similar functions in SDL_stdlib.c - _alldiv and whatnot - DO pop the stack).

A 'ret 10h' at the end of _allmul appears to do the trick
jim@4659
     1
/*
slouken@5535
     2
  Simple DirectMedia Layer
slouken@6885
     3
  Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
jim@4659
     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.
jim@4659
     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:
jim@4659
    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.
jim@4659
    20
*/
jim@4659
    21
jim@4659
    22
/**
jim@4659
    23
 *  \file SDL_gesture.h
jim@4659
    24
 *  
jim@4659
    25
 *  Include file for SDL gesture event handling.
jim@4659
    26
 */
jim@4659
    27
jim@4659
    28
#ifndef _SDL_gesture_h
jim@4659
    29
#define _SDL_gesture_h
jim@4659
    30
jim@4659
    31
#include "SDL_stdinc.h"
jim@4659
    32
#include "SDL_error.h"
jim@4659
    33
#include "SDL_video.h"
jim@4659
    34
jimtla@4678
    35
#include "SDL_touch.h"
jimtla@4678
    36
jimtla@4678
    37
jim@4659
    38
#include "begin_code.h"
jim@4659
    39
/* Set up for C function definitions, even when using C++ */
jim@4659
    40
#ifdef __cplusplus
jim@4659
    41
/* *INDENT-OFF* */
jim@4659
    42
extern "C" {
jim@4659
    43
/* *INDENT-ON* */
jim@4659
    44
#endif
jim@4659
    45
slouken@4679
    46
typedef Sint64 SDL_GestureID;
jim@4659
    47
jim@4659
    48
/* Function prototypes */
jim@4659
    49
jim@4659
    50
/**
jim@4659
    51
 *  \brief Begin Recording a gesture on the specified touch, or all touches (-1)
jim@4659
    52
 *
jim@4659
    53
 *
jim@4659
    54
 */
slouken@4679
    55
extern DECLSPEC int SDLCALL SDL_RecordGesture(SDL_TouchID touchId);
jim@4659
    56
jim@4659
    57
jim@4659
    58
/**
jim@4659
    59
 *  \brief Save all currently loaded Dollar Gesture templates
jim@4659
    60
 *
jim@4659
    61
 *
jim@4659
    62
 */
slouken@4679
    63
extern DECLSPEC int SDLCALL SDL_SaveAllDollarTemplates(SDL_RWops *src);
jim@4659
    64
jim@4659
    65
/**
jim@4659
    66
 *  \brief Save a currently loaded Dollar Gesture template
jim@4659
    67
 *
jim@4659
    68
 *
jim@4659
    69
 */
slouken@4679
    70
extern DECLSPEC int SDLCALL SDL_SaveDollarTemplate(SDL_GestureID gestureId,SDL_RWops *src);
jim@4659
    71
jim@4659
    72
jim@4659
    73
/**
jim@4659
    74
 *  \brief Load Dollar Gesture templates from a file
jim@4659
    75
 *
jim@4659
    76
 *
jim@4659
    77
 */
slouken@4679
    78
extern DECLSPEC int SDLCALL SDL_LoadDollarTemplates(SDL_TouchID touchId, SDL_RWops *src);
jim@4659
    79
jim@4659
    80
jim@4659
    81
/* Ends C function definitions when using C++ */
jim@4659
    82
#ifdef __cplusplus
jim@4659
    83
/* *INDENT-OFF* */
jim@4659
    84
}
jim@4659
    85
/* *INDENT-ON* */
jim@4659
    86
#endif
jim@4659
    87
#include "close_code.h"
jim@4659
    88
jim@4659
    89
#endif /* _SDL_gesture_h */
jim@4659
    90
jim@4659
    91
/* vi: set ts=4 sw=4 expandtab: */