BeOS changes

This commit is contained in:
mcafee%netscape.com 1999-06-29 10:27:58 +00:00
parent 6c052fb7e8
commit 7f42e390e5
13 changed files with 201 additions and 18 deletions

View File

@ -20,6 +20,11 @@
#include "prlog.h"
#include "prinit.h"
#if defined(XP_BEOS)
/* For DEBUGGER macros */
#include <Debug.h>
#endif
#if defined(XP_UNIX)
/* for abort() */
#include <stdlib.h>
@ -96,6 +101,12 @@ NS_COM void nsDebug::Abort(const char* aFile, PRIntn aLine)
ExitToShell();
#elif defined(XP_UNIX)
PR_Abort();
#elif defined(XP_BEOS)
{
char buf[2000];
sprintf(buf, "Abort: at file %s, line %d", aFile, aLine);
DEBUGGER(buf);
}
#endif
}
@ -110,6 +121,12 @@ NS_COM void nsDebug::Break(const char* aFile, PRIntn aLine)
::DebugBreak();
#elif defined(XP_UNIX) && !defined(UNIX_CRASH_ON_ASSERT)
fprintf(stderr, "\07"); fflush(stderr);
#elif defined(XP_BEOS)
{
char buf[2000];
sprintf(buf, "Break: at file %s, line %d", aFile, aLine);
DEBUGGER(buf);
}
#else
Abort(aFile, aLine);
#endif

View File

@ -65,6 +65,10 @@ EXTRA_DSO_LDOPTS = \
$(MKSHLIB_UNFORCE_ALL)
endif
ifeq ($(OS_ARCH),BeOS)
EXTRA_DSO_LDOPTS += -lbe
endif
include $(topsrcdir)/config/rules.mk
ifeq ($(OS_ARCH),HP-UX)

View File

