Use SDLCALL for callbacks in public APIs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264
diff --git a/include/SDL_config_os2.h b/include/SDL_config_os2.h
index 130dd32..1583245 100644
--- a/include/SDL_config_os2.h
+++ b/include/SDL_config_os2.h
@@ -102,8 +102,11 @@
#define HAVE_GETENV 1
#define HAVE_SETENV 1
#define HAVE_PUTENV 1
+/* OpenWatcom requires specific calling conventions for qsort and bsearch */
+#ifndef __WATCOMC__
#define HAVE_QSORT 1
#define HAVE_BSEARCH 1
+#endif
#define HAVE_ABS 1
#define HAVE_BCOPY 1
#define HAVE_MEMSET 1
diff --git a/include/SDL_joystick.h b/include/SDL_joystick.h
index 9825b5b..f10689f 100644
--- a/include/SDL_joystick.h
+++ b/include/SDL_joystick.h
@@ -373,12 +373,12 @@ typedef struct SDL_VirtualJoystickDesc
const char *name; /**< the name of the joystick */
void *userdata; /**< User data pointer passed to callbacks */
- void (*Update)(void *userdata); /**< Called when the joystick state should be updated */
- void (*SetPlayerIndex)(void *userdata, int player_index); /**< Called when the player index is set */
- int (*Rumble)(void *userdata, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble); /**< Implements SDL_JoystickRumble() */
- int (*RumbleTriggers)(void *userdata, Uint16 left_rumble, Uint16 right_rumble); /**< Implements SDL_JoystickRumbleTriggers() */
- int (*SetLED)(void *userdata, Uint8 red, Uint8 green, Uint8 blue); /**< Implements SDL_JoystickSetLED() */
- int (*SendEffect)(void *userdata, const void *data, int size); /**< Implements SDL_JoystickSendEffect() */
+ void (SDLCALL *Update)(void *userdata); /**< Called when the joystick state should be updated */
+ void (SDLCALL *SetPlayerIndex)(void *userdata, int player_index); /**< Called when the player index is set */
+ int (SDLCALL *Rumble)(void *userdata, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble); /**< Implements SDL_JoystickRumble() */
+ int (SDLCALL *RumbleTriggers)(void *userdata, Uint16 left_rumble, Uint16 right_rumble); /**< Implements SDL_JoystickRumbleTriggers() */
+ int (SDLCALL *SetLED)(void *userdata, Uint8 red, Uint8 green, Uint8 blue); /**< Implements SDL_JoystickSetLED() */
+ int (SDLCALL *SendEffect)(void *userdata, const void *data, int size); /**< Implements SDL_JoystickSendEffect() */
} SDL_VirtualJoystickDesc;
diff --git a/include/SDL_stdinc.h b/include/SDL_stdinc.h
index 3196172..6ee15f1 100644
--- a/include/SDL_stdinc.h
+++ b/include/SDL_stdinc.h
@@ -468,8 +468,8 @@ extern DECLSPEC int SDLCALL SDL_GetNumAllocations(void);
extern DECLSPEC char *SDLCALL SDL_getenv(const char *name);
extern DECLSPEC int SDLCALL SDL_setenv(const char *name, const char *value, int overwrite);
-extern DECLSPEC void SDLCALL SDL_qsort(void *base, size_t nmemb, size_t size, int (*compare) (const void *, const void *));
-extern DECLSPEC void * SDLCALL SDL_bsearch(const void *key, const void *base, size_t nmemb, size_t size, int (*compare) (const void *, const void *));
+extern DECLSPEC void SDLCALL SDL_qsort(void *base, size_t nmemb, size_t size, int (SDLCALL *compare) (const void *, const void *));
+extern DECLSPEC void * SDLCALL SDL_bsearch(const void *key, const void *base, size_t nmemb, size_t size, int (SDLCALL *compare) (const void *, const void *));
extern DECLSPEC int SDLCALL SDL_abs(int x);
diff --git a/include/SDL_system.h b/include/SDL_system.h
index 41563ad..c540e47 100644
--- a/include/SDL_system.h
+++ b/include/SDL_system.h
@@ -195,7 +195,7 @@ extern DECLSPEC int SDLCALL SDL_LinuxSetThreadPriorityAndPolicy(Sint64 threadID,
*
* \sa SDL_iPhoneSetEventPump
*/
-extern DECLSPEC int SDLCALL SDL_iPhoneSetAnimationCallback(SDL_Window * window, int interval, void (*callback)(void*), void *callbackParam);
+extern DECLSPEC int SDLCALL SDL_iPhoneSetAnimationCallback(SDL_Window * window, int interval, void (SDLCALL *callback)(void*), void *callbackParam);
#define SDL_iOSSetEventPump(enabled) SDL_iPhoneSetEventPump(enabled)
diff --git a/src/audio/wasapi/SDL_wasapi_win32.c b/src/audio/wasapi/SDL_wasapi_win32.c
index 8e5c7e2..137f370 100644
--- a/src/audio/wasapi/SDL_wasapi_win32.c
+++ b/src/audio/wasapi/SDL_wasapi_win32.c
@@ -362,7 +362,7 @@ typedef struct
WAVEFORMATEXTENSIBLE fmt;
} EndpointItem;
-static int sort_endpoints(const void *_a, const void *_b)
+static int SDLCALL sort_endpoints(const void *_a, const void *_b)
{
LPWSTR a = ((const EndpointItem *) _a)->devid;
LPWSTR b = ((const EndpointItem *) _b)->devid;
diff --git a/src/joystick/hidapi/SDL_hidapi_rumble.c b/src/joystick/hidapi/SDL_hidapi_rumble.c
index bf37627..9cbdb95 100644
--- a/src/joystick/hidapi/SDL_hidapi_rumble.c
+++ b/src/joystick/hidapi/SDL_hidapi_rumble.c
@@ -53,7 +53,7 @@ typedef struct SDL_HIDAPI_RumbleContext
static SDL_HIDAPI_RumbleContext rumble_context;
-static int SDL_HIDAPI_RumbleThread(void *data)
+static int SDLCALL SDL_HIDAPI_RumbleThread(void *data)
{
SDL_HIDAPI_RumbleContext *ctx = (SDL_HIDAPI_RumbleContext *)data;
diff --git a/src/joystick/windows/SDL_dinputjoystick.c b/src/joystick/windows/SDL_dinputjoystick.c
index 353f66e..7b4c23e 100644
--- a/src/joystick/windows/SDL_dinputjoystick.c
+++ b/src/joystick/windows/SDL_dinputjoystick.c
@@ -683,7 +683,7 @@ EnumDevObjectsCallback(LPCDIDEVICEOBJECTINSTANCE pDeviceObject, LPVOID pContext)
/* Sort using the data offset into the DInput struct.
* This gives a reasonable ordering for the inputs.
*/
-static int
+static int SDLCALL
SortDevFunc(const void *a, const void *b)
{
const input_t *inputA = (const input_t*)a;
diff --git a/src/joystick/windows/SDL_rawinputjoystick.c b/src/joystick/windows/SDL_rawinputjoystick.c
index e28fea0..ca9bd7d 100644
--- a/src/joystick/windows/SDL_rawinputjoystick.c
+++ b/src/joystick/windows/SDL_rawinputjoystick.c
@@ -1069,7 +1069,7 @@ RAWINPUT_JoystickGetDeviceInstanceID(int device_index)
return RAWINPUT_GetDeviceByIndex(device_index)->joystick_id;
}
-static int
+static int SDLCALL
RAWINPUT_SortValueCaps(const void *A, const void *B)
{
HIDP_VALUE_CAPS *capsA = (HIDP_VALUE_CAPS *)A;
diff --git a/src/joystick/windows/SDL_windowsjoystick.c b/src/joystick/windows/SDL_windowsjoystick.c
index a9b7137..463afd7 100644
--- a/src/joystick/windows/SDL_windowsjoystick.c
+++ b/src/joystick/windows/SDL_windowsjoystick.c
@@ -330,7 +330,7 @@ SDL_WaitForDeviceNotification(SDL_DeviceNotificationData *data, SDL_mutex *mutex
static SDL_DeviceNotificationData s_notification_data;
/* Function/thread to scan the system for joysticks. */
-static int
+static int SDLCALL
SDL_JoystickThread(void *_data)
{
#if SDL_JOYSTICK_XINPUT
diff --git a/src/stdlib/SDL_malloc.c b/src/stdlib/SDL_malloc.c
index 7dc5a42..0a51ddd 100644
--- a/src/stdlib/SDL_malloc.c
+++ b/src/stdlib/SDL_malloc.c
@@ -733,7 +733,7 @@ extern "C"
maximum supported value of n differs across systems, but is in all
cases less than the maximum representable value of a size_t.
*/
- void *dlmalloc(size_t);
+ void * SDLCALL dlmalloc(size_t);
/*
free(void* p)
@@ -742,14 +742,14 @@ extern "C"
It has no effect if p is null. If p was not malloced or already
freed, free(p) will by default cause the current program to abort.
*/
- void dlfree(void *);
+ void SDLCALL dlfree(void *);
/*
calloc(size_t n_elements, size_t element_size);
Returns a pointer to n_elements * element_size bytes, with all locations
set to zero.
*/
- void *dlcalloc(size_t, size_t);
+ void * SDLCALL dlcalloc(size_t, size_t);
/*
realloc(void* p, size_t n)
@@ -774,7 +774,7 @@ extern "C"
to be used as an argument to realloc is not supported.
*/
- void *dlrealloc(void *, size_t);
+ void * SDLCALL dlrealloc(void *, size_t);
/*
memalign(size_t alignment, size_t n);
diff --git a/src/test/SDL_test_harness.c b/src/test/SDL_test_harness.c
index 8f10f3e..3a1f432 100644
--- a/src/test/SDL_test_harness.c
+++ b/src/test/SDL_test_harness.c
@@ -169,7 +169,7 @@ SDLTest_GenerateExecKey(const char *runSeed, const char *suiteName, const char *
* \return Timer id or -1 on failure.
*/
static SDL_TimerID
-SDLTest_SetTestTimeout(int timeout, void (*callback)(void))
+SDLTest_SetTestTimeout(int timeout, void (SDLCALL *callback)(void))
{
Uint32 timeoutInMilliseconds;
SDL_TimerID timerID;
@@ -209,7 +209,7 @@ SDLTest_SetTestTimeout(int timeout, void (*callback)(void))
#if defined(__WATCOMC__)
#pragma aux SDLTest_BailOut aborts;
#endif
-static SDL_NORETURN void
+static SDL_NORETURN void SDLCALL
SDLTest_BailOut(void)
{
SDLTest_LogError("TestCaseTimeout timer expired. Aborting test run.");
diff --git a/src/video/SDL_video.c b/src/video/SDL_video.c
index 78ae8f6..d3ec5d0 100644
--- a/src/video/SDL_video.c
+++ b/src/video/SDL_video.c
@@ -341,7 +341,7 @@ SDL_DestroyWindowTexture(SDL_VideoDevice *unused, SDL_Window * window)
SDL_free(data);
}
-static int
+static int SDLCALL
cmpmodes(const void *A, const void *B)
{
const SDL_DisplayMode *a = (const SDL_DisplayMode *) A;
diff --git a/src/video/windows/SDL_windowsevents.c b/src/video/windows/SDL_windowsevents.c
index ebd0dd1..cf6a7c5 100644
--- a/src/video/windows/SDL_windowsevents.c
+++ b/src/video/windows/SDL_windowsevents.c
@@ -29,6 +29,7 @@
#include "SDL_timer.h"
#include "SDL_vkeys.h"
#include "SDL_hints.h"
+#include "SDL_main.h"
#include "../../events/SDL_events_c.h"
#include "../../events/SDL_touch_c.h"
#include "../../events/scancodes_windows.h"
diff --git a/test/testgamecontroller.c b/test/testgamecontroller.c
index 6ccf3b6..011e5cd 100644
--- a/test/testgamecontroller.c
+++ b/test/testgamecontroller.c
@@ -312,24 +312,24 @@ static SDL_bool ShowingFront()
return showing_front;
}
-static void VirtualControllerSetPlayerIndex(void *userdata, int player_index)
+static void SDLCALL VirtualControllerSetPlayerIndex(void *userdata, int player_index)
{
SDL_Log("Virtual Controller: player index set to %d\n", player_index);
}
-static int VirtualControllerRumble(void *userdata, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble)
+static int SDLCALL VirtualControllerRumble(void *userdata, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble)
{
SDL_Log("Virtual Controller: rumble set to %d/%d\n", low_frequency_rumble, high_frequency_rumble);
return 0;
}
-static int VirtualControllerRumbleTriggers(void *userdata, Uint16 left_rumble, Uint16 right_rumble)
+static int SDLCALL VirtualControllerRumbleTriggers(void *userdata, Uint16 left_rumble, Uint16 right_rumble)
{
SDL_Log("Virtual Controller: trigger rumble set to %d/%d\n", left_rumble, right_rumble);
return 0;
}
-static int VirtualControllerSetLED(void *userdata, Uint8 red, Uint8 green, Uint8 blue)
+static int SDLCALL VirtualControllerSetLED(void *userdata, Uint8 red, Uint8 green, Uint8 blue)
{
SDL_Log("Virtual Controller: LED set to RGB %d,%d,%d\n", red, green, blue);
return 0;
diff --git a/test/testqsort.c b/test/testqsort.c
index d28daeb..29ea056 100644
--- a/test/testqsort.c
+++ b/test/testqsort.c
@@ -12,7 +12,7 @@
#include "SDL_test.h"
-static int
+static int SDLCALL
num_compare(const void *_a, const void *_b)
{
const int a = *((const int *) _a);