From 712a4e7cb3fbfc2fe5d97141bda870e0082be323 Mon Sep 17 00:00:00 2001 From: "mozilla%weilbacher.org" Date: Sun, 10 Dec 2006 08:53:03 +0000 Subject: [PATCH] [OS/2] Bug 351246: Load Mozilla into Highmem on OS/2. Part 1, changes to OS/2 only core code. r=abwillis1, sr=mkaply git-svn-id: svn://10.0.0.236/trunk@216818 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/gc/boehm/os_dep.c | 16 ++++++++++++++ .../base/src/nsMessengerOS2Integration.cpp | 12 ++++++++++ mozilla/toolkit/xre/nsNativeAppSupportOS2.cpp | 22 ++++++++++++++++++- mozilla/widget/src/os2/nsDragService.cpp | 14 ++++++++++++ mozilla/xpcom/io/nsLocalFileOS2.cpp | 7 ++++++ .../xpfe/bootstrap/nsNativeAppSupportOS2.cpp | 21 +++++++++++++++++- .../xpinstall/wizard/os2/uninstall/extra.c | 5 +++++ 7 files changed, 95 insertions(+), 2 deletions(-) diff --git a/mozilla/gc/boehm/os_dep.c b/mozilla/gc/boehm/os_dep.c index 612785d3f59..dd81002d34b 100644 --- a/mozilla/gc/boehm/os_dep.c +++ b/mozilla/gc/boehm/os_dep.c @@ -1110,11 +1110,27 @@ void * os2_alloc(size_t bytes) { void * result; +#ifdef MOZ_OS2_HIGH_MEMORY + APIRET rc = DosAllocMem(&result, bytes, PAG_EXECUTE | PAG_READ | + PAG_WRITE | PAG_COMMIT | OBJ_ANY); + if (rc != NO_ERROR) { /* Did the kernel handle OBJ_ANY? */ + /* Try again without OBJ_ANY and if the first failure was not caused + * by OBJ_ANY then we will get the same failure, else we have taken + * care of pre-FP13 systems where the kernel couldn't handle it. + */ + rc = DosAllocMem(&result, bytes, PAG_EXECUTE | PAG_READ | + PAG_WRITE | PAG_COMMIT); + if (rc != NO_ERROR) { + return(0); + } + } +#else if (DosAllocMem(&result, bytes, PAG_EXECUTE | PAG_READ | PAG_WRITE | PAG_COMMIT) != NO_ERROR) { return(0); } +#endif if (result == 0) return(os2_alloc(bytes)); return(result); } diff --git a/mozilla/mailnews/base/src/nsMessengerOS2Integration.cpp b/mozilla/mailnews/base/src/nsMessengerOS2Integration.cpp index 91d8282d320..64de361f789 100644 --- a/mozilla/mailnews/base/src/nsMessengerOS2Integration.cpp +++ b/mozilla/mailnews/base/src/nsMessengerOS2Integration.cpp @@ -56,8 +56,20 @@ nsMessengerOS2Integration::nsMessengerOS2Integration() PAG_READ | PAG_WRITE); if (rc != NO_ERROR) { +#ifdef MOZ_OS2_HIGH_MEMORY + rc = DosAllocSharedMem(&pvObject, WARPCENTER_SHAREDMEM, sizeof(ULONG), + PAG_COMMIT | PAG_WRITE | OBJ_ANY); + if (rc != NO_ERROR) { // Did the kernel handle OBJ_ANY? + // Try again without OBJ_ANY and if the first failure was not caused + // by OBJ_ANY then we will get the same failure, else we have taken + // care of pre-FP13 systems where the kernel couldn't handle it. + rc = DosAllocSharedMem(&pvObject, WARPCENTER_SHAREDMEM, sizeof(ULONG), + PAG_COMMIT | PAG_WRITE); + } +#else rc = DosAllocSharedMem(&pvObject, WARPCENTER_SHAREDMEM, sizeof(ULONG), PAG_COMMIT | PAG_WRITE); +#endif pUnreadState = (PULONG)pvObject; } *pUnreadState = 0; diff --git a/mozilla/toolkit/xre/nsNativeAppSupportOS2.cpp b/mozilla/toolkit/xre/nsNativeAppSupportOS2.cpp index 40aeb0dd462..683c2ee4d46 100644 --- a/mozilla/toolkit/xre/nsNativeAppSupportOS2.cpp +++ b/mozilla/toolkit/xre/nsNativeAppSupportOS2.cpp @@ -38,6 +38,11 @@ * * ***** END LICENSE BLOCK ***** */ +#ifdef MOZ_OS2_HIGH_MEMORY +// os2safe.h has to be included before os2.h, needed for high mem +#include +#endif + #define INCL_PM #define INCL_GPI #define INCL_DOS @@ -671,9 +676,24 @@ struct MessageWindow { return NS_ERROR_FAILURE; ULONG ulSize = sizeof(COPYDATASTRUCT)+strlen(cmd)+1+CCHMAXPATH; +#ifdef MOZ_OS2_HIGH_MEMORY + APIRET rc = DosAllocSharedMem( &pvData, NULL, ulSize, + PAG_COMMIT | PAG_READ | PAG_WRITE | OBJ_GETTABLE | OBJ_ANY); + if (rc != NO_ERROR) { // Did the kernel handle OBJ_ANY? + // Try again without OBJ_ANY and if the first failure was not caused + // by OBJ_ANY then we will get the same failure, else we have taken + // care of pre-FP13 systems where the kernel couldn't handle it. + rc = DosAllocSharedMem( &pvData, NULL, ulSize, + PAG_COMMIT | PAG_READ | PAG_WRITE | OBJ_GETTABLE); + if (rc != NO_ERROR) { + return NS_ERROR_OUT_OF_MEMORY; + } + } +#else if (DosAllocSharedMem( &pvData, NULL, ulSize, - (PAG_COMMIT|PAG_READ|PAG_WRITE|OBJ_GETTABLE))) + PAG_COMMIT | PAG_READ | PAG_WRITE | OBJ_GETTABLE | OBJ_ANY)) return NS_ERROR_OUT_OF_MEMORY; +#endif // We used to set dwData to zero, when we didn't send the // working dir. Now we're using it as a version number. diff --git a/mozilla/widget/src/os2/nsDragService.cpp b/mozilla/widget/src/os2/nsDragService.cpp index 9feb6a100a3..cbba566bb8e 100644 --- a/mozilla/widget/src/os2/nsDragService.cpp +++ b/mozilla/widget/src/os2/nsDragService.cpp @@ -1472,8 +1472,22 @@ nsresult RenderToDTShare( PDRAGITEM pditem, HWND hwnd) nsresult rv; void * pMem; +#ifdef MOZ_OS2_HIGH_MEMORY + APIRET rc = DosAllocSharedMem( &pMem, DTSHARE_NAME, 0x100000, + PAG_WRITE | PAG_READ | OBJ_ANY); + if (rc != NO_ERROR && + rc != ERROR_ALREADY_EXISTS) { // Did the kernel handle OBJ_ANY? + // Try again without OBJ_ANY and if the first failure was not caused + // by OBJ_ANY then we will get the same failure, else we have taken + // care of pre-FP13 systems where the kernel couldn't handle it. + rc = DosAllocSharedMem( &pMem, DTSHARE_NAME, 0x100000, + PAG_WRITE | PAG_READ); + } +#else APIRET rc = DosAllocSharedMem( &pMem, DTSHARE_NAME, 0x100000, PAG_WRITE | PAG_READ); +#endif + if (rc == ERROR_ALREADY_EXISTS) rc = DosGetNamedSharedMem( &pMem, DTSHARE_NAME, PAG_WRITE | PAG_READ); diff --git a/mozilla/xpcom/io/nsLocalFileOS2.cpp b/mozilla/xpcom/io/nsLocalFileOS2.cpp index a186cb24852..b442b7fbf1e 100644 --- a/mozilla/xpcom/io/nsLocalFileOS2.cpp +++ b/mozilla/xpcom/io/nsLocalFileOS2.cpp @@ -2113,7 +2113,14 @@ nsLocalFile::IsExecutable(PRBool *_retval) return NS_OK; // upper-case the extension, then see if it claims to be an executable +#ifdef MOZ_OS2_HIGH_MEMORY + // WinUpper() cannot be used because it crashes with high memory. + // strupr() does not take into account non-ASCII characters but this is + // irrelevant for the possible extensions below + strupr(ext); +#else WinUpper(0, 0, 0, ext); +#endif if (strcmp(ext, ".EXE") == 0 || strcmp(ext, ".CMD") == 0 || strcmp(ext, ".COM") == 0 || diff --git a/mozilla/xpfe/bootstrap/nsNativeAppSupportOS2.cpp b/mozilla/xpfe/bootstrap/nsNativeAppSupportOS2.cpp index 67b4de85ba4..2b8456c6dd0 100644 --- a/mozilla/xpfe/bootstrap/nsNativeAppSupportOS2.cpp +++ b/mozilla/xpfe/bootstrap/nsNativeAppSupportOS2.cpp @@ -39,6 +39,11 @@ * * ***** END LICENSE BLOCK ***** */ +#ifdef MOZ_OS2_HIGH_MEMORY +// os2safe.h has to be included before os2.h, needed for high mem +#include +#endif + #define INCL_PM #define INCL_GPI #define INCL_DOS @@ -1146,8 +1151,22 @@ struct MessageWindow { APIRET rc = NO_ERROR; PVOID pvData = NULL; ULONG ulSize = sizeof(COPYDATASTRUCT)+strlen(cmd)+1; +#ifdef MOZ_OS2_HIGH_MEMORY rc = DosAllocSharedMem( &pvData, NULL, ulSize, - (PAG_COMMIT|PAG_READ|PAG_WRITE|OBJ_GETTABLE) ); + PAG_COMMIT | PAG_READ | PAG_WRITE | OBJ_GETTABLE | OBJ_ANY); + if( rc != NO_ERROR ) // Did the kernel handle OBJ_ANY? + { + // Try again without OBJ_ANY and if the first failure was not caused + // by OBJ_ANY then we will get the same failure, else we have taken + // care of pre-FP13 systems where the kernel couldn't handle it. + rc = DosAllocSharedMem( &pvData, NULL, ulSize, + PAG_COMMIT | PAG_READ | PAG_WRITE | OBJ_GETTABLE); + } +#else + rc = DosAllocSharedMem( &pvData, NULL, ulSize, + PAG_COMMIT | PAG_READ | PAG_WRITE | OBJ_GETTABLE); +#endif + if( rc != NO_ERROR ) { diff --git a/mozilla/xpinstall/wizard/os2/uninstall/extra.c b/mozilla/xpinstall/wizard/os2/uninstall/extra.c index e58141b9c30..89fa5f0a57e 100644 --- a/mozilla/xpinstall/wizard/os2/uninstall/extra.c +++ b/mozilla/xpinstall/wizard/os2/uninstall/extra.c @@ -37,6 +37,11 @@ * * ***** END LICENSE BLOCK ***** */ +#ifdef MOZ_OS2_HIGH_MEMORY +/* os2safe.h has to be included before os2.h, needed for high mem */ +#include +#endif + #include "extern.h" #include "extra.h" #include "parser.h"