Commit b4ba6518 authored by Sam Lantinga's avatar Sam Lantinga

Fixed bug #215

The current SVN trunk is missing the SDLCALL specifier at numerous locations.

It has to be added for all (possibly user provided) callbacks.

I stumbled over this while creating a makefile for the OpenWatcom compiler for
Win32.

--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%401728
parent cab8a203
...@@ -168,6 +168,8 @@ extern DECLSPEC void SDLCALL SDL_free(void *mem); ...@@ -168,6 +168,8 @@ extern DECLSPEC void SDLCALL SDL_free(void *mem);
# elif defined(_MSC_VER) # elif defined(_MSC_VER)
# include <malloc.h> # include <malloc.h>
# define alloca _alloca # define alloca _alloca
# elif defined(__WATCOMC__)
# include <malloc.h>
# elif defined(__AIX__) # elif defined(__AIX__)
#pragma alloca #pragma alloca
# else # else
......
...@@ -120,13 +120,13 @@ static int audio_configured = 0; ...@@ -120,13 +120,13 @@ static int audio_configured = 0;
#endif #endif
/* The general mixing thread function */ /* The general mixing thread function */
int SDL_RunAudio(void *audiop) int SDLCALL SDL_RunAudio(void *audiop)
{ {
SDL_AudioDevice *audio = (SDL_AudioDevice *)audiop; SDL_AudioDevice *audio = (SDL_AudioDevice *)audiop;
Uint8 *stream; Uint8 *stream;
int stream_len; int stream_len;
void *udata; void *udata;
void (*fill)(void *userdata,Uint8 *stream, int len); void (SDLCALL *fill)(void *userdata,Uint8 *stream, int len);
int silence; int silence;
#if SDL_AUDIO_DRIVER_AHI #if SDL_AUDIO_DRIVER_AHI
int started = 0; int started = 0;
......
...@@ -31,4 +31,4 @@ extern Uint16 SDL_NextAudioFormat(void); ...@@ -31,4 +31,4 @@ extern Uint16 SDL_NextAudioFormat(void);
extern void SDL_CalculateAudioSpec(SDL_AudioSpec *spec); extern void SDL_CalculateAudioSpec(SDL_AudioSpec *spec);
/* The actual mixing thread function */ /* The actual mixing thread function */
extern int SDL_RunAudio(void *audiop); extern int SDLCALL SDL_RunAudio(void *audiop);
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
/* Effectively mix right and left channels into a single channel */ /* Effectively mix right and left channels into a single channel */
void SDL_ConvertMono(SDL_AudioCVT *cvt, Uint16 format) void SDLCALL SDL_ConvertMono(SDL_AudioCVT *cvt, Uint16 format)
{ {
int i; int i;
Sint32 sample; Sint32 sample;
...@@ -169,7 +169,7 @@ void SDL_ConvertMono(SDL_AudioCVT *cvt, Uint16 format) ...@@ -169,7 +169,7 @@ void SDL_ConvertMono(SDL_AudioCVT *cvt, Uint16 format)
} }
/* Discard top 4 channels */ /* Discard top 4 channels */
void SDL_ConvertStrip(SDL_AudioCVT *cvt, Uint16 format) void SDLCALL SDL_ConvertStrip(SDL_AudioCVT *cvt, Uint16 format)
{ {
int i; int i;
Sint32 lsample, rsample; Sint32 lsample, rsample;
...@@ -285,7 +285,7 @@ void SDL_ConvertStrip(SDL_AudioCVT *cvt, Uint16 format) ...@@ -285,7 +285,7 @@ void SDL_ConvertStrip(SDL_AudioCVT *cvt, Uint16 format)
/* Discard top 2 channels of 6 */ /* Discard top 2 channels of 6 */
void SDL_ConvertStrip_2(SDL_AudioCVT *cvt, Uint16 format) void SDLCALL SDL_ConvertStrip_2(SDL_AudioCVT *cvt, Uint16 format)
{ {
int i; int i;
Sint32 lsample, rsample; Sint32 lsample, rsample;
...@@ -400,7 +400,7 @@ void SDL_ConvertStrip_2(SDL_AudioCVT *cvt, Uint16 format) ...@@ -400,7 +400,7 @@ void SDL_ConvertStrip_2(SDL_AudioCVT *cvt, Uint16 format)
} }
/* Duplicate a mono channel to both stereo channels */ /* Duplicate a mono channel to both stereo channels */
void SDL_ConvertStereo(SDL_AudioCVT *cvt, Uint16 format) void SDLCALL SDL_ConvertStereo(SDL_AudioCVT *cvt, Uint16 format)
{ {
int i; int i;
...@@ -438,7 +438,7 @@ void SDL_ConvertStereo(SDL_AudioCVT *cvt, Uint16 format) ...@@ -438,7 +438,7 @@ void SDL_ConvertStereo(SDL_AudioCVT *cvt, Uint16 format)
/* Duplicate a stereo channel to a pseudo-5.1 stream */ /* Duplicate a stereo channel to a pseudo-5.1 stream */
void SDL_ConvertSurround(SDL_AudioCVT *cvt, Uint16 format) void SDLCALL SDL_ConvertSurround(SDL_AudioCVT *cvt, Uint16 format)
{ {
int i; int i;
...@@ -615,7 +615,7 @@ void SDL_ConvertSurround(SDL_AudioCVT *cvt, Uint16 format) ...@@ -615,7 +615,7 @@ void SDL_ConvertSurround(SDL_AudioCVT *cvt, Uint16 format)
/* Duplicate a stereo channel to a pseudo-4.0 stream */ /* Duplicate a stereo channel to a pseudo-4.0 stream */
void SDL_ConvertSurround_4(SDL_AudioCVT *cvt, Uint16 format) void SDLCALL SDL_ConvertSurround_4(SDL_AudioCVT *cvt, Uint16 format)
{ {
int i; int i;
...@@ -768,7 +768,7 @@ void SDL_ConvertSurround_4(SDL_AudioCVT *cvt, Uint16 format) ...@@ -768,7 +768,7 @@ void SDL_ConvertSurround_4(SDL_AudioCVT *cvt, Uint16 format)
/* Convert 8-bit to 16-bit - LSB */ /* Convert 8-bit to 16-bit - LSB */
void SDL_Convert16LSB(SDL_AudioCVT *cvt, Uint16 format) void SDLCALL SDL_Convert16LSB(SDL_AudioCVT *cvt, Uint16 format)
{ {
int i; int i;
Uint8 *src, *dst; Uint8 *src, *dst;
...@@ -791,7 +791,7 @@ void SDL_Convert16LSB(SDL_AudioCVT *cvt, Uint16 format) ...@@ -791,7 +791,7 @@ void SDL_Convert16LSB(SDL_AudioCVT *cvt, Uint16 format)
} }
} }
/* Convert 8-bit to 16-bit - MSB */ /* Convert 8-bit to 16-bit - MSB */
void SDL_Convert16MSB(SDL_AudioCVT *cvt, Uint16 format) void SDLCALL SDL_Convert16MSB(SDL_AudioCVT *cvt, Uint16 format)
{ {
int i; int i;
Uint8 *src, *dst; Uint8 *src, *dst;
...@@ -815,7 +815,7 @@ void SDL_Convert16MSB(SDL_AudioCVT *cvt, Uint16 format) ...@@ -815,7 +815,7 @@ void SDL_Convert16MSB(SDL_AudioCVT *cvt, Uint16 format)
} }
/* Convert 16-bit to 8-bit */ /* Convert 16-bit to 8-bit */
void SDL_Convert8(SDL_AudioCVT *cvt, Uint16 format) void SDLCALL SDL_Convert8(SDL_AudioCVT *cvt, Uint16 format)
{ {
int i; int i;
Uint8 *src, *dst; Uint8 *src, *dst;
...@@ -841,7 +841,7 @@ void SDL_Convert8(SDL_AudioCVT *cvt, Uint16 format) ...@@ -841,7 +841,7 @@ void SDL_Convert8(SDL_AudioCVT *cvt, Uint16 format)
} }
/* Toggle signed/unsigned */ /* Toggle signed/unsigned */
void SDL_ConvertSign(SDL_AudioCVT *cvt, Uint16 format) void SDLCALL SDL_ConvertSign(SDL_AudioCVT *cvt, Uint16 format)
{ {
int i; int i;
Uint8 *data; Uint8 *data;
...@@ -870,7 +870,7 @@ void SDL_ConvertSign(SDL_AudioCVT *cvt, Uint16 format) ...@@ -870,7 +870,7 @@ void SDL_ConvertSign(SDL_AudioCVT *cvt, Uint16 format)
} }
/* Toggle endianness */ /* Toggle endianness */
void SDL_ConvertEndian(SDL_AudioCVT *cvt, Uint16 format) void SDLCALL SDL_ConvertEndian(SDL_AudioCVT *cvt, Uint16 format)
{ {
int i; int i;
Uint8 *data, tmp; Uint8 *data, tmp;
...@@ -892,7 +892,7 @@ void SDL_ConvertEndian(SDL_AudioCVT *cvt, Uint16 format) ...@@ -892,7 +892,7 @@ void SDL_ConvertEndian(SDL_AudioCVT *cvt, Uint16 format)
} }
/* Convert rate up by multiple of 2 */ /* Convert rate up by multiple of 2 */
void SDL_RateMUL2(SDL_AudioCVT *cvt, Uint16 format) void SDLCALL SDL_RateMUL2(SDL_AudioCVT *cvt, Uint16 format)
{ {
int i; int i;
Uint8 *src, *dst; Uint8 *src, *dst;
...@@ -930,7 +930,7 @@ void SDL_RateMUL2(SDL_AudioCVT *cvt, Uint16 format) ...@@ -930,7 +930,7 @@ void SDL_RateMUL2(SDL_AudioCVT *cvt, Uint16 format)
/* Convert rate up by multiple of 2, for stereo */ /* Convert rate up by multiple of 2, for stereo */
void SDL_RateMUL2_c2(SDL_AudioCVT *cvt, Uint16 format) void SDLCALL SDL_RateMUL2_c2(SDL_AudioCVT *cvt, Uint16 format)
{ {
int i; int i;
Uint8 *src, *dst; Uint8 *src, *dst;
...@@ -973,7 +973,7 @@ void SDL_RateMUL2_c2(SDL_AudioCVT *cvt, Uint16 format) ...@@ -973,7 +973,7 @@ void SDL_RateMUL2_c2(SDL_AudioCVT *cvt, Uint16 format)
} }
/* Convert rate up by multiple of 2, for quad */ /* Convert rate up by multiple of 2, for quad */
void SDL_RateMUL2_c4(SDL_AudioCVT *cvt, Uint16 format) void SDLCALL SDL_RateMUL2_c4(SDL_AudioCVT *cvt, Uint16 format)
{ {
int i; int i;
Uint8 *src, *dst; Uint8 *src, *dst;
...@@ -1029,7 +1029,7 @@ void SDL_RateMUL2_c4(SDL_AudioCVT *cvt, Uint16 format) ...@@ -1029,7 +1029,7 @@ void SDL_RateMUL2_c4(SDL_AudioCVT *cvt, Uint16 format)
/* Convert rate up by multiple of 2, for 5.1 */ /* Convert rate up by multiple of 2, for 5.1 */
void SDL_RateMUL2_c6(SDL_AudioCVT *cvt, Uint16 format) void SDLCALL SDL_RateMUL2_c6(SDL_AudioCVT *cvt, Uint16 format)
{ {
int i; int i;
Uint8 *src, *dst; Uint8 *src, *dst;
...@@ -1096,7 +1096,7 @@ void SDL_RateMUL2_c6(SDL_AudioCVT *cvt, Uint16 format) ...@@ -1096,7 +1096,7 @@ void SDL_RateMUL2_c6(SDL_AudioCVT *cvt, Uint16 format)
} }
/* Convert rate down by multiple of 2 */ /* Convert rate down by multiple of 2 */
void SDL_RateDIV2(SDL_AudioCVT *cvt, Uint16 format) void SDLCALL SDL_RateDIV2(SDL_AudioCVT *cvt, Uint16 format)
{ {
int i; int i;
Uint8 *src, *dst; Uint8 *src, *dst;
...@@ -1131,7 +1131,7 @@ void SDL_RateDIV2(SDL_AudioCVT *cvt, Uint16 format) ...@@ -1131,7 +1131,7 @@ void SDL_RateDIV2(SDL_AudioCVT *cvt, Uint16 format)
/* Convert rate down by multiple of 2, for stereo */ /* Convert rate down by multiple of 2, for stereo */
void SDL_RateDIV2_c2(SDL_AudioCVT *cvt, Uint16 format) void SDLCALL SDL_RateDIV2_c2(SDL_AudioCVT *cvt, Uint16 format)
{ {
int i; int i;
Uint8 *src, *dst; Uint8 *src, *dst;
...@@ -1169,7 +1169,7 @@ void SDL_RateDIV2_c2(SDL_AudioCVT *cvt, Uint16 format) ...@@ -1169,7 +1169,7 @@ void SDL_RateDIV2_c2(SDL_AudioCVT *cvt, Uint16 format)
/* Convert rate down by multiple of 2, for quad */ /* Convert rate down by multiple of 2, for quad */
void SDL_RateDIV2_c4(SDL_AudioCVT *cvt, Uint16 format) void SDLCALL SDL_RateDIV2_c4(SDL_AudioCVT *cvt, Uint16 format)
{ {
int i; int i;
Uint8 *src, *dst; Uint8 *src, *dst;
...@@ -1212,7 +1212,7 @@ void SDL_RateDIV2_c4(SDL_AudioCVT *cvt, Uint16 format) ...@@ -1212,7 +1212,7 @@ void SDL_RateDIV2_c4(SDL_AudioCVT *cvt, Uint16 format)
} }
/* Convert rate down by multiple of 2, for 5.1 */ /* Convert rate down by multiple of 2, for 5.1 */
void SDL_RateDIV2_c6(SDL_AudioCVT *cvt, Uint16 format) void SDLCALL SDL_RateDIV2_c6(SDL_AudioCVT *cvt, Uint16 format)
{ {
int i; int i;
Uint8 *src, *dst; Uint8 *src, *dst;
...@@ -1261,7 +1261,7 @@ void SDL_RateDIV2_c6(SDL_AudioCVT *cvt, Uint16 format) ...@@ -1261,7 +1261,7 @@ void SDL_RateDIV2_c6(SDL_AudioCVT *cvt, Uint16 format)
} }
/* Very slow rate conversion routine */ /* Very slow rate conversion routine */
void SDL_RateSLOW(SDL_AudioCVT *cvt, Uint16 format) void SDLCALL SDL_RateSLOW(SDL_AudioCVT *cvt, Uint16 format)
{ {
double ipos; double ipos;
int i, clen; int i, clen;
...@@ -1474,7 +1474,7 @@ int SDL_BuildAudioCVT(SDL_AudioCVT *cvt, ...@@ -1474,7 +1474,7 @@ int SDL_BuildAudioCVT(SDL_AudioCVT *cvt,
Uint32 hi_rate, lo_rate; Uint32 hi_rate, lo_rate;
int len_mult; int len_mult;
double len_ratio; double len_ratio;
void (*rate_cvt)(SDL_AudioCVT *cvt, Uint16 format); void (SDLCALL *rate_cvt)(SDL_AudioCVT *cvt, Uint16 format);
if ( src_rate > dst_rate ) { if ( src_rate > dst_rate ) {
hi_rate = src_rate; hi_rate = src_rate;
......
...@@ -87,7 +87,7 @@ void SDL_Unlock_EventThread(void) ...@@ -87,7 +87,7 @@ void SDL_Unlock_EventThread(void)
#include <time.h> #include <time.h>
#endif #endif
static int SDL_GobbleEvents(void *unused) static int SDLCALL SDL_GobbleEvents(void *unused)
{ {
event_thread = SDL_ThreadID(); event_thread = SDL_ThreadID();
......
...@@ -43,7 +43,7 @@ ...@@ -43,7 +43,7 @@
#define INVALID_SET_FILE_POINTER 0xFFFFFFFF #define INVALID_SET_FILE_POINTER 0xFFFFFFFF
#endif #endif
static int win32_file_open(SDL_RWops *context, const char *filename, const char *mode) static int SDLCALL win32_file_open(SDL_RWops *context, const char *filename, const char *mode)
{ {
#ifndef _WIN32_WCE #ifndef _WIN32_WCE
UINT old_error_mode; UINT old_error_mode;
...@@ -108,7 +108,7 @@ static int win32_file_open(SDL_RWops *context, const char *filename, const char ...@@ -108,7 +108,7 @@ static int win32_file_open(SDL_RWops *context, const char *filename, const char
return 0; /* ok */ return 0; /* ok */
} }
static int win32_file_seek(SDL_RWops *context, int offset, int whence) static int SDLCALL win32_file_seek(SDL_RWops *context, int offset, int whence)
{ {
DWORD win32whence; DWORD win32whence;
int file_pos; int file_pos;
...@@ -138,7 +138,7 @@ static int win32_file_seek(SDL_RWops *context, int offset, int whence) ...@@ -138,7 +138,7 @@ static int win32_file_seek(SDL_RWops *context, int offset, int whence)
SDL_Error(SDL_EFSEEK); SDL_Error(SDL_EFSEEK);
return -1; /* error */ return -1; /* error */
} }
static int win32_file_read(SDL_RWops *context, void *ptr, int size, int maxnum) static int SDLCALL win32_file_read(SDL_RWops *context, void *ptr, int size, int maxnum)
{ {
int total_bytes; int total_bytes;
...@@ -156,7 +156,7 @@ static int win32_file_read(SDL_RWops *context, void *ptr, int size, int maxnum) ...@@ -156,7 +156,7 @@ static int win32_file_read(SDL_RWops *context, void *ptr, int size, int maxnum)
nread = byte_read/size; nread = byte_read/size;
return nread; return nread;
} }
static int win32_file_write(SDL_RWops *context, const void *ptr, int size, int num) static int SDLCALL win32_file_write(SDL_RWops *context, const void *ptr, int size, int num)
{ {
int total_bytes; int total_bytes;
...@@ -183,7 +183,7 @@ static int win32_file_write(SDL_RWops *context, const void *ptr, int size, int n ...@@ -183,7 +183,7 @@ static int win32_file_write(SDL_RWops *context, const void *ptr, int size, int n
nwritten = byte_written/size; nwritten = byte_written/size;
return nwritten; return nwritten;
} }
static int win32_file_close(SDL_RWops *context) static int SDLCALL win32_file_close(SDL_RWops *context)
{ {
if ( context ) { if ( context ) {
...@@ -201,7 +201,7 @@ static int win32_file_close(SDL_RWops *context) ...@@ -201,7 +201,7 @@ static int win32_file_close(SDL_RWops *context)
/* Functions to read/write stdio file pointers */ /* Functions to read/write stdio file pointers */
static int stdio_seek(SDL_RWops *context, int offset, int whence) static int SDLCALL stdio_seek(SDL_RWops *context, int offset, int whence)
{ {
if ( fseek(context->hidden.stdio.fp, offset, whence) == 0 ) { if ( fseek(context->hidden.stdio.fp, offset, whence) == 0 ) {
return(ftell(context->hidden.stdio.fp)); return(ftell(context->hidden.stdio.fp));
...@@ -210,7 +210,7 @@ static int stdio_seek(SDL_RWops *context, int offset, int whence) ...@@ -210,7 +210,7 @@ static int stdio_seek(SDL_RWops *context, int offset, int whence)
return(-1); return(-1);
} }
} }
static int stdio_read(SDL_RWops *context, void *ptr, int size, int maxnum) static int SDLCALL stdio_read(SDL_RWops *context, void *ptr, int size, int maxnum)
{ {
size_t nread; size_t nread;
...@@ -220,7 +220,7 @@ static int stdio_read(SDL_RWops *context, void *ptr, int size, int maxnum) ...@@ -220,7 +220,7 @@ static int stdio_read(SDL_RWops *context, void *ptr, int size, int maxnum)
} }
return(nread); return(nread);
} }
static int stdio_write(SDL_RWops *context, const void *ptr, int size, int num) static int SDLCALL stdio_write(SDL_RWops *context, const void *ptr, int size, int num)
{ {
size_t nwrote; size_t nwrote;
...@@ -230,7 +230,7 @@ static int stdio_write(SDL_RWops *context, const void *ptr, int size, int num) ...@@ -230,7 +230,7 @@ static int stdio_write(SDL_RWops *context, const void *ptr, int size, int num)
} }
return(nwrote); return(nwrote);
} }
static int stdio_close(SDL_RWops *context) static int SDLCALL stdio_close(SDL_RWops *context)
{ {
if ( context ) { if ( context ) {
if ( context->hidden.stdio.autoclose ) { if ( context->hidden.stdio.autoclose ) {
...@@ -245,7 +245,7 @@ static int stdio_close(SDL_RWops *context) ...@@ -245,7 +245,7 @@ static int stdio_close(SDL_RWops *context)
/* Functions to read/write memory pointers */ /* Functions to read/write memory pointers */
static int mem_seek(SDL_RWops *context, int offset, int whence) static int SDLCALL mem_seek(SDL_RWops *context, int offset, int whence)
{ {
Uint8 *newpos; Uint8 *newpos;
...@@ -272,7 +272,7 @@ static int mem_seek(SDL_RWops *context, int offset, int whence) ...@@ -272,7 +272,7 @@ static int mem_seek(SDL_RWops *context, int offset, int whence)
context->hidden.mem.here = newpos; context->hidden.mem.here = newpos;
return(context->hidden.mem.here-context->hidden.mem.base); return(context->hidden.mem.here-context->hidden.mem.base);
} }
static int mem_read(SDL_RWops *context, void *ptr, int size, int maxnum) static int SDLCALL mem_read(SDL_RWops *context, void *ptr, int size, int maxnum)
{ {
size_t total_bytes; size_t total_bytes;
size_t mem_available; size_t mem_available;
...@@ -292,7 +292,7 @@ static int mem_read(SDL_RWops *context, void *ptr, int size, int maxnum) ...@@ -292,7 +292,7 @@ static int mem_read(SDL_RWops *context, void *ptr, int size, int maxnum)
return (total_bytes / size); return (total_bytes / size);
} }
static int mem_write(SDL_RWops *context, const void *ptr, int size, int num) static int SDLCALL mem_write(SDL_RWops *context, const void *ptr, int size, int num)
{ {
if ( (context->hidden.mem.here + (num*size)) > context->hidden.mem.stop ) { if ( (context->hidden.mem.here + (num*size)) > context->hidden.mem.stop ) {
num = (context->hidden.mem.stop-context->hidden.mem.here)/size; num = (context->hidden.mem.stop-context->hidden.mem.here)/size;
...@@ -301,12 +301,12 @@ static int mem_write(SDL_RWops *context, const void *ptr, int size, int num) ...@@ -301,12 +301,12 @@ static int mem_write(SDL_RWops *context, const void *ptr, int size, int num)
context->hidden.mem.here += num*size; context->hidden.mem.here += num*size;
return(num); return(num);
} }
static int mem_writeconst(SDL_RWops *context, const void *ptr, int size, int num) static int SDLCALL mem_writeconst(SDL_RWops *context, const void *ptr, int size, int num)
{ {
SDL_SetError("Can't write to read-only memory"); SDL_SetError("Can't write to read-only memory");
return(-1); return(-1);
} }
static int mem_close(SDL_RWops *context) static int SDLCALL mem_close(SDL_RWops *context)
{ {
if ( context ) { if ( context ) {
SDL_FreeRW(context); SDL_FreeRW(context);
......
...@@ -121,8 +121,15 @@ static BOOL OutOfMemory(void) ...@@ -121,8 +121,15 @@ static BOOL OutOfMemory(void)
return FALSE; return FALSE;
} }
/* SDL_Quit() shouldn't be used with atexit() directly because
calling conventions may differ... */
static void cleanup(void)
{
SDL_Quit();
}
/* Remove the output files if there was no output written */ /* Remove the output files if there was no output written */
static void __cdecl cleanup_output(void) static void cleanup_output(void)
{ {
#ifndef NO_STDIO_REDIRECT #ifndef NO_STDIO_REDIRECT
FILE *file; FILE *file;
...@@ -188,7 +195,7 @@ int console_main(int argc, char *argv[]) ...@@ -188,7 +195,7 @@ int console_main(int argc, char *argv[])
if ( bufp == NULL ) { if ( bufp == NULL ) {
return OutOfMemory(); return OutOfMemory();
} }
SDL_strlcpy(bufp, appname, n); SDL_strlcpy(bufp, appname, n+1);
appname = bufp; appname = bufp;
/* Load SDL dynamic link library */ /* Load SDL dynamic link library */
...@@ -197,7 +204,7 @@ int console_main(int argc, char *argv[]) ...@@ -197,7 +204,7 @@ int console_main(int argc, char *argv[])
return(FALSE); return(FALSE);
} }
atexit(cleanup_output); atexit(cleanup_output);
atexit(SDL_Quit); atexit(cleanup);
/* Sam: /* Sam:
We still need to pass in the application handle so that We still need to pass in the application handle so that
......
...@@ -168,7 +168,7 @@ SDL_error *SDL_GetErrBuf(void) ...@@ -168,7 +168,7 @@ SDL_error *SDL_GetErrBuf(void)
/* Arguments and callback to setup and run the user thread function */ /* Arguments and callback to setup and run the user thread function */
typedef struct { typedef struct {
int (*func)(void *); int (SDLCALL *func)(void *);
void *data; void *data;
SDL_Thread *info; SDL_Thread *info;
SDL_sem *wait; SDL_sem *wait;
...@@ -177,7 +177,7 @@ typedef struct { ...@@ -177,7 +177,7 @@ typedef struct {
void SDL_RunThread(void *data) void SDL_RunThread(void *data)
{ {
thread_args *args; thread_args *args;
int (*userfunc)(void *); int (SDLCALL *userfunc)(void *);
void *userdata; void *userdata;
int *statusloc; int *statusloc;
...@@ -204,9 +204,9 @@ void SDL_RunThread(void *data) ...@@ -204,9 +204,9 @@ void SDL_RunThread(void *data)
#ifdef SDL_PASSED_BEGINTHREAD_ENDTHREAD #ifdef SDL_PASSED_BEGINTHREAD_ENDTHREAD
#undef SDL_CreateThread #undef SDL_CreateThread
DECLSPEC SDL_Thread * SDLCALL SDL_CreateThread(int (*fn)(void *), void *data, pfnSDL_CurrentBeginThread pfnBeginThread, pfnSDL_CurrentEndThread pfnEndThread) DECLSPEC SDL_Thread * SDLCALL SDL_CreateThread(int (SDLCALL *fn)(void *), void *data, pfnSDL_CurrentBeginThread pfnBeginThread, pfnSDL_CurrentEndThread pfnEndThread)
#else #else
DECLSPEC SDL_Thread * SDLCALL SDL_CreateThread(int (*fn)(void *), void *data) DECLSPEC SDL_Thread * SDLCALL SDL_CreateThread(int (SDLCALL *fn)(void *), void *data)
#endif #endif
{ {
SDL_Thread *thread; SDL_Thread *thread;
......
...@@ -41,6 +41,15 @@ typedef unsigned long (__cdecl *pfnSDL_CurrentBeginThread) (void *, unsigned, ...@@ -41,6 +41,15 @@ typedef unsigned long (__cdecl *pfnSDL_CurrentBeginThread) (void *, unsigned,
unsigned (__stdcall *func)(void *), void *arg, unsigned (__stdcall *func)(void *), void *arg,
unsigned, unsigned *threadID); unsigned, unsigned *threadID);
typedef void (__cdecl *pfnSDL_CurrentEndThread)(unsigned code); typedef void (__cdecl *pfnSDL_CurrentEndThread)(unsigned code);
#elif defined(__WATCOMC__)
/* This is for Watcom targets except OS2 */
#if __WATCOMC__ < 1240
#define __watcall
#endif
typedef unsigned long (__watcall *pfnSDL_CurrentBeginThread) (void *, unsigned,
unsigned (__stdcall *func)(void *), void *arg,
unsigned, unsigned *threadID);
typedef void (__watcall *pfnSDL_CurrentEndThread)(unsigned code);
#else #else
typedef uintptr_t (__cdecl *pfnSDL_CurrentBeginThread) (void *, unsigned, typedef uintptr_t (__cdecl *pfnSDL_CurrentBeginThread) (void *, unsigned,
unsigned (__stdcall *func)(void *), void *arg, unsigned (__stdcall *func)(void *), void *arg,
......
...@@ -177,7 +177,7 @@ int WIN_GL_SetupWindow(_THIS) ...@@ -177,7 +177,7 @@ int WIN_GL_SetupWindow(_THIS)
int iAttribs[64]; int iAttribs[64];
int *iAttr; int *iAttr;
float fAttribs[1] = { 0 }; float fAttribs[1] = { 0 };
const GLubyte *(*glGetStringFunc)(GLenum); const GLubyte *(WINAPI *glGetStringFunc)(GLenum);
const char *wglext; const char *wglext;
/* load the gl driver from a default path */ /* load the gl driver from a default path */
......
...@@ -32,7 +32,7 @@ static void quit(int rc) ...@@ -32,7 +32,7 @@ static void quit(int rc)
} }
void fillerup(void *unused, Uint8 *stream, int len) void SDLCALL fillerup(void *unused, Uint8 *stream, int len)
{ {
Uint8 *waveptr; Uint8 *waveptr;
int waveleft; int waveleft;
......
...@@ -17,7 +17,7 @@ static void quit(int rc) ...@@ -17,7 +17,7 @@ static void quit(int rc)
exit(rc); exit(rc);
} }
int ThreadFunc(void *data) int SDLCALL ThreadFunc(void *data)
{ {
/* Set the child thread error string */ /* Set the child thread error string */
SDL_SetError("Thread %s (%d) had a problem: %s", SDL_SetError("Thread %s (%d) had a problem: %s",
......
...@@ -17,7 +17,7 @@ static void quit(int rc) ...@@ -17,7 +17,7 @@ static void quit(int rc)
exit(rc); exit(rc);
} }
int ThreadFunc(void *data) int SDLCALL ThreadFunc(void *data)
{ {
printf("Started thread %s: My thread id is %u\n", printf("Started thread %s: My thread id is %u\n",
(char *)data, SDL_ThreadID()); (char *)data, SDL_ThreadID());
......
...@@ -5,7 +5,6 @@ ...@@ -5,7 +5,6 @@
#include <signal.h> #include <signal.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h>
#include "SDL.h" #include "SDL.h"
#include "SDL_mutex.h" #include "SDL_mutex.h"
...@@ -14,6 +13,7 @@ ...@@ -14,6 +13,7 @@
static SDL_mutex *mutex = NULL; static SDL_mutex *mutex = NULL;
static Uint32 mainthread; static Uint32 mainthread;
static SDL_Thread *threads[6]; static SDL_Thread *threads[6];
static volatile int doterminate = 0;
/* /*
* SDL_Quit() shouldn't be used with atexit() directly because * SDL_Quit() shouldn't be used with atexit() directly because
...@@ -31,8 +31,8 @@ void printid(void) ...@@ -31,8 +31,8 @@ void printid(void)
void terminate(int sig) void terminate(int sig)
{ {
printf("Process %u: raising SIGTERM\n", SDL_ThreadID()); signal(SIGINT, terminate);
raise(SIGTERM); doterminate = 1;
} }
void closemutex(int sig) void closemutex(int sig)
{ {
...@@ -44,7 +44,7 @@ void closemutex(int sig) ...@@ -44,7 +44,7 @@ void closemutex(int sig)
SDL_DestroyMutex(mutex); SDL_DestroyMutex(mutex);
exit(sig); exit(sig);
} }
int Run(void *data) int SDLCALL Run(void *data)
{ {
if ( SDL_ThreadID() == mainthread ) if ( SDL_ThreadID() == mainthread )
signal(SIGTERM, closemutex); signal(SIGTERM, closemutex);
...@@ -63,6 +63,10 @@ int Run(void *data) ...@@ -63,6 +63,10 @@ int Run(void *data)
} }
/* If this sleep isn't done, then threads may starve */ /* If this sleep isn't done, then threads may starve */
SDL_Delay(10); SDL_Delay(10);
if (SDL_ThreadID() == mainthread && doterminate) {
printf("Process %u: raising SIGTERM\n", SDL_ThreadID());
raise(SIGTERM);
}
} }
return(0); return(0);
} }
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
static SDL_sem *sem; static SDL_sem *sem;
int alive = 1; int alive = 1;
int ThreadFunc(void *data) int SDLCALL ThreadFunc(void *data)
{ {
int threadnum = (int)(uintptr_t)data; int threadnum = (int)(uintptr_t)data;
while ( alive ) { while ( alive ) {
......
...@@ -12,13 +12,13 @@ ...@@ -12,13 +12,13 @@
static int ticks = 0; static int ticks = 0;
static Uint32 ticktock(Uint32 interval) static Uint32 SDLCALL ticktock(Uint32 interval)
{ {
++ticks; ++ticks;
return(interval); return(interval);
} }
static Uint32 callback(Uint32 interval, void *param) static Uint32 SDLCALL callback(Uint32 interval, void *param)
{ {
printf("Timer %d : param = %d\n", interval, (int)(uintptr_t)param); printf("Timer %d : param = %d\n", interval, (int)(uintptr_t)param);
return interval; return interval;
......
...@@ -168,7 +168,7 @@ void HotKey_Quit(void) ...@@ -168,7 +168,7 @@ void HotKey_Quit(void)
SDL_PushEvent(&event); SDL_PushEvent(&event);
} }
int FilterEvents(const SDL_Event *event) int SDLCALL FilterEvents(const SDL_Event *event)
{ {
static int reallyquit = 0; static int reallyquit = 0;
......
...@@ -77,7 +77,7 @@ SDL_Surface *LoadIconSurface(char *file, Uint8 **maskp) ...@@ -77,7 +77,7 @@ SDL_Surface *LoadIconSurface(char *file, Uint8 **maskp)
return(icon); return(icon);
} }
int FilterEvents(const SDL_Event *event) int SDLCALL FilterEvents(const SDL_Event *event)
{ {
static int reallyquit = 0; static int reallyquit = 0;
...@@ -127,7 +127,7 @@ int FilterEvents(const SDL_Event *event) ...@@ -127,7 +127,7 @@ int FilterEvents(const SDL_Event *event)
} }
} }
int HandleMouse(void *unused) int SDLCALL HandleMouse(void *unused)
{ {
SDL_Event events[10]; SDL_Event events[10];
int i, found; int i, found;
...@@ -164,7 +164,7 @@ int HandleMouse(void *unused) ...@@ -164,7 +164,7 @@ int HandleMouse(void *unused)
return(0); return(0);
} }
int HandleKeyboard(void *unused) int SDLCALL HandleKeyboard(void *unused)
{ {
SDL_Event events[10]; SDL_Event events[10];
int i, found; int i, found;
......
...@@ -20,14 +20,14 @@ static void quit(int rc) ...@@ -20,14 +20,14 @@ static void quit(int rc)
exit(rc); exit(rc);
} }
int SubThreadFunc(void *data) { int SDLCALL SubThreadFunc(void *data) {
while(! *(int volatile *)data) { while(! *(int volatile *)data) {
; /*SDL_Delay(10);*/ /* do nothing */ ; /*SDL_Delay(10);*/ /* do nothing */
} }
return 0; return 0;
} }
int ThreadFunc(void *data) { int SDLCALL ThreadFunc(void *data) {
SDL_Thread *sub_threads[NUMTHREADS]; SDL_Thread *sub_threads[NUMTHREADS];
int flags[NUMTHREADS]; int flags[NUMTHREADS];
int i; int i;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment