From cee0250e5f3f9d5561817a0d047f68ba490313c4 Mon Sep 17 00:00:00 2001 From: Ozkan Sezer Date: Sat, 24 Mar 2018 22:25:33 +0300 Subject: [PATCH] OS/2 fixes: - update SDL_platform.h to handle __EMX__ - update SDL_config_os2.h - fix a typo in SDL_dart.c (bitwise AND, not logical AND) - fix NULL / NULLHANDLE confusion in SDL_sysloadso.c and SDL_os2fslib.c --- include/SDL_config_os2.h | 19 ++++--------------- include/SDL_platform.h | 2 +- src/audio/dart/SDL_dart.c | 2 +- src/loadso/os2/SDL_sysloadso.c | 9 +++++---- src/video/os2fslib/SDL_os2fslib.c | 30 +++++++++++++++--------------- 5 files changed, 26 insertions(+), 36 deletions(-) diff --git a/include/SDL_config_os2.h b/include/SDL_config_os2.h index 42edd20e8..0342c8181 100644 --- a/include/SDL_config_os2.h +++ b/include/SDL_config_os2.h @@ -27,17 +27,6 @@ /* This is a set of defines to configure the SDL features */ -typedef signed char int8_t; -typedef unsigned char uint8_t; -typedef signed short int16_t; -typedef unsigned short uint16_t; -typedef signed int int32_t; -typedef unsigned int uint32_t; -typedef unsigned int size_t; -typedef unsigned long uintptr_t; -typedef signed long long int64_t; -typedef unsigned long long uint64_t; - #define SDL_HAS_64BIT_TYPE 1 /* Use Watcom's LIBC */ @@ -67,7 +56,6 @@ typedef unsigned long long uint64_t; #define HAVE_ALLOCA 1 #define HAVE_GETENV 1 #define HAVE_PUTENV 1 -#define HAVE_UNSETENV 1 #define HAVE_QSORT 1 #define HAVE_ABS 1 #define HAVE_BCOPY 1 @@ -89,12 +77,13 @@ typedef unsigned long long uint64_t; #define HAVE_STRSTR 1 #define HAVE_ITOA 1 #define HAVE__LTOA 1 -#define HAVE__UITOA 1 #define HAVE__ULTOA 1 #define HAVE_STRTOL 1 +#define HAVE_STRTOUL 1 #define HAVE__I64TOA 1 #define HAVE__UI64TOA 1 #define HAVE_STRTOLL 1 +#define HAVE_STRTOULL 1 #define HAVE_STRTOD 1 #define HAVE_ATOI 1 #define HAVE_ATOF 1 @@ -102,11 +91,11 @@ typedef unsigned long long uint64_t; #define HAVE_STRNCMP 1 #define HAVE_STRICMP 1 #define HAVE_STRCASECMP 1 +#define HAVE_STRNCASECMP 1 #define HAVE_SSCANF 1 #define HAVE_SNPRINTF 1 #define HAVE_VSNPRINTF 1 #define HAVE_SETJMP 1 -#define HAVE_CLOCK_GETTIME 1 /* Enable various audio drivers */ #define SDL_AUDIO_DRIVER_DART 1 @@ -133,7 +122,7 @@ typedef unsigned long long uint64_t; #define SDL_VIDEO_DRIVER_OS2FS 1 /* Enable OpenGL support */ -/* Nothing here yet for OS/2... :( */ +/* Nothing yet for OS/2. */ /* Enable assembly routines where available */ #define SDL_ASSEMBLY_ROUTINES 1 diff --git a/include/SDL_platform.h b/include/SDL_platform.h index 48540a85d..bcbd7b666 100644 --- a/include/SDL_platform.h +++ b/include/SDL_platform.h @@ -82,7 +82,7 @@ #undef __OPENBSD__ #define __OPENBSD__ 1 #endif -#if defined(__OS2__) +#if defined(__OS2__) || defined(__EMX__) #undef __OS2__ #define __OS2__ 1 #endif diff --git a/src/audio/dart/SDL_dart.c b/src/audio/dart/SDL_dart.c index 77e530db5..cc7e73953 100644 --- a/src/audio/dart/SDL_dart.c +++ b/src/audio/dart/SDL_dart.c @@ -48,7 +48,7 @@ LONG APIENTRY DARTEventFunc(ULONG ulStatus, PMCI_MIX_BUFFER pBuffer, ULONG ulFlags) { - if (ulFlags && MIX_WRITE_COMPLETE) + if (ulFlags & MIX_WRITE_COMPLETE) { // Playback of buffer completed! // Get pointer to buffer description diff --git a/src/loadso/os2/SDL_sysloadso.c b/src/loadso/os2/SDL_sysloadso.c index 62ea536dd..c2d991175 100644 --- a/src/loadso/os2/SDL_sysloadso.c +++ b/src/loadso/os2/SDL_sysloadso.c @@ -35,12 +35,12 @@ void *SDL_LoadObject(const char *sofile) { - HMODULE handle = NULL; + HMODULE handle = NULLHANDLE; char buf[512]; APIRET ulrc = DosLoadModule(buf, sizeof (buf), (char *) sofile, &handle); /* Generate an error message if all loads failed */ - if ((ulrc != NO_ERROR) || (handle == NULL)) + if ((ulrc != NO_ERROR) || (handle == NULLHANDLE)) SDL_SetError("Failed loading %s: %s", sofile, buf); return((void *) handle); @@ -49,8 +49,9 @@ void *SDL_LoadObject(const char *sofile) void *SDL_LoadFunction(void *handle, const char *name) { const char *loaderror = "Unknown error"; - void *symbol = NULL; + PFN symbol = NULL; APIRET ulrc = DosQueryProcAddr((HMODULE)handle, 0, (char *)name, &symbol); + if (ulrc == ERROR_INVALID_HANDLE) loaderror = "Invalid module handle"; else if (ulrc == ERROR_INVALID_NAME) @@ -59,7 +60,7 @@ void *SDL_LoadFunction(void *handle, const char *name) if (symbol == NULL) SDL_SetError("Failed loading %s: %s", name, loaderror); - return(symbol); + return((void *) symbol); } void SDL_UnloadObject(void *handle) diff --git a/src/video/os2fslib/SDL_os2fslib.c b/src/video/os2fslib/SDL_os2fslib.c index a902d1fe7..21d940b33 100644 --- a/src/video/os2fslib/SDL_os2fslib.c +++ b/src/video/os2fslib/SDL_os2fslib.c @@ -48,8 +48,8 @@ static ULONG ulFCFToUse = static int bMouseCaptured = 0; static int bMouseCapturable = 0; -static HPOINTER hptrGlobalPointer = NULL; -static HPOINTER hptrCurrentIcon = NULL; +static HPOINTER hptrGlobalPointer = NULLHANDLE; +static HPOINTER hptrCurrentIcon = NULLHANDLE; static int iWindowSizeX = 320; static int iWindowSizeY = 200; static int bWindowResized = 0; @@ -180,7 +180,7 @@ static UniChar NativeCharToUniChar(int chcode) int rc; UconvObject ucoTemp; char achFrom[2]; - char *pchFrom; + void *pchFrom; size_t iFromCount; UniChar aucTo[10]; UniChar *pucTo; @@ -636,7 +636,7 @@ static MRESULT EXPENTRY WndProc( HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) bWindowResized = 1; // Make sure the window will be redrawn - WinInvalidateRegion(hwnd, NULL, TRUE); + WinInvalidateRegion(hwnd, NULLHANDLE, TRUE); } break; @@ -725,7 +725,7 @@ static MRESULT EXPENTRY WndProc( HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) if ((pVideo->hidden->iMouseVisible) && (!bMouseCaptured)) WinSetPointer(HWND_DESKTOP, WinQuerySysPointer(HWND_DESKTOP, SPTR_ARROW, FALSE)); else - WinSetPointer(HWND_DESKTOP, NULL); + WinSetPointer(HWND_DESKTOP, NULLHANDLE); if (bMouseCapturable) { @@ -782,7 +782,7 @@ static MRESULT EXPENTRY WndProc( HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) if (!bMouseCaptured) { WinSetCapture(HWND_DESKTOP, hwnd); - WinSetPointer(HWND_DESKTOP, NULL); + WinSetPointer(HWND_DESKTOP, NULLHANDLE); bMouseCaptured = 1; { SWP swpClient; @@ -826,7 +826,7 @@ static MRESULT EXPENTRY WndProc( HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) if (!bMouseCaptured) { WinSetCapture(HWND_DESKTOP, hwnd); - WinSetPointer(HWND_DESKTOP, NULL); + WinSetPointer(HWND_DESKTOP, NULLHANDLE); bMouseCaptured = 1; { SWP swpClient; @@ -871,7 +871,7 @@ static MRESULT EXPENTRY WndProc( HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) if (!bMouseCaptured) { WinSetCapture(HWND_DESKTOP, hwnd); - WinSetPointer(HWND_DESKTOP, NULL); + WinSetPointer(HWND_DESKTOP, NULLHANDLE); bMouseCaptured = 1; { SWP swpClient; @@ -957,7 +957,7 @@ static MRESULT EXPENTRY WndProc( HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) } else { - WinSetPointer(HWND_DESKTOP, NULL); + WinSetPointer(HWND_DESKTOP, NULLHANDLE); } } #ifdef DEBUG_BUILD @@ -1257,7 +1257,7 @@ static void PMThreadFunc(void *pParm) bMouseCaptured = 0; } // Destroy our window - WinDestroyWindow(pVideo->hidden->hwndFrame); pVideo->hidden->hwndFrame=NULL; + WinDestroyWindow(pVideo->hidden->hwndFrame); pVideo->hidden->hwndFrame=NULLHANDLE; // Show pointer to make sure it will not be left hidden. WinSetPointer(HWND_DESKTOP, WinQuerySysPointer(HWND_DESKTOP, SPTR_ARROW, FALSE)); WinShowPointer(HWND_DESKTOP, TRUE); @@ -1475,7 +1475,7 @@ int os2fslib_ShowWMCursor(_THIS, WMcursor *cursor) else { WinSetPointer(HWND_DESKTOP, FALSE); - hptrGlobalPointer = NULL; + hptrGlobalPointer = NULLHANDLE; _this->hidden->iMouseVisible = 0; } @@ -1610,7 +1610,7 @@ static void os2fslib_DestroyIcon(HWND hwndFrame) if (hptrCurrentIcon) { WinDestroyPointer(hptrCurrentIcon); - hptrCurrentIcon = NULL; + hptrCurrentIcon = NULLHANDLE; WinSendMsg(hwndFrame, WM_SETICON, @@ -2256,7 +2256,7 @@ static void os2fslib_VideoQuit(_THIS) printf("[os2fslib_VideoQuit] : Destroying PM window!\n"); fflush(stdout); #endif - WinDestroyWindow(_this->hidden->hwndFrame); _this->hidden->hwndFrame=NULL; + WinDestroyWindow(_this->hidden->hwndFrame); _this->hidden->hwndFrame=NULLHANDLE; } } @@ -2280,7 +2280,7 @@ static void os2fslib_VideoQuit(_THIS) if (hptrCurrentIcon) { WinDestroyPointer(hptrCurrentIcon); - hptrCurrentIcon = NULL; + hptrCurrentIcon = NULLHANDLE; } } @@ -2564,7 +2564,7 @@ static SDL_Surface *os2fslib_SetVideoMode(_THIS, SDL_Surface *current, } // Redraw window - WinInvalidateRegion(_this->hidden->hwndClient, NULL, TRUE); + WinInvalidateRegion(_this->hidden->hwndClient, NULLHANDLE, TRUE); // Now destroy the message queue, if we've created it! if (ERRORIDERROR(hmqerror)==0)