os2: misc build fixes
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 265 266 267 268 269 270 271
diff --git a/src/audio/os2/SDL_os2audio.c b/src/audio/os2/SDL_os2audio.c
index 9e5e99b..4a8017d 100644
--- a/src/audio/os2/SDL_os2audio.c
+++ b/src/audio/os2/SDL_os2audio.c
@@ -26,7 +26,6 @@
#include "../../core/os2/SDL_os2.h"
-#include "SDL_timer.h"
#include "SDL_audio.h"
#include "../SDL_audio_c.h"
#include "SDL_os2audio.h"
@@ -34,12 +33,12 @@
/*
void lockIncr(volatile int *piVal);
#pragma aux lockIncr = \
- " lock add [eax], 1 "\
+ "lock add [eax], 1 "\
parm [eax];
void lockDecr(volatile int *piVal);
#pragma aux lockDecr = \
- " lock sub [eax], 1 "\
+ "lock sub [eax], 1 "\
parm [eax];
*/
@@ -169,7 +168,7 @@ static void OS2_DetectDevices(void)
static void OS2_WaitDevice(_THIS)
{
- SDL_PrivateAudioData *pAData = (SDL_PrivateAudioData *)this->hidden;
+ SDL_PrivateAudioData *pAData = (SDL_PrivateAudioData *)_this->hidden;
ULONG ulRC;
/* Wait for an audio chunk to finish */
@@ -181,13 +180,13 @@ static void OS2_WaitDevice(_THIS)
static Uint8 *OS2_GetDeviceBuf(_THIS)
{
- SDL_PrivateAudioData *pAData = (SDL_PrivateAudioData *)this->hidden;
- return pAData->aMixBuffers[pAData->ulNextBuf].pBuffer;
+ SDL_PrivateAudioData *pAData = (SDL_PrivateAudioData *)_this->hidden;
+ return (Uint8 *) pAData->aMixBuffers[pAData->ulNextBuf].pBuffer;
}
static void OS2_PlayDevice(_THIS)
{
- SDL_PrivateAudioData *pAData = (SDL_PrivateAudioData *)this->hidden;
+ SDL_PrivateAudioData *pAData = (SDL_PrivateAudioData *)_this->hidden;
ULONG ulRC;
PMCI_MIX_BUFFER pMixBuffer = &pAData->aMixBuffers[pAData->ulNextBuf];
@@ -204,7 +203,7 @@ static void OS2_PlayDevice(_THIS)
static void OS2_CloseDevice(_THIS)
{
- SDL_PrivateAudioData *pAData = (SDL_PrivateAudioData *)this->hidden;
+ SDL_PrivateAudioData *pAData = (SDL_PrivateAudioData *)_this->hidden;
MCI_GENERIC_PARMS sMCIGenericParms;
ULONG ulRC;
@@ -230,7 +229,7 @@ static void OS2_CloseDevice(_THIS)
stMCIBuffer.ulBufferSize = pAData->aMixBuffers[0].ulBufferLength;
stMCIBuffer.ulNumBuffers = pAData->cMixBuffers;
- stMCIBuffer.pBufList = &pAData->aMixBuffers;
+ stMCIBuffer.pBufList = pAData->aMixBuffers;
ulRC = mciSendCommand(pAData->usDeviceId, MCI_BUFFER,
MCI_WAIT | MCI_DEALLOCATE_MEMORY, &stMCIBuffer, 0);
@@ -267,7 +266,7 @@ static int OS2_OpenDevice(_THIS, void *handle, const char *devname,
SDL_zero(stMCIAmpOpen);
SDL_zero(stMCIBuffer);
- for (SDLAudioFmt = SDL_FirstAudioFormat(this->spec.format);
+ for (SDLAudioFmt = SDL_FirstAudioFormat(_this->spec.format);
SDLAudioFmt != 0; SDLAudioFmt = SDL_NextAudioFormat()) {
if (SDLAudioFmt == AUDIO_U8 || SDLAudioFmt == AUDIO_S16)
break;
@@ -277,10 +276,10 @@ static int OS2_OpenDevice(_THIS, void *handle, const char *devname,
SDLAudioFmt = AUDIO_S16;
}
- pAData = SDL_calloc(1, sizeof(SDL_PrivateAudioData));
+ pAData = (SDL_PrivateAudioData *) SDL_calloc(1, sizeof(struct SDL_PrivateAudioData));
if (pAData == NULL)
return SDL_OutOfMemory();
- this->hidden = pAData;
+ _this->hidden = pAData;
ulRC = DosCreateEventSem(NULL, &pAData->hevBuf, DCE_AUTORESET, TRUE);
if (ulRC != NO_ERROR) {
@@ -334,21 +333,21 @@ static int OS2_OpenDevice(_THIS, void *handle, const char *devname,
&stMCIAmpSet, 0);
}
- this->spec.format = SDLAudioFmt;
- this->spec.channels = this->spec.channels > 1 ? 2 : 1;
- if (this->spec.freq < 8000) {
- this->spec.freq = 8000;
+ _this->spec.format = SDLAudioFmt;
+ _this->spec.channels = _this->spec.channels > 1 ? 2 : 1;
+ if (_this->spec.freq < 8000) {
+ _this->spec.freq = 8000;
new_freq = TRUE;
- } else if (this->spec.freq > 48000) {
- this->spec.freq = 48000;
+ } else if (_this->spec.freq > 48000) {
+ _this->spec.freq = 48000;
new_freq = TRUE;
}
/* Setup mixer. */
pAData->stMCIMixSetup.ulFormatTag = MCI_WAVE_FORMAT_PCM;
pAData->stMCIMixSetup.ulBitsPerSample = SDL_AUDIO_BITSIZE(SDLAudioFmt);
- pAData->stMCIMixSetup.ulSamplesPerSec = this->spec.freq;
- pAData->stMCIMixSetup.ulChannels = this->spec.channels;
+ pAData->stMCIMixSetup.ulSamplesPerSec = _this->spec.freq;
+ pAData->stMCIMixSetup.ulChannels = _this->spec.channels;
pAData->stMCIMixSetup.ulDeviceType = MCI_DEVTYPE_WAVEFORM_AUDIO;
if (iscapture == 0) {
pAData->stMCIMixSetup.ulFormatMode= MCI_PLAY;
@@ -360,10 +359,10 @@ static int OS2_OpenDevice(_THIS, void *handle, const char *devname,
ulRC = mciSendCommand(pAData->usDeviceId, MCI_MIXSETUP,
MCI_WAIT | MCI_MIXSETUP_INIT, &pAData->stMCIMixSetup, 0);
- if (ulRC != MCIERR_SUCCESS && this->spec.freq > 44100) {
+ if (ulRC != MCIERR_SUCCESS && _this->spec.freq > 44100) {
new_freq = TRUE;
pAData->stMCIMixSetup.ulSamplesPerSec = 44100;
- this->spec.freq = 44100;
+ _this->spec.freq = 44100;
ulRC = mciSendCommand(pAData->usDeviceId, MCI_MIXSETUP,
MCI_WAIT | MCI_MIXSETUP_INIT, &pAData->stMCIMixSetup, 0);
}
@@ -379,23 +378,23 @@ static int OS2_OpenDevice(_THIS, void *handle, const char *devname,
return _MCIError("MCI_MIXSETUP", ulRC);
}
- if (this->spec.samples == 0 || new_freq == TRUE) {
+ if (_this->spec.samples == 0 || new_freq == TRUE) {
/* also see SDL_audio.c:prepare_audiospec() */
/* Pick a default of ~46 ms at desired frequency */
- Uint32 samples = (this->spec.freq / 1000) * 46;
+ Uint32 samples = (_this->spec.freq / 1000) * 46;
Uint32 power2 = 1;
while (power2 < samples) {
power2 <<= 1;
}
- this->spec.samples = power2;
+ _this->spec.samples = power2;
}
/* Update the fragment size as size in bytes */
- SDL_CalculateAudioSpec(&this->spec);
+ SDL_CalculateAudioSpec(&_this->spec);
/* Allocate memory buffers */
- stMCIBuffer.ulBufferSize = this->spec.size;/* (this->spec.freq / 1000) * 100 */
+ stMCIBuffer.ulBufferSize = _this->spec.size;/* (_this->spec.freq / 1000) * 100 */
stMCIBuffer.ulNumBuffers = NUM_BUFFERS;
- stMCIBuffer.pBufList = &pAData->aMixBuffers;
+ stMCIBuffer.pBufList = pAData->aMixBuffers;
ulRC = mciSendCommand(pAData->usDeviceId, MCI_BUFFER,
MCI_WAIT | MCI_ALLOCATE_MEMORY, &stMCIBuffer, 0);
@@ -403,7 +402,7 @@ static int OS2_OpenDevice(_THIS, void *handle, const char *devname,
return _MCIError("MCI_BUFFER", ulRC);
}
pAData->cMixBuffers = stMCIBuffer.ulNumBuffers;
- this->spec.size = stMCIBuffer.ulBufferSize;
+ _this->spec.size = stMCIBuffer.ulBufferSize;
/* Fill all device buffers with data */
for (ulIdx = 0; ulIdx < stMCIBuffer.ulNumBuffers; ulIdx++) {
@@ -412,13 +411,13 @@ static int OS2_OpenDevice(_THIS, void *handle, const char *devname,
pAData->aMixBuffers[ulIdx].ulUserParm = (ULONG)pAData;
memset(((PMCI_MIX_BUFFER)stMCIBuffer.pBufList)[ulIdx].pBuffer,
- this->spec.silence, stMCIBuffer.ulBufferSize);
+ _this->spec.silence, stMCIBuffer.ulBufferSize);
}
/* Write buffers to kick off the amp mixer */
/*pAData->ulQueuedBuf = 1;//stMCIBuffer.ulNumBuffers */
ulRC = pAData->stMCIMixSetup.pmixWrite(pAData->stMCIMixSetup.ulMixHandle,
- &pAData->aMixBuffers,
+ pAData->aMixBuffers,
1 /*stMCIBuffer.ulNumBuffers*/);
if (ulRC != MCIERR_SUCCESS) {
_mixIOError("pmixWrite", ulRC);
diff --git a/src/audio/os2/SDL_os2audio.h b/src/audio/os2/SDL_os2audio.h
index 781d413..46a3384 100644
--- a/src/audio/os2/SDL_os2audio.h
+++ b/src/audio/os2/SDL_os2audio.h
@@ -33,9 +33,9 @@
#include <os2me.h>
/* Hidden "this" pointer for the audio functions */
-#define _THIS SDL_AudioDevice *this
+#define _THIS SDL_AudioDevice *_this
-#define NUM_BUFFERS 3
+#define NUM_BUFFERS 3
typedef struct SDL_PrivateAudioData
{
diff --git a/src/core/os2/geniconv/os2iconv.c b/src/core/os2/geniconv/os2iconv.c
index d7dfe06..e03a6a4 100644
--- a/src/core/os2/geniconv/os2iconv.c
+++ b/src/core/os2/geniconv/os2iconv.c
@@ -41,6 +41,10 @@
#endif
#include "os2cp.h"
+#if !defined(min)
+#define min(a, b) (((a) < (b)) ? (a) : (b))
+#endif
+
#define MAX_CP_NAME_LEN 64
typedef struct iuconv_obj {
@@ -127,7 +131,7 @@ extern iconv_t _System os2_iconv_open(const char* tocode, const char* fromcode)
uo_fromcode = NULL;
}
- iuobj = malloc(sizeof(iuconv_obj));
+ iuobj = (iuconv_obj *) malloc(sizeof(iuconv_obj));
iuobj->uo_tocode = uo_tocode;
iuobj->uo_fromcode = uo_fromcode;
iuobj->buf_len = 0;
diff --git a/src/core/os2/geniconv/sys2utf8.c b/src/core/os2/geniconv/sys2utf8.c
index 392cd4b..4815476 100644
--- a/src/core/os2/geniconv/sys2utf8.c
+++ b/src/core/os2/geniconv/sys2utf8.c
@@ -83,15 +83,15 @@ int StrUTF8(int fToUTF8, char *pcDst, int cbDst, char *pcSrc, int cbSrc)
char *StrUTF8New(int fToUTF8, char *pcStr, int cbStr)
{
int cbNewStr = (((cbStr > 4)? cbStr : 4) + 1) * 2;
- char *pszNewStr = malloc(cbNewStr);
+ char *pszNewStr = (char *) malloc(cbNewStr);
if (pszNewStr == NULL)
return NULL;
cbNewStr = StrUTF8(fToUTF8, pszNewStr, cbNewStr, pcStr, cbStr);
if (cbNewStr != -1) {
- pcStr = realloc(pszNewStr, cbNewStr + ((fToUTF8)? 1 : sizeof(short)));
- if (pcStr != NULL)
+ pcStr = (char *) realloc(pszNewStr, cbNewStr + ((fToUTF8)? 1 : sizeof(short)));
+ if (pcStr)
return pcStr;
}
diff --git a/src/core/os2/geniconv/test.c b/src/core/os2/geniconv/test.c
index 405ceac..cbe8db0 100644
--- a/src/core/os2/geniconv/test.c
+++ b/src/core/os2/geniconv/test.c
@@ -51,10 +51,10 @@ int main(void)
inbuf = StrUTF8New(1, acBuf, strlen(acBuf));
/* UTF-8 -> system cp. by StrUTF8() */
- if (StrUTF8(0, &acBuf, sizeof(acBuf), inbuf, strlen(inbuf)) == -1) {
+ if (StrUTF8(0, acBuf, sizeof(acBuf), inbuf, strlen(inbuf)) == -1) {
puts("StrUTF8() failed");
} else {
- printf("system cp. -> UTF-8 -> system cp.: %s\n", &acBuf);
+ printf("system cp. -> UTF-8 -> system cp.: %s\n", acBuf);
}
free(inbuf);