@ -33,6 +33,11 @@
#include "prcmon.h"
#include "prthread.h" /* XXX: only used for the NSPR initialization hack (rick) */
#ifdef XP_BEOS
#include <FindDirectory.h>
#include <Path.h>
#endif
// Logging of debug output
#define FORCE_PR_LOG /* Allow logging in the release build */
#include "prlog.h"
@ -255,7 +260,23 @@ nsComponentManagerImpl::PlatformInit(void)
}
}
#endif /* XP_UNIX */
#ifdef XP_BEOS
BPath p;
const char *settings = "/boot/home/config/settings";
if(find_directory(B_USER_SETTINGS_DIRECTORY, &p) == B_OK)
settings = p.Path();
char settingsMozillaDir[1024];
PR_snprintf(settingsMozillaDir, sizeof(settingsMozillaDir),
"%s/" NS_MOZILLA_DIR_NAME, settings);
if (PR_Access(settingsMozillaDir, PR_ACCESS_EXISTS) != PR_SUCCESS) {
PR_MkDir(settingsMozillaDir, NS_MOZILLA_DIR_PERMISSION);
printf("nsComponentManager: Creating Directory %s\n", settingsMozillaDir);
PR_LOG(nsComponentManagerLog, PR_LOG_ALWAYS,
("nsComponentManager: Creating Directory %s", settingsMozillaDir));
}
#endif
// Open the App Components registry. We will keep it open forever!
rv = mRegistry->OpenWellKnownRegistry(nsIRegistry::ApplicationComponentRegistry);
if (NS_FAILED(rv)) return rv;
@ -1534,7 +1555,7 @@ nsComponentManagerImpl::UnregisterComponent(const nsCID &aClass,
if (old != NULL && old->dll != NULL)
{
if (old->dll->GetPersistentDescriptorString() != NULL &&
#ifdef XP_UNIX
#if defined(XP_UNIX) || defined(XP_BEOS)
PL_strcasecmp(old->dll->GetPersistentDescriptorString(), aLibrary)
#else
PL_strcmp(old->dll->GetPersistentDescriptorString(), aLibrary)

View File

@ -201,6 +201,11 @@ protected:
#define NS_MOZILLA_DIR_PERMISSION 00700
#endif /* XP_UNIX */
#ifdef XP_BEOS
#define NS_MOZILLA_DIR_NAME "mozilla"
#define NS_MOZILLA_DIR_PERMISSION 00700
#endif /* XP_BEOS */
/**
* When using the registry we put a version number in it.
* If the version number that is in the registry doesn't match

View File

@ -39,7 +39,7 @@
# define NS_LINEBREAK "\015\012"
# define NS_LINEBREAK_LEN 2
# else
# ifdef XP_UNIX
# if defined(XP_UNIX) || defined(XP_BEOS)
# define NS_LINEBREAK "\012"
# define NS_LINEBREAK_LEN 1
# endif /* XP_UNIX */

View File

@ -23,6 +23,8 @@
#include <windows.h>
#elif defined(XP_MAC)
#include <stdlib.h>
#elif defined(XP_BEOS)
#include <fcntl.h>
#elif defined(XP_UNIX)
#include <sys/mman.h>
#include <fcntl.h>
@ -278,7 +280,36 @@ nsPageMgr::InitPages(nsPageCount minPages, nsPageCount maxPages)
TempDisposeHandle(h, &err);
}
return PR_FAILURE;
#elif defined(XP_BEOS)
nsPage* addr = NULL;
nsPageCount size = maxPages;
#if (1L<<NS_PAGEMGR_PAGE_BITS) != B_PAGE_SIZE
#error can only work with 4096 byte pages
#endif
while(addr == NULL)
{
/* let the system place the heap */
if((mAid = create_area("MozillaHeap", (void **)&addr, B_ANY_ADDRESS,
size << NS_PAGEMGR_PAGE_BITS, B_NO_LOCK,
B_READ_AREA | B_WRITE_AREA)) < 0)
{
addr = NULL;
size--;
if (size < minPages) {
return PR_FAILURE;
}
}
}
PR_ASSERT(NS_PAGEMGR_IS_ALIGNED(addr, NS_PAGEMGR_PAGE_BITS));
mMemoryBase = addr;
mPageCount = size;
mBoundary = addr;
return PR_SUCCESS;
#else
nsPage* addr = NULL;
@ -334,6 +365,10 @@ nsPageMgr::FinalizePages()
}
}
#elif defined(XP_BEOS)
delete_area(mAid);
#else
munmap((caddr_t)mMemoryBase, mPageCount << NS_PAGEMGR_PAGE_BITS);
#endif
@ -366,6 +401,9 @@ nsPageMgr::nsPageMgr()
mSegMap(nsnull),
mSegTable(nsnull),
mSegTableCount(0),
#endif
#if defined(XP_BEOS)
mAid(B_ERROR),
#endif
mPageCount(0)
{

View File

@ -25,11 +25,16 @@
#include "nscore.h"
#include "nsAutoLock.h"
#include "prlog.h"
#ifdef XP_MAC
#include <Types.h>
#include <Memory.h>
#endif
#if defined(XP_BEOS)
#include <OS.h>
#endif
/*******************************************************************************
* Configuration/Debugging parameters:
******************************************************************************/
@ -182,6 +187,10 @@ class nsPageMgr : public nsIPageManager, public nsIAllocator {
nsSegmentDesc* mSegTable;
PRWord mSegTableCount;
#endif
#if defined(XP_BEOS)
area_id mAid;
#endif
};
/******************************************************************************/

View File

@ -20,6 +20,11 @@
#include "prlog.h"
#include "prinit.h"
#if defined(XP_BEOS)
/* For DEBUGGER macros */
#include <Debug.h>
#endif
#if defined(XP_UNIX)
/* for abort() */
#include <stdlib.h>
@ -96,6 +101,12 @@ NS_COM void nsDebug::Abort(const char* aFile, PRIntn aLine)
ExitToShell();
#elif defined(XP_UNIX)
PR_Abort();
#elif defined(XP_BEOS)
{
char buf[2000];
sprintf(buf, "Abort: at file %s, line %d", aFile, aLine);
DEBUGGER(buf);
}
#endif
}
@ -110,6 +121,12 @@ NS_COM void nsDebug::Break(const char* aFile, PRIntn aLine)
::DebugBreak();
#elif defined(XP_UNIX) && !defined(UNIX_CRASH_ON_ASSERT)
fprintf(stderr, "\07"); fflush(stderr);
#elif defined(XP_BEOS)
{
char buf[2000];
sprintf(buf, "Break: at file %s, line %d", aFile, aLine);
DEBUGGER(buf);
}
#else
Abort(aFile, aLine);
#endif

View File

