os2: a _lot_ of coding style cleanup, sot that they match the SDL style.

also renamed the 'debug' macro to debug_os2: the former was dangerously
a common name.

the binary (dll) output is precisely the same as before.
This commit is contained in:
Ozkan Sezer 2020-10-15 21:37:30 +03:00
parent bdc5129f13
commit a90f0400a5
29 changed files with 3536 additions and 3806 deletions

View file

@ -32,56 +32,56 @@
#define INCL_DOSERRORS
#include <os2.h>
SDL_TLSData **ppSDLTLSData = NULL;
SDL_TLSData **ppSDLTLSData = NULL;
static ULONG cTLSAlloc = 0;
static ULONG cTLSAlloc = 0;
// SDL_OS2TLSAlloc() called from SDL_InitSubSystem()
void SDL_OS2TLSAlloc()
/* SDL_OS2TLSAlloc() called from SDL_InitSubSystem() */
void SDL_OS2TLSAlloc(void)
{
ULONG ulRC;
ULONG ulRC;
if ( ( cTLSAlloc == 0 ) || ( ppSDLTLSData == NULL ) )
{
// First call - allocate the thread local memory (1 DWORD).
ulRC = DosAllocThreadLocalMemory( 1, (PULONG *)&ppSDLTLSData );
if ( ulRC != NO_ERROR )
debug( "DosAllocThreadLocalMemory() failed, rc = %u", ulRC );
}
cTLSAlloc++;
if (cTLSAlloc == 0 || ppSDLTLSData == NULL) {
/* First call - allocate the thread local memory (1 DWORD) */
ulRC = DosAllocThreadLocalMemory(1, (PULONG *)&ppSDLTLSData);
if (ulRC != NO_ERROR) {
debug_os2("DosAllocThreadLocalMemory() failed, rc = %u", ulRC);
}
}
cTLSAlloc++;
}
// SDL_OS2TLSFree() called from SDL_QuitSubSystem()
void SDL_OS2TLSFree()
/* SDL_OS2TLSFree() called from SDL_QuitSubSystem() */
void SDL_OS2TLSFree(void)
{
ULONG ulRC;
ULONG ulRC;
if ( cTLSAlloc != 0 )
cTLSAlloc--;
if (cTLSAlloc != 0)
cTLSAlloc--;
if ( ( cTLSAlloc == 0 ) && ( ppSDLTLSData != NULL ) )
{
// Last call - free the thread local memory.
ulRC = DosFreeThreadLocalMemory( (PULONG)ppSDLTLSData );
if ( ulRC != NO_ERROR )
debug( "DosFreeThreadLocalMemory() failed, rc = %u", ulRC );
else
ppSDLTLSData = NULL;
}
if (cTLSAlloc == 0 && ppSDLTLSData != NULL) {
/* Last call - free the thread local memory */
ulRC = DosFreeThreadLocalMemory((PULONG)ppSDLTLSData);
if (ulRC != NO_ERROR) {
debug_os2("DosFreeThreadLocalMemory() failed, rc = %u", ulRC);
} else {
ppSDLTLSData = NULL;
}
}
}
SDL_TLSData *SDL_SYS_GetTLSData()
SDL_TLSData *SDL_SYS_GetTLSData(void)
{
return ppSDLTLSData == NULL ? NULL : *ppSDLTLSData;
return (ppSDLTLSData == NULL)? NULL : *ppSDLTLSData;
}
int SDL_SYS_SetTLSData(SDL_TLSData *data)
{
if ( ppSDLTLSData == NULL )
return -1;
if (!ppSDLTLSData)
return -1;
*ppSDLTLSData = data;
return 0;
*ppSDLTLSData = data;
return 0;
}
#endif /* SDL_THREAD_OS2 */