Skip to content

Commit

Permalink
Fixed bug #215
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
slouken committed May 7, 2006
1 parent de116ac commit d7ca3ca
Show file tree
Hide file tree
Showing 19 changed files with 85 additions and 63 deletions.
2 changes: 2 additions & 0 deletions include/SDL_stdinc.h
Expand Up @@ -168,6 +168,8 @@ extern DECLSPEC void SDLCALL SDL_free(void *mem);
# elif defined(_MSC_VER)
# include <malloc.h>
# define alloca _alloca
# elif defined(__WATCOMC__)
# include <malloc.h>
# elif defined(__AIX__)
#pragma alloca
# else
Expand Down
4 changes: 2 additions & 2 deletions src/audio/SDL_audio.c
Expand Up @@ -120,13 +120,13 @@ static int audio_configured = 0;
#endif

/* The general mixing thread function */
int SDL_RunAudio(void *audiop)
int SDLCALL SDL_RunAudio(void *audiop)
{
SDL_AudioDevice *audio = (SDL_AudioDevice *)audiop;
Uint8 *stream;
int stream_len;
void *udata;
void (*fill)(void *userdata,Uint8 *stream, int len);
void (SDLCALL *fill)(void *userdata,Uint8 *stream, int len);
int silence;
#if SDL_AUDIO_DRIVER_AHI
int started = 0;
Expand Down
2 changes: 1 addition & 1 deletion src/audio/SDL_audio_c.h
Expand Up @@ -31,4 +31,4 @@ extern Uint16 SDL_NextAudioFormat(void);
extern void SDL_CalculateAudioSpec(SDL_AudioSpec *spec);

/* The actual mixing thread function */
extern int SDL_RunAudio(void *audiop);
extern int SDLCALL SDL_RunAudio(void *audiop);
42 changes: 21 additions & 21 deletions src/audio/SDL_audiocvt.c
Expand Up @@ -27,7 +27,7 @@


/* 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;
Sint32 sample;
Expand Down Expand Up @@ -169,7 +169,7 @@ void SDL_ConvertMono(SDL_AudioCVT *cvt, Uint16 format)
}

/* Discard top 4 channels */
void SDL_ConvertStrip(SDL_AudioCVT *cvt, Uint16 format)
void SDLCALL SDL_ConvertStrip(SDL_AudioCVT *cvt, Uint16 format)
{
int i;
Sint32 lsample, rsample;
Expand Down Expand Up @@ -285,7 +285,7 @@ void SDL_ConvertStrip(SDL_AudioCVT *cvt, Uint16 format)


/* 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;
Sint32 lsample, rsample;
Expand Down Expand Up @@ -400,7 +400,7 @@ void SDL_ConvertStrip_2(SDL_AudioCVT *cvt, Uint16 format)
}

/* 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;

Expand Down Expand Up @@ -438,7 +438,7 @@ void SDL_ConvertStereo(SDL_AudioCVT *cvt, Uint16 format)


/* 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;

Expand Down Expand Up @@ -615,7 +615,7 @@ void SDL_ConvertSurround(SDL_AudioCVT *cvt, Uint16 format)


/* 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;

Expand Down Expand Up @@ -768,7 +768,7 @@ void SDL_ConvertSurround_4(SDL_AudioCVT *cvt, Uint16 format)


/* 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;
Uint8 *src, *dst;
Expand All @@ -791,7 +791,7 @@ void SDL_Convert16LSB(SDL_AudioCVT *cvt, Uint16 format)
}
}
/* 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;
Uint8 *src, *dst;
Expand All @@ -815,7 +815,7 @@ void SDL_Convert16MSB(SDL_AudioCVT *cvt, Uint16 format)
}

/* 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;
Uint8 *src, *dst;
Expand All @@ -841,7 +841,7 @@ void SDL_Convert8(SDL_AudioCVT *cvt, Uint16 format)
}

/* Toggle signed/unsigned */
void SDL_ConvertSign(SDL_AudioCVT *cvt, Uint16 format)
void SDLCALL SDL_ConvertSign(SDL_AudioCVT *cvt, Uint16 format)
{
int i;
Uint8 *data;
Expand Down Expand Up @@ -870,7 +870,7 @@ void SDL_ConvertSign(SDL_AudioCVT *cvt, Uint16 format)
}

/* Toggle endianness */
void SDL_ConvertEndian(SDL_AudioCVT *cvt, Uint16 format)
void SDLCALL SDL_ConvertEndian(SDL_AudioCVT *cvt, Uint16 format)
{
int i;
Uint8 *data, tmp;
Expand All @@ -892,7 +892,7 @@ void SDL_ConvertEndian(SDL_AudioCVT *cvt, Uint16 format)
}

/* 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;
Uint8 *src, *dst;
Expand Down Expand Up @@ -930,7 +930,7 @@ void SDL_RateMUL2(SDL_AudioCVT *cvt, Uint16 format)


/* 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;
Uint8 *src, *dst;
Expand Down Expand Up @@ -973,7 +973,7 @@ void SDL_RateMUL2_c2(SDL_AudioCVT *cvt, Uint16 format)
}

/* 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;
Uint8 *src, *dst;
Expand Down Expand Up @@ -1029,7 +1029,7 @@ void SDL_RateMUL2_c4(SDL_AudioCVT *cvt, Uint16 format)


/* 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;
Uint8 *src, *dst;
Expand Down Expand Up @@ -1096,7 +1096,7 @@ void SDL_RateMUL2_c6(SDL_AudioCVT *cvt, Uint16 format)
}

/* 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;
Uint8 *src, *dst;
Expand Down Expand Up @@ -1131,7 +1131,7 @@ void SDL_RateDIV2(SDL_AudioCVT *cvt, Uint16 format)


/* 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;
Uint8 *src, *dst;
Expand Down Expand Up @@ -1169,7 +1169,7 @@ void SDL_RateDIV2_c2(SDL_AudioCVT *cvt, Uint16 format)


/* 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;
Uint8 *src, *dst;
Expand Down Expand Up @@ -1212,7 +1212,7 @@ void SDL_RateDIV2_c4(SDL_AudioCVT *cvt, Uint16 format)
}

/* 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;
Uint8 *src, *dst;
Expand Down Expand Up @@ -1261,7 +1261,7 @@ void SDL_RateDIV2_c6(SDL_AudioCVT *cvt, Uint16 format)
}

/* Very slow rate conversion routine */
void SDL_RateSLOW(SDL_AudioCVT *cvt, Uint16 format)
void SDLCALL SDL_RateSLOW(SDL_AudioCVT *cvt, Uint16 format)
{
double ipos;
int i, clen;
Expand Down Expand Up @@ -1474,7 +1474,7 @@ int SDL_BuildAudioCVT(SDL_AudioCVT *cvt,
Uint32 hi_rate, lo_rate;
int len_mult;
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 ) {
hi_rate = src_rate;
Expand Down
2 changes: 1 addition & 1 deletion src/events/SDL_events.c
Expand Up @@ -87,7 +87,7 @@ void SDL_Unlock_EventThread(void)
#include <time.h>
#endif

static int SDL_GobbleEvents(void *unused)
static int SDLCALL SDL_GobbleEvents(void *unused)
{
event_thread = SDL_ThreadID();

Expand Down
28 changes: 14 additions & 14 deletions src/file/SDL_rwops.c
Expand Up @@ -43,7 +43,7 @@
#define INVALID_SET_FILE_POINTER 0xFFFFFFFF
#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
UINT old_error_mode;
Expand Down Expand Up @@ -108,7 +108,7 @@ static int win32_file_open(SDL_RWops *context, const char *filename, const char

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;
int file_pos;
Expand Down Expand Up @@ -138,7 +138,7 @@ static int win32_file_seek(SDL_RWops *context, int offset, int whence)
SDL_Error(SDL_EFSEEK);
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;
Expand All @@ -156,7 +156,7 @@ static int win32_file_read(SDL_RWops *context, void *ptr, int size, int maxnum)
nread = byte_read/size;
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;
Expand All @@ -183,7 +183,7 @@ static int win32_file_write(SDL_RWops *context, const void *ptr, int size, int n
nwritten = byte_written/size;
return nwritten;
}
static int win32_file_close(SDL_RWops *context)
static int SDLCALL win32_file_close(SDL_RWops *context)
{

if ( context ) {
Expand All @@ -201,7 +201,7 @@ static int win32_file_close(SDL_RWops *context)

/* 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 ) {
return(ftell(context->hidden.stdio.fp));
Expand All @@ -210,7 +210,7 @@ static int stdio_seek(SDL_RWops *context, int offset, int whence)
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;

Expand All @@ -220,7 +220,7 @@ static int stdio_read(SDL_RWops *context, void *ptr, int size, int maxnum)
}
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;

Expand All @@ -230,7 +230,7 @@ static int stdio_write(SDL_RWops *context, const void *ptr, int size, int num)
}
return(nwrote);
}
static int stdio_close(SDL_RWops *context)
static int SDLCALL stdio_close(SDL_RWops *context)
{
if ( context ) {
if ( context->hidden.stdio.autoclose ) {
Expand All @@ -245,7 +245,7 @@ static int stdio_close(SDL_RWops *context)

/* 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;

Expand All @@ -272,7 +272,7 @@ static int mem_seek(SDL_RWops *context, int offset, int whence)
context->hidden.mem.here = newpos;
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 mem_available;
Expand All @@ -292,7 +292,7 @@ static int mem_read(SDL_RWops *context, void *ptr, int size, int maxnum)

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 ) {
num = (context->hidden.mem.stop-context->hidden.mem.here)/size;
Expand All @@ -301,12 +301,12 @@ static int mem_write(SDL_RWops *context, const void *ptr, int size, int num)
context->hidden.mem.here += num*size;
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");
return(-1);
}
static int mem_close(SDL_RWops *context)
static int SDLCALL mem_close(SDL_RWops *context)
{
if ( context ) {
SDL_FreeRW(context);
Expand Down
13 changes: 10 additions & 3 deletions src/main/win32/SDL_win32_main.c
Expand Up @@ -121,8 +121,15 @@ static BOOL OutOfMemory(void)
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 */
static void __cdecl cleanup_output(void)
static void cleanup_output(void)
{
#ifndef NO_STDIO_REDIRECT
FILE *file;
Expand Down Expand Up @@ -188,7 +195,7 @@ int console_main(int argc, char *argv[])
if ( bufp == NULL ) {
return OutOfMemory();
}
SDL_strlcpy(bufp, appname, n);
SDL_strlcpy(bufp, appname, n+1);
appname = bufp;

/* Load SDL dynamic link library */
Expand All @@ -197,7 +204,7 @@ int console_main(int argc, char *argv[])
return(FALSE);
}
atexit(cleanup_output);
atexit(SDL_Quit);
atexit(cleanup);

/* Sam:
We still need to pass in the application handle so that
Expand Down

0 comments on commit d7ca3ca

Please sign in to comment.