diff options
author | wtc%netscape.com <devnull@localhost> | 1999-01-26 01:56:55 +0000 |
---|---|---|
committer | wtc%netscape.com <devnull@localhost> | 1999-01-26 01:56:55 +0000 |
commit | ae64f054e7eea5b4d86697e36e38aaa33b7ba435 (patch) | |
tree | ae4fc780cee6d9623176f60cce09b1a00f0ff37d | |
parent | 4e4a4d306e70e0b958854e856ed7d9a9783a9831 (diff) | |
download | nspr-hg-ae64f054e7eea5b4d86697e36e38aaa33b7ba435.tar.gz |
Merged first batch of BeOS port patches contributed by
Matthew Zahorik <maz@albany.net>.
-rw-r--r-- | config/now.c | 6 | ||||
-rw-r--r-- | config/nsinstall.c | 13 | ||||
-rw-r--r-- | lib/ds/plevent.c | 10 | ||||
-rw-r--r-- | pr/include/md/Makefile | 4 | ||||
-rw-r--r-- | pr/include/md/_pth.h | 8 | ||||
-rw-r--r-- | pr/include/md/prosdep.h | 7 | ||||
-rw-r--r-- | pr/include/prinet.h | 5 | ||||
-rw-r--r-- | pr/include/prio.h | 8 | ||||
-rw-r--r-- | pr/include/private/primpl.h | 51 | ||||
-rw-r--r-- | pr/include/prtypes.h | 14 | ||||
-rw-r--r-- | pr/src/Makefile | 20 | ||||
-rw-r--r-- | pr/src/io/prfile.c | 5 | ||||
-rw-r--r-- | pr/src/io/prlog.c | 9 | ||||
-rw-r--r-- | pr/src/io/prmapopt.c | 22 | ||||
-rw-r--r-- | pr/src/io/prsocket.c | 20 | ||||
-rw-r--r-- | pr/src/linking/prlink.c | 45 | ||||
-rw-r--r-- | pr/src/md/Makefile | 6 | ||||
-rw-r--r-- | pr/src/md/prosdep.c | 7 | ||||
-rw-r--r-- | pr/src/misc/prinit.c | 16 | ||||
-rw-r--r-- | pr/src/misc/prtime.c | 2 | ||||
-rw-r--r-- | pr/src/threads/Makefile | 11 | ||||
-rw-r--r-- | pr/tests/op_filok.c | 2 |
22 files changed, 250 insertions, 41 deletions
diff --git a/config/now.c b/config/now.c index 55952eae..d4e8aff9 100644 --- a/config/now.c +++ b/config/now.c @@ -19,7 +19,7 @@ #include <stdio.h> #include <stdlib.h> -#if defined(XP_UNIX) || defined(XP_OS2_EMX) +#if defined(XP_UNIX) || defined(XP_OS2_EMX) || defined(XP_BEOS) #include <sys/time.h> #elif defined(WIN32) || defined(XP_OS2_VACPP) #include <sys/timeb.h> @@ -41,7 +41,7 @@ int main(int argc, char **argv) * of this program and omit the library build time * in PRVersionDescription. */ -#elif defined(XP_UNIX) || defined(XP_OS2_EMX) +#elif defined(XP_UNIX) || defined(XP_OS2_EMX) || defined(XP_BEOS) long long now; struct timeval tv; #ifdef HAVE_SVID_GETTOD @@ -52,6 +52,8 @@ int main(int argc, char **argv) now = ((1000000LL) * tv.tv_sec) + (long long)tv.tv_usec; #if defined(OSF1) fprintf(stdout, "%ld", now); +#elif defined(BEOS) && defined(__POWERPC__) + fprintf(stdout, "%Ld", now); /* Metroworks on BeOS PPC */ #else fprintf(stdout, "%lld", now); #endif diff --git a/config/nsinstall.c b/config/nsinstall.c index 18659d20..d90bd89f 100644 --- a/config/nsinstall.c +++ b/config/nsinstall.c @@ -45,10 +45,17 @@ #if defined(AIX) || defined(BSDI) || defined(HPUX) || defined(LINUX) \ || defined(SUNOS4) || defined(SCO) || defined(UNIXWARE) \ - || defined(RHAPSODY) || defined(NEXTSTEP) || defined(QNX) + || defined(RHAPSODY) || defined(NEXTSTEP) || defined(QNX) \ + || defined(BEOS) #undef HAVE_LCHOWN #endif +#define HAVE_FCHMOD + +#if defined(BEOS) +#undef HAVE_FCHMOD +#endif + /* * Does getcwd() take NULL as the first argument and malloc * the result buffer? @@ -357,7 +364,11 @@ main(int argc, char **argv) if (utime(toname, &utb) < 0) fail("cannot set times of %s", toname); } +#ifdef HAVE_FCHMOD if (fchmod(tofd, mode) < 0) +#else + if (chmod(toname, mode) < 0) +#endif fail("cannot change mode of %s", toname); if ((owner || group) && fchown(tofd, uid, gid) < 0) fail("cannot change owner of %s", toname); diff --git a/lib/ds/plevent.c b/lib/ds/plevent.c index b271a81e..1e331a23 100644 --- a/lib/ds/plevent.c +++ b/lib/ds/plevent.c @@ -646,6 +646,14 @@ _pl_NativeNotify(PLEventQueue* self) }/* --- end _pl_NativeNotify() --- */ #endif /* XP_UNIX */ +#if defined(XP_BEOS) +static PRStatus +_pl_NativeNotify(PLEventQueue* self) +{ + return PR_SUCCESS; /* Is this correct? */ +} +#endif /* XP_BEOS */ + #if defined(XP_MAC) static PRStatus _pl_NativeNotify(PLEventQueue* self) @@ -928,7 +936,7 @@ static void _md_CreateEventQueue( PLEventQueue *eventQueue ) } /* end _md_CreateEventQueue() */ #endif /* XP_OS2 */ -#if defined(XP_UNIX) || defined(XP_MAC) +#if defined(XP_UNIX) || defined(XP_MAC) || defined(XP_BEOS) /* ** _md_CreateEventQueue() -- ModelDependent initializer */ diff --git a/pr/include/md/Makefile b/pr/include/md/Makefile index 0c091b5b..cd91bc5e 100644 --- a/pr/include/md/Makefile +++ b/pr/include/md/Makefile @@ -131,6 +131,10 @@ ifeq ($(OS_ARCH),QNX) MDCPUCFG_H = _qnx.cfg endif +ifeq ($(OS_ARCH),BeOS) +MDCPUCFG_H = _beos.cfg +endif + export:: $(HEADERS) $(MDCPUCFG_H) $(INSTALL) -m 444 $(HEADERS) $(DIST)/include/md $(INSTALL) -m 444 $(MDCPUCFG_H) $(DIST)/include diff --git a/pr/include/md/_pth.h b/pr/include/md/_pth.h index 621eaf90..a54f8783 100644 --- a/pr/include/md/_pth.h +++ b/pr/include/md/_pth.h @@ -226,14 +226,6 @@ extern int (*_PT_aix_yield_fcn)(); #error "Need to define PTHREAD_YIELD for this platform" #endif -/* -** And when you really wanted hardcore locking w/o any fluff ... -** -** ... and why would you want that???? -*/ -#define _PR_LOCK_LOCK(_lock) pthread_mutex_lock(&_lock->mutex); -#define _PR_LOCK_UNLOCK(_lock) pthread_mutex_unlock(&_lock->mutex); - #define _MD_INIT_LOCKS() #endif /* nspr_pth_defs_h_ */ diff --git a/pr/include/md/prosdep.h b/pr/include/md/prosdep.h index a1aaac15..2b4eab6b 100644 --- a/pr/include/md/prosdep.h +++ b/pr/include/md/prosdep.h @@ -121,9 +121,14 @@ PR_BEGIN_EXTERN_C #include "md/_unixos.h" #include "md/_unix_errors.h" +#elif defined(XP_BEOS) + +#include "md/_beos.h" +#include "md/_unix_errors.h" + #else -#error "The platform is not Unix, Windows, or Mac" +#error "The platform is not BeOS, Unix, Windows, or Mac" #endif diff --git a/pr/include/prinet.h b/pr/include/prinet.h index 9ac10c20..5c89180d 100644 --- a/pr/include/prinet.h +++ b/pr/include/prinet.h @@ -40,14 +40,15 @@ #ifndef prinet_h__ #define prinet_h__ -#if defined(XP_UNIX) || defined(XP_OS2) +#if defined(XP_UNIX) || defined(XP_OS2) || defined(XP_BEOS) #include <sys/types.h> #include <sys/socket.h> /* AF_INET */ #include <netinet/in.h> /* INADDR_ANY, ..., ntohl(), ... */ #ifdef XP_OS2 #include <sys/ioctl.h> -#else +#endif +#ifdef XP_UNIX #include <arpa/inet.h> #endif #include <netdb.h> diff --git a/pr/include/prio.h b/pr/include/prio.h index b1531d6c..b8fcad7d 100644 --- a/pr/include/prio.h +++ b/pr/include/prio.h @@ -134,13 +134,21 @@ typedef struct in6_addr PRIPv6Addr; union PRNetAddr { struct { PRUint16 family; /* address family (0x00ff maskable) */ +#ifdef XP_BEOS + char data[10]; /* Be has a smaller structure */ +#else char data[14]; /* raw address data */ +#endif } raw; struct { PRUint16 family; /* address family (AF_INET) */ PRUint16 port; /* port number */ PRUint32 ip; /* The actual 32 bits of address */ +#ifdef XP_BEOS + char pad[4]; /* Be has a smaller structure */ +#else char pad[8]; +#endif } inet; #if defined(_PR_INET6) struct { diff --git a/pr/include/private/primpl.h b/pr/include/private/primpl.h index b7476d6c..ea4f5070 100644 --- a/pr/include/private/primpl.h +++ b/pr/include/private/primpl.h @@ -31,6 +31,10 @@ #include <pthread.h> #endif +#if defined(_PR_BTHREADS) +#include <kernel/OS.h> +#endif + #ifdef WINNT /* Need to force service-pack 3 extensions to be defined by ** setting _WIN32_WINNT to NT 4.0 for winsock.h, winbase.h, winnt.h. @@ -1220,14 +1224,18 @@ struct PRLock { pthread_mutex_t mutex; /* the underlying lock */ _PT_Notified notified; /* array of conditions notified */ pthread_t owner; /* current lock owner */ -#else /* defined(_PR_PTHREADS) */ +#elif defined(_PR_BTHREADS) + sem_id semaphoreID; /* the underlying lock */ + int32 benaphoreCount; /* number of people in lock */ + thread_id owner; /* current lock owner */ +#else /* not pthreads or Be threads */ PRCList links; /* linkage for PRThread.lockList */ struct PRThread *owner; /* current lock owner */ PRCList waitQ; /* list of threads waiting for lock */ PRThreadPriority priority; /* priority of lock */ PRThreadPriority boostPriority; /* boosted priority of lock owner */ _MDLock ilock; /* Internal Lock to protect user-level fields */ -#endif /* defined(_PR_PTHREADS) */ +#endif }; extern void _PR_InitLocks(void); @@ -1237,11 +1245,14 @@ struct PRCondVar { #if defined(_PR_PTHREADS) pthread_cond_t cv; /* underlying pthreads condition */ PRInt32 notify_pending; /* CV has destroy pending notification */ -#else /* defined(_PR_PTHREADS) */ +#elif defined(_PR_BTHREADS) + sem_id isem; /* Semaphore used to lock threadQ */ + int32 benaphoreCount; /* Number of people in lock */ +#else /* not pthreads or Be threads */ PRCList condQ; /* Condition variable wait Q */ _MDLock ilock; /* Internal Lock to protect condQ */ _MDCVar md; -#endif /* defined(_PR_PTHREADS) */ +#endif }; /************************************************************************/ @@ -1261,6 +1272,10 @@ struct PRMonitor { /************************************************************************/ struct PRSemaphore { +#if defined(_PR_BTHREADS) + sem_id sem; + int32 benaphoreCount; +#else PRCondVar *cvar; /* associated lock and condition variable queue */ PRUintn count; /* the value of the counting semaphore */ PRUint32 waiters; /* threads waiting on the semaphore */ @@ -1268,6 +1283,7 @@ struct PRSemaphore { #else /* defined(_PR_PTHREADS) */ _MDSemaphore md; #endif /* defined(_PR_PTHREADS) */ +#endif /* defined(_PR_BTHREADS) */ }; PR_EXTERN(void) _PR_InitSem(void); @@ -1340,7 +1356,13 @@ struct PRThread { pthread_mutex_t suspendResumeMutex; pthread_cond_t suspendResumeCV; #endif -#else /* defined(_PR_PTHREADS) */ +#elif defined(_PR_BTHREADS) + PRUint32 flags; + _MDThread md; + PRBool io_pending; + PRInt32 io_fd; + PRBool io_suspended; +#else /* not pthreads or Be threads */ _MDLock threadLock; /* Lock to protect thread state variables. * Protects the following fields: * state @@ -1405,7 +1427,7 @@ struct PRThread { PRBool io_suspended; _MDThread md; -#endif /* defined(_PR_PTHREADS) */ +#endif }; struct PRProcessAttr { @@ -1683,6 +1705,23 @@ PR_EXTERN(PRInt32) _PR_MD_GET_SOCKET_ERROR(void); extern PRStatus _PR_MD_GETHOSTNAME(char *name, PRUint32 namelen); #define _PR_MD_GETHOSTNAME _MD_GETHOSTNAME +#ifdef XP_BEOS + +extern PRLock *_connectLock; + +typedef struct _ConnectListNode { + PRInt32 osfd; + PRNetAddr addr; + PRUint32 addrlen; + PRIntervalTime timeout; +} ConnectListNode; + +extern ConnectListNode connectList[64]; + +extern PRUint32 connectCount; + +#endif /* XP_BEOS */ + PR_END_EXTERN_C #endif /* primpl_h___ */ diff --git a/pr/include/prtypes.h b/pr/include/prtypes.h index 7a1a9ffc..d1ab7a3d 100644 --- a/pr/include/prtypes.h +++ b/pr/include/prtypes.h @@ -35,6 +35,10 @@ #include "prcpucfg.h" +#ifdef XP_BEOS +#include <support/SupportDefs.h> +#endif + #include <stddef.h> /*********************************************************************** @@ -67,6 +71,16 @@ #define PR_CALLBACK_DECL #define PR_STATIC_CALLBACK(__x) static __x +#elif defined(XP_BEOS) +#define PR_EXTERN(__type) extern __declspec(dllexport) __type +#define PR_IMPLEMENT(__type) __declspec(dllexport) __type +#define PR_EXTERN_DATA(__type) extern __declspec(dllexport) __type +#define PR_IMPLEMENT_DATA(__type) __declspec(dllexport) __type + +#define PR_CALLBACK +#define PR_CALLBACK_DECL +#define PR_STATIC_CALLBACK(__x) static __x + #elif defined(WIN16) #define PR_CALLBACK_DECL __cdecl diff --git a/pr/src/Makefile b/pr/src/Makefile index ab4c3795..5241380e 100644 --- a/pr/src/Makefile +++ b/pr/src/Makefile @@ -27,6 +27,10 @@ ifeq ($(USE_PTHREADS), 1) DIRS += pthreads endif +ifeq ($(USE_BTHREADS), 1) + DIRS += bthreads +endif + ifeq ($(USE_CPLUS), 1) DIRS += cplus endif @@ -195,7 +199,10 @@ OBJS += \ io/$(OBJDIR)/prdir.$(OBJ_SUFFIX) \ io/$(OBJDIR)/prfile.$(OBJ_SUFFIX) \ io/$(OBJDIR)/prio.$(OBJ_SUFFIX) \ - io/$(OBJDIR)/prsocket.$(OBJ_SUFFIX) \ + io/$(OBJDIR)/prsocket.$(OBJ_SUFFIX) + +ifndef USE_BTHREADS +OBJS += \ threads/$(OBJDIR)/prcthr.$(OBJ_SUFFIX) \ threads/$(OBJDIR)/prdump.$(OBJ_SUFFIX) \ threads/$(OBJDIR)/prmon.$(OBJ_SUFFIX) \ @@ -207,6 +214,8 @@ OBJS += \ threads/combined/$(OBJDIR)/pruthr.$(OBJ_SUFFIX) endif +endif + ifeq ($(USE_IPV6), 1) OBJS += io/$(OBJDIR)/pripv6.$(OBJ_SUFFIX) endif @@ -301,8 +310,13 @@ endif else -# Unix -include md/unix/objs.mk +ifeq ($(OS_ARCH), BeOS) + include md/beos/objs.mk + include bthreads/objs.mk +else + # Unix + include md/unix/objs.mk +endif endif diff --git a/pr/src/io/prfile.c b/pr/src/io/prfile.c index dbe7b9e5..f39de5ed 100644 --- a/pr/src/io/prfile.c +++ b/pr/src/io/prfile.c @@ -296,7 +296,7 @@ PRInt32 PR_GetSysfdTableMax(void) return 16384; #elif defined (WIN16) return FOPEN_MAX; -#elif defined (XP_MAC) +#elif defined (XP_MAC) || defined(XP_BEOS) PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0); return -1; #else @@ -331,7 +331,8 @@ PRInt32 PR_SetSysfdTableSize(int table_size) return rlim.rlim_cur; #elif defined(AIX) || defined(NEXTSTEP) || defined(QNX) \ - || defined(WIN32) || defined(WIN16) || defined(OS2) + || defined(WIN32) || defined(WIN16) || defined(OS2) \ + || defined(XP_BEOS) PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0); return -1; #elif defined (XP_MAC) diff --git a/pr/src/io/prlog.c b/pr/src/io/prlog.c index 897371bb..093cef55 100644 --- a/pr/src/io/prlog.c +++ b/pr/src/io/prlog.c @@ -30,7 +30,10 @@ * This can lead to infinite recursion. */ static PRLock *_pr_logLock; -#if (defined(_PR_PTHREADS) || defined(_PR_GLOBAL_THREADS_ONLY)) +#if defined(_PR_PTHREADS) || defined(_PR_BTHREADS) +#define _PR_LOCK_LOG() PR_Lock(_pr_logLock); +#define _PR_UNLOCK_LOG() PR_Unlock(_pr_logLock); +#elif defined(_PR_GLOBAL_THREADS_ONLY) #define _PR_LOCK_LOG() { _PR_LOCK_LOCK(_pr_logLock) #define _PR_UNLOCK_LOG() _PR_LOCK_UNLOCK(_pr_logLock); } #else @@ -393,6 +396,8 @@ PR_IMPLEMENT(void) PR_LogPrint(const char *fmt, ...) * pointer, but a structure; so you can't easily print it... */ me ? &(me->id): 0L, me); +#elif defined(_PR_BTHREADS) + me, me); #else me ? me->id : 0L, me); #endif @@ -462,7 +467,7 @@ PR_IMPLEMENT(void) PR_Assert(const char *s, const char *file, PRIntn ln) { #ifdef PR_LOGGING PR_LogPrint("Assertion failure: %s, at %s:%d\n", s, file, ln); -#if defined(XP_UNIX) || defined(XP_OS2) +#if defined(XP_UNIX) || defined(XP_OS2) || defined(XP_BEOS) fprintf(stderr, "Assertion failure: %s, at %s:%d\n", s, file, ln); #endif #ifdef XP_MAC diff --git a/pr/src/io/prmapopt.c b/pr/src/io/prmapopt.c index 49c15863..a32b2806 100644 --- a/pr/src/io/prmapopt.c +++ b/pr/src/io/prmapopt.c @@ -70,6 +70,7 @@ PRStatus PR_CALLBACK _PR_SocketGetSocketOption(PRFileDesc *fd, PRSocketOptionDat { case PR_SockOpt_Linger: { +#if !defined(XP_BEOS) struct linger linger; length = sizeof(linger); rv = _PR_MD_GETSOCKOPT( @@ -83,6 +84,10 @@ PRStatus PR_CALLBACK _PR_SocketGetSocketOption(PRFileDesc *fd, PRSocketOptionDat PR_SecondsToInterval(linger.l_linger); } break; +#else + PR_SetError( PR_NOT_IMPLEMENTED_ERROR, 0 ); + return PR_FAILURE; +#endif } case PR_SockOpt_Reuseaddr: case PR_SockOpt_Keepalive: @@ -222,12 +227,17 @@ PRStatus PR_CALLBACK _PR_SocketSetSocketOption(PRFileDesc *fd, const PRSocketOpt { case PR_SockOpt_Linger: { +#if !defined(XP_BEOS) struct linger linger; linger.l_onoff = data->value.linger.polarity; linger.l_linger = PR_IntervalToSeconds(data->value.linger.linger); rv = _PR_MD_SETSOCKOPT( fd, level, name, (char*)&linger, sizeof(linger)); break; +#else + PR_SetError( PR_NOT_IMPLEMENTED_ERROR, 0 ); + return PR_FAILURE; +#endif } case PR_SockOpt_Reuseaddr: case PR_SockOpt_Keepalive: @@ -366,6 +376,18 @@ PRStatus PR_CALLBACK _PR_SocketSetSocketOption(PRFileDesc *fd, const PRSocketOpt */ #define _PR_NO_SUCH_SOCKOPT -1 +#ifndef SO_KEEPALIVE +#define SO_KEEPALIVE _PR_NO_SUCH_SOCKOPT +#endif + +#ifndef SO_SNDBUF +#define SO_SNDBUF _PR_NO_SUCH_SOCKOPT +#endif + +#ifndef SO_RCVBUF +#define SO_RCVBUF _PR_NO_SUCH_SOCKOPT +#endif + #ifndef IP_MULTICAST_IF /* set/get IP multicast interface */ #define IP_MULTICAST_IF _PR_NO_SUCH_SOCKOPT #endif diff --git a/pr/src/io/prsocket.c b/pr/src/io/prsocket.c index e93e0ec2..9c144e18 100644 --- a/pr/src/io/prsocket.c +++ b/pr/src/io/prsocket.c @@ -295,6 +295,16 @@ PR_IMPLEMENT(PRStatus) PR_GetConnectStatus(const PRPollDesc *pd) else return PR_SUCCESS; +#elif defined(XP_BEOS) + + err = _MD_beos_get_nonblocking_connect_error(bottom); + if( err != 0 ) { + _PR_MD_MAP_CONNECT_ERROR(err); + return PR_FAILURE; + } + else + return PR_SUCCESS; + #else PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0); return PR_FAILURE; @@ -905,6 +915,7 @@ static PRStatus PR_CALLBACK SocketGetSockOpt( { if (PR_SockOpt_Linger == optname) { +#if !defined(XP_BEOS) struct linger linger; PRInt32 len = sizeof(linger); rv = _PR_MD_GETSOCKOPT( @@ -917,6 +928,10 @@ static PRStatus PR_CALLBACK SocketGetSockOpt( linger.l_linger); *optlen = sizeof(PRLinger); } +#else + PR_SetError( PR_NOT_IMPLEMENTED_ERROR, 0 ); + return PR_FAILURE; +#endif } else { @@ -966,12 +981,17 @@ static PRStatus PR_CALLBACK SocketSetSockOpt( { if (PR_SockOpt_Linger == optname) { +#if !defined(XP_BEOS) struct linger linger; linger.l_onoff = ((PRLinger*)(optval))->polarity ? 1 : 0; linger.l_linger = PR_IntervalToSeconds( ((PRLinger*)(optval))->linger); rv = _PR_MD_SETSOCKOPT( fd, level, name, (char *) &linger, sizeof(linger)); +#else + PR_SetError( PR_NOT_IMPLEMENTED_ERROR, 0 ); + return PR_FAILURE; +#endif } else { diff --git a/pr/src/linking/prlink.c b/pr/src/linking/prlink.c index 594133fa..0cb884dc 100644 --- a/pr/src/linking/prlink.c +++ b/pr/src/linking/prlink.c @@ -20,6 +20,10 @@ #include <string.h> +#ifdef XP_BEOS +#include <image.h> +#endif + #ifdef XP_MAC #include <CodeFragments.h> #include <TextUtils.h> @@ -77,6 +81,10 @@ struct PRLibrary { void* dlh; #endif #endif + +#ifdef XP_BEOS + void* dlh; +#endif }; static PRLibrary *pr_loadmap; @@ -375,14 +383,14 @@ PR_GetLibraryName(const char *path, const char *lib) #ifdef XP_MAC fullname = PR_smprintf("%s%s", path, lib); #endif -#ifdef XP_UNIX +#if defined(XP_UNIX) || defined(XP_BEOS) if (strstr(lib, PR_DLL_SUFFIX) == NULL) { fullname = PR_smprintf("%s/lib%s%s", path, lib, PR_DLL_SUFFIX); } else { fullname = PR_smprintf("%s/%s", path, lib); } -#endif /* XP_UNIX */ +#endif /* XP_UNIX || XP_BEOS */ return fullname; } @@ -642,6 +650,25 @@ PR_LoadLibrary(const char *name) } #endif +#ifdef XP_BEOS + { + image_id h = load_add_on( name ); + + if( h == B_ERROR || h <= 0 ) { + + h = 0; + result = NULL; + PR_DELETE( lm ); + lm = NULL; + goto unlock; + } + lm->name = strdup(name); + lm->dlh = (void*)h; + lm->next = pr_loadmap; + pr_loadmap = lm; + } +#endif + #ifdef XP_UNIX #ifdef HAVE_DLL { @@ -716,6 +743,11 @@ PR_UnloadLibrary(PRLibrary *lib) lib->name, lib->refCount)); goto done; } + +#ifdef XP_BEOS + unload_add_on( (image_id) lib->dlh ); +#endif + #ifdef XP_UNIX #ifdef HAVE_DLL #ifdef USE_DLFCN @@ -801,7 +833,7 @@ pr_FindSymbolInLib(PRLibrary *lm, const char *name) ** If the symbol was not found in the static table then check if ** the symbol was exported in the DLL... Win16 only!! */ -#if !defined(WIN16) +#if !defined(WIN16) && !defined(XP_BEOS) PR_SetError(PR_FIND_SYMBOL_ERROR, 0); return (void*)NULL; #endif @@ -827,6 +859,13 @@ pr_FindSymbolInLib(PRLibrary *lm, const char *name) } #endif /* XP_MAC */ +#ifdef XP_BEOS + if( B_NO_ERROR != get_image_symbol( (image_id)lm->dlh, name, B_SYMBOL_TYPE_TEXT, &f ) ) { + + f = NULL; + } +#endif + #ifdef XP_UNIX #ifdef HAVE_DLL #ifdef USE_DLFCN diff --git a/pr/src/md/Makefile b/pr/src/md/Makefile index a05a1db4..e63c8d5c 100644 --- a/pr/src/md/Makefile +++ b/pr/src/md/Makefile @@ -28,7 +28,11 @@ ifeq ($(OS_ARCH),WINNT) DIRS = windows endif else - DIRS = unix + ifeq ($(OS_ARCH),BeOS) + DIRS = beos + else + DIRS = unix + endif endif # Disable optimization of the nspr on SunOS4.1.3 diff --git a/pr/src/md/prosdep.c b/pr/src/md/prosdep.c index 3d288b07..0c65c783 100644 --- a/pr/src/md/prosdep.c +++ b/pr/src/md/prosdep.c @@ -28,6 +28,9 @@ #ifdef _WIN32 #include <windows.h> #endif +#ifdef XP_BEOS +#include <OS.h> +#endif PRInt32 _pr_pageShift; PRInt32 _pr_pageSize; @@ -57,6 +60,10 @@ static void GetPageSize(void) _pr_pageSize = 4096; #endif /* XP_MAC */ +#ifdef XP_BEOS + _pr_pageSize = B_PAGE_SIZE; +#endif + #ifdef XP_PC #ifdef _WIN32 SYSTEM_INFO info; diff --git a/pr/src/misc/prinit.c b/pr/src/misc/prinit.c index 2bda7fe0..d0eec826 100644 --- a/pr/src/misc/prinit.c +++ b/pr/src/misc/prinit.c @@ -33,7 +33,7 @@ PRFileDesc *_pr_stdin; PRFileDesc *_pr_stdout; PRFileDesc *_pr_stderr; -#if !defined(_PR_PTHREADS) +#if !defined(_PR_PTHREADS) && !defined(_PR_BTHREADS) PRCList _pr_active_local_threadQ = PR_INIT_STATIC_CLIST(&_pr_active_local_threadQ); @@ -166,7 +166,7 @@ void _PR_ImplicitInitialization() PR_IMPLEMENT(void) PR_DisableClockInterrupts(void) { -#if !defined(_PR_PTHREADS) +#if !defined(_PR_PTHREADS) && !defined(_PR_BTHREADS) if (!_pr_initialized) { _PR_InitStuff(); } else { @@ -177,7 +177,7 @@ PR_IMPLEMENT(void) PR_DisableClockInterrupts(void) PR_IMPLEMENT(void) PR_EnableClockInterrupts(void) { -#if !defined(_PR_PTHREADS) +#if !defined(_PR_PTHREADS) && !defined(_PR_BTHREADS) if (!_pr_initialized) { _PR_InitStuff(); } @@ -187,14 +187,14 @@ PR_IMPLEMENT(void) PR_EnableClockInterrupts(void) PR_IMPLEMENT(void) PR_BlockClockInterrupts(void) { -#if !defined(_PR_PTHREADS) +#if !defined(_PR_PTHREADS) && !defined(_PR_BTHREADS) _PR_MD_BLOCK_CLOCK_INTERRUPTS(); #endif } PR_IMPLEMENT(void) PR_UnblockClockInterrupts(void) { -#if !defined(_PR_PTHREADS) +#if !defined(_PR_PTHREADS) && !defined(_PR_BTHREADS) _PR_MD_UNBLOCK_CLOCK_INTERRUPTS(); #endif } @@ -237,7 +237,7 @@ PR_IMPLEMENT(PRIntn) PR_Initialize( * *----------------------------------------------------------------------- */ -#if defined(_PR_PTHREADS) +#if defined(_PR_PTHREADS) || defined(_PR_BTHREADS) /* see ptthread.c */ #else static void @@ -284,7 +284,7 @@ thread is destroyed, can not access current thread any more. * *---------------------------------------------------------------------- */ -#if defined(_PR_PTHREADS) +#if defined(_PR_PTHREADS) || defined(_PR_BTHREADS) /* see ptthread.c */ #else @@ -375,7 +375,7 @@ PR_IMPLEMENT(PRStatus) PR_Cleanup() *------------------------------------------------------------------------ */ -#if defined(_PR_PTHREADS) +#if defined(_PR_PTHREADS) || defined(_PR_BTHREADS) /* see ptthread.c */ #else PR_IMPLEMENT(void) PR_ProcessExit(PRIntn status) diff --git a/pr/src/misc/prtime.c b/pr/src/misc/prtime.c index 4bf43fc8..88328886 100644 --- a/pr/src/misc/prtime.c +++ b/pr/src/misc/prtime.c @@ -609,7 +609,7 @@ static struct tm *MT_safe_localtime(const time_t *clock, struct tm *result) #endif /* definition of MT_safe_localtime() */ -#if defined(XP_UNIX) || defined(XP_PC) +#if defined(XP_UNIX) || defined(XP_PC) || defined(XP_BEOS) PR_IMPLEMENT(PRTimeParameters) PR_LocalTimeParameters(const PRExplodedTime *gmt) diff --git a/pr/src/threads/Makefile b/pr/src/threads/Makefile index 755d9928..bc0e3986 100644 --- a/pr/src/threads/Makefile +++ b/pr/src/threads/Makefile @@ -24,8 +24,12 @@ include $(MOD_DEPTH)/config/config.mk ifdef USE_PTHREADS DIRS = else +ifdef USE_BTHREADS + DIRS = +else DIRS = combined endif +endif # Disable optimization of the nspr on SunOS4.1.3 ifeq ($(OS_ARCH),SunOS) @@ -40,6 +44,12 @@ CSRCS = \ prtpd.c \ $(NULL) else +ifdef USE_BTHREADS +CSRCS = \ + prcmon.c \ + prtpd.c \ + $(NULL) +else CSRCS = \ prcmon.c \ prdump.c \ @@ -49,6 +59,7 @@ CSRCS = \ prtpd.c \ $(NULL) endif +endif TARGETS = $(OBJS) diff --git a/pr/tests/op_filok.c b/pr/tests/op_filok.c index 2ef12432..680fea20 100644 --- a/pr/tests/op_filok.c +++ b/pr/tests/op_filok.c @@ -52,6 +52,8 @@ #define EXISTING_FILENAME "c:/boot.ini" #elif defined(OS2) #define EXISTING_FILENAME "c:/config.sys" +#elif defined(BEOS) +#define EXISTING_FILENAME "/boot/beos/bin/sh" #else #error "Unknown OS" #endif |