@ -361,7 +361,7 @@ char* nsSimpleCharString::GetLeaf(char inSeparator) const
return result;
} // nsSimpleCharString::GetLeaf
#if defined(XP_UNIX) || defined(XP_PC)
#if defined(XP_UNIX) || defined(XP_PC) || defined(XP_BEOS)
//----------------------------------------------------------------------------------------
void nsFileSpecHelpers::MakeAllDirectories(const char* inPath, int mode)
@ -440,6 +440,8 @@ void nsFileSpecHelpers::MakeAllDirectories(const char* inPath, int mode)
#include "nsFileSpecWin.cpp" // Windows-specific implementations
#elif defined(XP_MAC)
#include "nsFileSpecMac.cpp" // Macintosh-specific implementations
#elif defined(XP_BEOS)
#include "nsFileSpecBeOS.cpp" // BeOS-specific implementations
#elif defined(XP_UNIX)
#include "nsFileSpecUnix.cpp" // Unix-specific implementations
#endif
@ -664,7 +666,7 @@ nsFilePath::nsFilePath(const nsFileURL& inOther)
}
#endif
#ifdef XP_UNIX
#if defined XP_UNIX || defined XP_BEOS
//----------------------------------------------------------------------------------------
nsFilePath::nsFilePath(const nsFileSpec& inOther)
//----------------------------------------------------------------------------------------
@ -679,7 +681,7 @@ nsFilePath::~nsFilePath()
{
}
#ifdef XP_UNIX
#if defined XP_UNIX || defined XP_BEOS
//----------------------------------------------------------------------------------------
void nsFilePath::operator = (const nsFileSpec& inOther)
//----------------------------------------------------------------------------------------
@ -859,7 +861,7 @@ void nsFileSpec::operator = (const nsPersistentFileDescriptor& inDescriptor)
// UNIX & WIN nsFileSpec implementation
//========================================================================================
#ifdef XP_UNIX
#if defined XP_UNIX || defined XP_BEOS
//----------------------------------------------------------------------------------------
nsFileSpec::nsFileSpec(const nsFilePath& inPath)
//----------------------------------------------------------------------------------------
@ -869,7 +871,7 @@ nsFileSpec::nsFileSpec(const nsFilePath& inPath)
}
#endif // XP_UNIX
#ifdef XP_UNIX
#if defined XP_UNIX || defined XP_BEOS
//----------------------------------------------------------------------------------------
void nsFileSpec::operator = (const nsFilePath& inPath)
//----------------------------------------------------------------------------------------
@ -879,7 +881,7 @@ void nsFileSpec::operator = (const nsFilePath& inPath)
}
#endif //XP_UNIX
#if defined(XP_UNIX) || defined(XP_PC)
#if defined(XP_UNIX) || defined(XP_PC) || defined(XP_BEOS)
//----------------------------------------------------------------------------------------
nsFileSpec::nsFileSpec(const nsFileSpec& inSpec)
//----------------------------------------------------------------------------------------
@ -889,7 +891,7 @@ nsFileSpec::nsFileSpec(const nsFileSpec& inSpec)
}
#endif //XP_UNIX
#if defined(XP_UNIX) || defined(XP_PC)
#if defined(XP_UNIX) || defined(XP_PC) || defined(XP_BEOS)
//----------------------------------------------------------------------------------------
nsFileSpec::nsFileSpec(const char* inString, PRBool inCreateDirs)
//----------------------------------------------------------------------------------------
@ -901,7 +903,7 @@ nsFileSpec::nsFileSpec(const char* inString, PRBool inCreateDirs)
}
#endif //XP_UNIX,PC
#if defined(XP_UNIX) || defined(XP_PC)
#if defined(XP_UNIX) || defined(XP_PC) || defined(XP_BEOS)
//----------------------------------------------------------------------------------------
nsFileSpec::nsFileSpec(const nsString& inString, PRBool inCreateDirs)
//----------------------------------------------------------------------------------------
@ -919,7 +921,7 @@ nsFileSpec::~nsFileSpec()
{
}
#if defined(XP_UNIX) || defined(XP_PC)
#if defined(XP_UNIX) || defined(XP_PC) || defined(XP_BEOS)
//----------------------------------------------------------------------------------------
void nsFileSpec::operator = (const nsFileSpec& inSpec)
//----------------------------------------------------------------------------------------
@ -930,7 +932,7 @@ void nsFileSpec::operator = (const nsFileSpec& inSpec)
#endif //XP_UNIX
#if defined(XP_UNIX) || defined(XP_PC)
#if defined(XP_UNIX) || defined(XP_PC) || defined(XP_BEOS)
//----------------------------------------------------------------------------------------
void nsFileSpec::operator = (const char* inString)
//----------------------------------------------------------------------------------------

View File

@ -138,7 +138,7 @@
#ifdef XP_MAC
#include <Files.h>
#elif defined(XP_UNIX) || defined (XP_OS2)
#elif defined(XP_UNIX) || defined (XP_OS2) || defined(XP_BEOS)
#include <dirent.h>
#elif defined(XP_PC)
#include "prio.h"
@ -709,7 +709,7 @@ class NS_COM nsDirectoryIterator
nsFileSpec mCurrent;
PRBool mExists;
#if defined(XP_UNIX)
#if defined(XP_UNIX) || defined(XP_BEOS)
DIR* mDir;
#elif defined(XP_PC)
PRDir* mDir; // XXX why not use PRDir for Unix too?

View File

@ -40,6 +40,14 @@
#include <stdlib.h>
#include <sys/param.h>
#include "prenv.h"
#elif defined(XP_BEOS)
#include <FindDirectory.h>
#include <Path.h>
#include <unistd.h>
#include <stdlib.h>
#include <sys/param.h>
#include <OS.h>
#include <image.h>
#endif
#include "plstr.h"
@ -194,6 +202,33 @@ static void GetCurrentProcessDirectory(nsFileSpec& aFileSpec)
}
}
#elif defined(XP_BEOS)
char *moz5 = getenv("MOZILLA_FIVE_HOME");
if (moz5)
{
aFileSpec = moz5;
return;
}
else
{
static char buf[MAXPATHLEN];
int32 cookie = 0;
image_info info;
char *p;
*buf = 0;
if(get_next_image_info(0, &cookie, &info) == B_OK)
{
strcpy(buf, info.name);
if((p = strrchr(buf, '/')) != 0)
{
*p = 0;
aFileSpec = buf;
return;
}
}
}
#endif
NS_ERROR("unable to get current process directory");
@ -258,7 +293,7 @@ void nsSpecialSystemDirectory::operator = (SystemDirectories aSystemSystemDirect
#elif defined(XP_MAC)
*this = kTemporaryFolderType;
#elif defined(XP_UNIX)
#elif defined(XP_UNIX) || defined(XP_BEOS)
*this = "/tmp/";
#endif
break;
@ -529,6 +564,37 @@ void nsSpecialSystemDirectory::operator = (SystemDirectories aSystemSystemDirect
#endif
#ifdef XP_BEOS
case BeOS_SettingsDirectory:
{
BPath p;
if(find_directory(B_USER_SETTINGS_DIRECTORY, &p) == B_OK)
*this = p.Path();
else
*this = "/boot/home/config/settings";
break;
}
case BeOS_HomeDirectory:
{
BPath p;
if(find_directory(B_USER_DIRECTORY, &p) == B_OK)
*this = p.Path();
else
*this = "/boot/home";
break;
}
case BeOS_DesktopDirectory:
{
BPath p;
if(find_directory(B_DESKTOP_DIRECTORY, &p) == B_OK)
*this = p.Path();
else
*this = "/boot/home/Desktop";
}
#endif
default:
break;
}

View File

@ -93,6 +93,10 @@ class NS_COM nsSpecialSystemDirectory : public nsFileSpec
, Unix_LocalDirectory = 301
, Unix_LibDirectory = 302
, Unix_HomeDirectory = 303
, BeOS_SettingsDirectory = 401
, BeOS_HomeDirectory = 402
, BeOS_DesktopDirectory = 403
};
//nsSpecialSystemDirectory();

View File

@ -641,7 +641,7 @@ POS_TYPE FILE_BUFFER_TYPE::seekpos(pos_type sp, IOS_BASE::openmode)
{
if (!mFileDesc || sp==pos_type(-1))
return -1;
#if defined(XP_PC) || defined(XP_UNIX)
#if defined(XP_PC) || defined(XP_UNIX) || defined(XP_BEOS)
PRInt32 position = sp;
#else
PRInt32 position = sp.offset();