зеркало из https://github.com/mozilla/pjs.git
Update with post-3.5 fixes on the tip
This commit is contained in:
Родитель
c070ed6434
Коммит
169a3f4297
|
@ -60,7 +60,7 @@ endif
|
||||||
|
|
||||||
ifeq ($(OS_ARCH), HP-UX)
|
ifeq ($(OS_ARCH), HP-UX)
|
||||||
ifeq ($(USE_64),1)
|
ifeq ($(USE_64),1)
|
||||||
XLDOPTS += +DD64
|
XLDOPTS += +DA2.0W
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
|
|
@ -69,8 +69,11 @@ static PRVersionDescription prVersionDescription_libplds3 =
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Version information for the 'ident' and 'what commands
|
* Version information for the 'ident' and 'what commands
|
||||||
|
*
|
||||||
|
* NOTE: the first component of the concatenated rcsid string
|
||||||
|
* must not end in a '$' to prevent rcs keyword substitution.
|
||||||
*/
|
*/
|
||||||
static char rcsid[] = "$Version: NSPR " PR_VERSION _DEBUG_STRING
|
static char rcsid[] = "$Header: NSPR " PR_VERSION _DEBUG_STRING
|
||||||
" " _BUILD_STRING " $";
|
" " _BUILD_STRING " $";
|
||||||
static char sccsid[] = "@(#)NSPR " PR_VERSION _DEBUG_STRING
|
static char sccsid[] = "@(#)NSPR " PR_VERSION _DEBUG_STRING
|
||||||
" " _BUILD_STRING;
|
" " _BUILD_STRING;
|
||||||
|
|
|
@ -69,8 +69,11 @@ static PRVersionDescription prVersionDescription_libplc3 =
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Version information for the 'ident' and 'what commands
|
* Version information for the 'ident' and 'what commands
|
||||||
|
*
|
||||||
|
* NOTE: the first component of the concatenated rcsid string
|
||||||
|
* must not end in a '$' to prevent rcs keyword substitution.
|
||||||
*/
|
*/
|
||||||
static char rcsid[] = "$Version: NSPR " PR_VERSION _DEBUG_STRING
|
static char rcsid[] = "$Header: NSPR " PR_VERSION _DEBUG_STRING
|
||||||
" " _BUILD_STRING " $";
|
" " _BUILD_STRING " $";
|
||||||
static char sccsid[] = "@(#)NSPR " PR_VERSION _DEBUG_STRING
|
static char sccsid[] = "@(#)NSPR " PR_VERSION _DEBUG_STRING
|
||||||
" " _BUILD_STRING;
|
" " _BUILD_STRING;
|
||||||
|
|
|
@ -69,8 +69,11 @@ static PRVersionDescription prVersionDescription_libprstrms3 =
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Version information for the 'ident' and 'what commands
|
* Version information for the 'ident' and 'what commands
|
||||||
|
*
|
||||||
|
* NOTE: the first component of the concatenated rcsid string
|
||||||
|
* must not end in a '$' to prevent rcs keyword substitution.
|
||||||
*/
|
*/
|
||||||
static char rcsid[] = "$Version: NSPR " PR_VERSION _DEBUG_STRING
|
static char rcsid[] = "$Header: NSPR " PR_VERSION _DEBUG_STRING
|
||||||
" " _BUILD_STRING " $";
|
" " _BUILD_STRING " $";
|
||||||
static char sccsid[] = "@(#)NSPR " PR_VERSION _DEBUG_STRING
|
static char sccsid[] = "@(#)NSPR " PR_VERSION _DEBUG_STRING
|
||||||
" " _BUILD_STRING;
|
" " _BUILD_STRING;
|
||||||
|
|
|
@ -63,6 +63,8 @@ extern PRStatus _MD_OS2GetHostName(char *name, PRUint32 namelen);
|
||||||
#else
|
#else
|
||||||
extern PRStatus _MD_WindowsGetHostName(char *name, PRUint32 namelen);
|
extern PRStatus _MD_WindowsGetHostName(char *name, PRUint32 namelen);
|
||||||
#define _MD_GETHOSTNAME _MD_WindowsGetHostName
|
#define _MD_GETHOSTNAME _MD_WindowsGetHostName
|
||||||
|
extern PRStatus _MD_WindowsGetSysInfo(PRSysInfo cmd, char *name, PRUint32 namelen);
|
||||||
|
#define _MD_GETSYSINFO _MD_WindowsGetSysInfo
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /* prpcos_h___ */
|
#endif /* prpcos_h___ */
|
||||||
|
|
|
@ -393,6 +393,8 @@ extern PRInt32 _MD_socketavailable(PRFileDesc *fd);
|
||||||
extern PRInt64 _MD_socketavailable64(PRFileDesc *fd);
|
extern PRInt64 _MD_socketavailable64(PRFileDesc *fd);
|
||||||
#define _MD_SOCKETAVAILABLE64 _MD_socketavailable64
|
#define _MD_SOCKETAVAILABLE64 _MD_socketavailable64
|
||||||
|
|
||||||
|
#define _MD_PIPEAVAILABLE _MD_socketavailable
|
||||||
|
|
||||||
extern PRInt32 _MD_pr_poll(PRPollDesc *pds, PRIntn npds,
|
extern PRInt32 _MD_pr_poll(PRPollDesc *pds, PRIntn npds,
|
||||||
PRIntervalTime timeout);
|
PRIntervalTime timeout);
|
||||||
#define _MD_PR_POLL _MD_pr_poll
|
#define _MD_PR_POLL _MD_pr_poll
|
||||||
|
@ -435,6 +437,9 @@ extern PRStatus _MD_set_fd_inheritable(PRFileDesc *fd, PRBool inheritable);
|
||||||
extern PRStatus _MD_gethostname(char *name, PRUint32 namelen);
|
extern PRStatus _MD_gethostname(char *name, PRUint32 namelen);
|
||||||
#define _MD_GETHOSTNAME _MD_gethostname
|
#define _MD_GETHOSTNAME _MD_gethostname
|
||||||
|
|
||||||
|
extern PRStatus _MD_getsysinfo(PRSysInfo cmd, char *name, PRUint32 namelen);
|
||||||
|
#define _MD_GETSYSINFO _MD_getsysinfo
|
||||||
|
|
||||||
extern int _MD_unix_get_nonblocking_connect_error(int osfd);
|
extern int _MD_unix_get_nonblocking_connect_error(int osfd);
|
||||||
|
|
||||||
#define HAVE_SOCKET_REUSEADDR
|
#define HAVE_SOCKET_REUSEADDR
|
||||||
|
|
|
@ -219,6 +219,7 @@ typedef enum PRSockOption
|
||||||
|
|
||||||
PR_SockOpt_NoDelay, /* don't delay send to coalesce packets */
|
PR_SockOpt_NoDelay, /* don't delay send to coalesce packets */
|
||||||
PR_SockOpt_MaxSegment, /* maximum segment size */
|
PR_SockOpt_MaxSegment, /* maximum segment size */
|
||||||
|
PR_SockOpt_Broadcast, /* enable broadcast */
|
||||||
PR_SockOpt_Last
|
PR_SockOpt_Last
|
||||||
} PRSockOption;
|
} PRSockOption;
|
||||||
|
|
||||||
|
@ -245,6 +246,7 @@ typedef struct PRSocketOptionData
|
||||||
PRBool keep_alive; /* Keep connections alive */
|
PRBool keep_alive; /* Keep connections alive */
|
||||||
PRBool mcast_loopback; /* IP multicast loopback */
|
PRBool mcast_loopback; /* IP multicast loopback */
|
||||||
PRBool no_delay; /* Don't delay send to coalesce packets */
|
PRBool no_delay; /* Don't delay send to coalesce packets */
|
||||||
|
PRBool broadcast; /* Enable broadcast */
|
||||||
PRSize max_segment; /* Maximum segment size */
|
PRSize max_segment; /* Maximum segment size */
|
||||||
PRSize recv_buffer_size; /* Receive buffer size */
|
PRSize recv_buffer_size; /* Receive buffer size */
|
||||||
PRSize send_buffer_size; /* Send buffer size */
|
PRSize send_buffer_size; /* Send buffer size */
|
||||||
|
@ -278,7 +280,8 @@ typedef enum PRDescType
|
||||||
PR_DESC_FILE = 1,
|
PR_DESC_FILE = 1,
|
||||||
PR_DESC_SOCKET_TCP = 2,
|
PR_DESC_SOCKET_TCP = 2,
|
||||||
PR_DESC_SOCKET_UDP = 3,
|
PR_DESC_SOCKET_UDP = 3,
|
||||||
PR_DESC_LAYERED = 4
|
PR_DESC_LAYERED = 4,
|
||||||
|
PR_DESC_PIPE = 5
|
||||||
} PRDescType;
|
} PRDescType;
|
||||||
|
|
||||||
typedef enum PRSeekWhence {
|
typedef enum PRSeekWhence {
|
||||||
|
|
|
@ -30,22 +30,6 @@
|
||||||
|
|
||||||
PR_BEGIN_EXTERN_C
|
PR_BEGIN_EXTERN_C
|
||||||
|
|
||||||
/*
|
|
||||||
** File descriptors of the NSPR layer can be in one of the
|
|
||||||
** following states (stored in the 'state' field of struct
|
|
||||||
** PRFilePrivate):
|
|
||||||
** - _PR_FILEDESC_OPEN: The OS fd is open.
|
|
||||||
** - _PR_FILEDESC_CLOSED: The OS fd is closed. The PRFileDesc
|
|
||||||
** is still open but is unusable. The only operation allowed
|
|
||||||
** on the PRFileDesc is PR_Close().
|
|
||||||
** - _PR_FILEDESC_FREED: The OS fd is closed and the PRFileDesc
|
|
||||||
** structure is freed.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define _PR_FILEDESC_OPEN 0xaaaaaaaa /* 1010101... */
|
|
||||||
#define _PR_FILEDESC_CLOSED 0x55555555 /* 0101010... */
|
|
||||||
#define _PR_FILEDESC_FREED 0x11111111
|
|
||||||
|
|
||||||
/************************************************************************/
|
/************************************************************************/
|
||||||
/************************************************************************/
|
/************************************************************************/
|
||||||
|
|
||||||
|
@ -53,6 +37,7 @@ PR_BEGIN_EXTERN_C
|
||||||
PR_EXTERN(const PRIOMethods*) PR_GetFileMethods(void);
|
PR_EXTERN(const PRIOMethods*) PR_GetFileMethods(void);
|
||||||
PR_EXTERN(const PRIOMethods*) PR_GetTCPMethods(void);
|
PR_EXTERN(const PRIOMethods*) PR_GetTCPMethods(void);
|
||||||
PR_EXTERN(const PRIOMethods*) PR_GetUDPMethods(void);
|
PR_EXTERN(const PRIOMethods*) PR_GetUDPMethods(void);
|
||||||
|
PR_EXTERN(const PRIOMethods*) PR_GetPipeMethods(void);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** Convert a NSPR Socket Handle to a Native Socket handle.
|
** Convert a NSPR Socket Handle to a Native Socket handle.
|
||||||
|
|
|
@ -1165,6 +1165,9 @@ extern PRInt32 _PR_MD_SOCKET(int af, int type, int flags);
|
||||||
extern PRInt32 _PR_MD_SOCKETAVAILABLE(PRFileDesc *fd);
|
extern PRInt32 _PR_MD_SOCKETAVAILABLE(PRFileDesc *fd);
|
||||||
#define _PR_MD_SOCKETAVAILABLE _MD_SOCKETAVAILABLE
|
#define _PR_MD_SOCKETAVAILABLE _MD_SOCKETAVAILABLE
|
||||||
|
|
||||||
|
extern PRInt32 _PR_MD_PIPEAVAILABLE(PRFileDesc *fd);
|
||||||
|
#define _PR_MD_PIPEAVAILABLE _MD_PIPEAVAILABLE
|
||||||
|
|
||||||
extern PRInt32 _PR_MD_PR_POLL(PRPollDesc *pds, PRIntn npds,
|
extern PRInt32 _PR_MD_PR_POLL(PRPollDesc *pds, PRIntn npds,
|
||||||
PRIntervalTime timeout);
|
PRIntervalTime timeout);
|
||||||
#define _PR_MD_PR_POLL _MD_PR_POLL
|
#define _PR_MD_PR_POLL _MD_PR_POLL
|
||||||
|
@ -1503,6 +1506,22 @@ struct PRFileMap {
|
||||||
|
|
||||||
/************************************************************************/
|
/************************************************************************/
|
||||||
|
|
||||||
|
/*
|
||||||
|
** File descriptors of the NSPR layer can be in one of the
|
||||||
|
** following states (stored in the 'state' field of struct
|
||||||
|
** PRFilePrivate):
|
||||||
|
** - _PR_FILEDESC_OPEN: The OS fd is open.
|
||||||
|
** - _PR_FILEDESC_CLOSED: The OS fd is closed. The PRFileDesc
|
||||||
|
** is still open but is unusable. The only operation allowed
|
||||||
|
** on the PRFileDesc is PR_Close().
|
||||||
|
** - _PR_FILEDESC_FREED: The OS fd is closed and the PRFileDesc
|
||||||
|
** structure is freed.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define _PR_FILEDESC_OPEN 0xaaaaaaaa /* 1010101... */
|
||||||
|
#define _PR_FILEDESC_CLOSED 0x55555555 /* 0101010... */
|
||||||
|
#define _PR_FILEDESC_FREED 0x11111111
|
||||||
|
|
||||||
struct PRFilePrivate {
|
struct PRFilePrivate {
|
||||||
PRInt32 state;
|
PRInt32 state;
|
||||||
PRBool nonblocking;
|
PRBool nonblocking;
|
||||||
|
@ -1876,6 +1895,9 @@ PR_EXTERN(PRInt32) _PR_MD_GET_SOCKET_ERROR(void);
|
||||||
extern PRStatus _PR_MD_GETHOSTNAME(char *name, PRUint32 namelen);
|
extern PRStatus _PR_MD_GETHOSTNAME(char *name, PRUint32 namelen);
|
||||||
#define _PR_MD_GETHOSTNAME _MD_GETHOSTNAME
|
#define _PR_MD_GETHOSTNAME _MD_GETHOSTNAME
|
||||||
|
|
||||||
|
extern PRStatus _PR_MD_GETSYSINFO(PRSysInfo cmd, char *name, PRUint32 namelen);
|
||||||
|
#define _PR_MD_GETSYSINFO _MD_GETSYSINFO
|
||||||
|
|
||||||
#ifdef XP_BEOS
|
#ifdef XP_BEOS
|
||||||
|
|
||||||
extern PRLock *_connectLock;
|
extern PRLock *_connectLock;
|
||||||
|
|
|
@ -17,7 +17,6 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "primpl.h"
|
#include "primpl.h"
|
||||||
#include "pratom.h"
|
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
@ -182,6 +181,8 @@ PR_IMPLEMENT(PRStatus) PR_SetFDCacheSize(PRIntn low, PRIntn high)
|
||||||
** turn the caches off, or turn them on. It is not dependent
|
** turn the caches off, or turn them on. It is not dependent
|
||||||
** on the compilation setting of DEBUG.
|
** on the compilation setting of DEBUG.
|
||||||
*/
|
*/
|
||||||
|
if (!_pr_initialized) _PR_ImplicitInitialization();
|
||||||
|
|
||||||
if (low > high) low = high; /* sanity check the params */
|
if (low > high) low = high; /* sanity check the params */
|
||||||
|
|
||||||
PR_Lock(_pr_fd_cache.ml);
|
PR_Lock(_pr_fd_cache.ml);
|
||||||
|
@ -201,8 +202,7 @@ PR_IMPLEMENT(PRStatus) PR_SetFDCacheSize(PRIntn low, PRIntn high)
|
||||||
{
|
{
|
||||||
PRFileDesc *fd = _pr_fd_cache.head;
|
PRFileDesc *fd = _pr_fd_cache.head;
|
||||||
_pr_fd_cache.head = fd->higher;
|
_pr_fd_cache.head = fd->higher;
|
||||||
fd->identity = PR_NSPR_IO_LAYER;
|
PR_StackPush(_pr_fd_cache.stack, (PRStackElem*)(&fd->higher));
|
||||||
_PR_Putfd(fd);
|
|
||||||
}
|
}
|
||||||
_pr_fd_cache.limit_low = 0;
|
_pr_fd_cache.limit_low = 0;
|
||||||
_pr_fd_cache.tail = NULL;
|
_pr_fd_cache.tail = NULL;
|
||||||
|
@ -211,18 +211,20 @@ PR_IMPLEMENT(PRStatus) PR_SetFDCacheSize(PRIntn low, PRIntn high)
|
||||||
}
|
}
|
||||||
else /* starting up or just adjusting parameters */
|
else /* starting up or just adjusting parameters */
|
||||||
{
|
{
|
||||||
PRBool was_using_cache = (0 != _pr_fd_cache.limit_high);
|
PRBool was_using_stack = (0 == _pr_fd_cache.limit_high);
|
||||||
_pr_fd_cache.limit_low = low;
|
_pr_fd_cache.limit_low = low;
|
||||||
_pr_fd_cache.limit_high = high;
|
_pr_fd_cache.limit_high = high;
|
||||||
if (was_using_cache) /* was using stack - feed into cache */
|
if (was_using_stack) /* was using stack - feed into cache */
|
||||||
{
|
{
|
||||||
PRStackElem *pop;
|
PRStackElem *pop;
|
||||||
while (NULL != (pop = PR_StackPop(_pr_fd_cache.stack)))
|
while (NULL != (pop = PR_StackPop(_pr_fd_cache.stack)))
|
||||||
{
|
{
|
||||||
PRFileDesc *fd = (PRFileDesc*)
|
PRFileDesc *fd = (PRFileDesc*)
|
||||||
((PRPtrdiff)pop - (PRPtrdiff)stack2fd);
|
((PRPtrdiff)pop - (PRPtrdiff)stack2fd);
|
||||||
fd->identity = PR_NSPR_IO_LAYER;
|
if (NULL == _pr_fd_cache.tail) _pr_fd_cache.tail = fd;
|
||||||
_PR_Putfd(fd);
|
fd->higher = _pr_fd_cache.head;
|
||||||
|
_pr_fd_cache.head = fd;
|
||||||
|
_pr_fd_cache.count += 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -241,20 +243,21 @@ void _PR_InitFdCache()
|
||||||
const char *low = PR_GetEnv("NSPR_FD_CACHE_SIZE_LOW");
|
const char *low = PR_GetEnv("NSPR_FD_CACHE_SIZE_LOW");
|
||||||
const char *high = PR_GetEnv("NSPR_FD_CACHE_SIZE_HIGH");
|
const char *high = PR_GetEnv("NSPR_FD_CACHE_SIZE_HIGH");
|
||||||
|
|
||||||
_pr_fd_cache.limit_low = _pr_fd_cache.limit_high = 0;
|
|
||||||
if (NULL != low) _pr_fd_cache.limit_low = atoi(low);
|
|
||||||
if (NULL != high) _pr_fd_cache.limit_high = atoi(high);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** _low is allowed to be zero, _high is not.
|
** _low is allowed to be zero, _high is not.
|
||||||
** If _high is zero, we're not doing the caching.
|
** If _high is zero, we're not doing the caching.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
_pr_fd_cache.limit_low = 0;
|
||||||
#if defined(DEBUG)
|
#if defined(DEBUG)
|
||||||
if (0 == _pr_fd_cache.limit_high)
|
_pr_fd_cache.limit_high = FD_SETSIZE;
|
||||||
_pr_fd_cache.limit_high = FD_SETSIZE;
|
#else
|
||||||
|
_pr_fd_cache.limit_high = 0;
|
||||||
#endif /* defined(DEBUG) */
|
#endif /* defined(DEBUG) */
|
||||||
|
|
||||||
|
if (NULL != low) _pr_fd_cache.limit_low = atoi(low);
|
||||||
|
if (NULL != high) _pr_fd_cache.limit_high = atoi(high);
|
||||||
|
|
||||||
if (_pr_fd_cache.limit_high < _pr_fd_cache.limit_low)
|
if (_pr_fd_cache.limit_high < _pr_fd_cache.limit_low)
|
||||||
_pr_fd_cache.limit_high = _pr_fd_cache.limit_low;
|
_pr_fd_cache.limit_high = _pr_fd_cache.limit_low;
|
||||||
|
|
||||||
|
|
|
@ -155,6 +155,20 @@ static PRInt64 PR_CALLBACK FileAvailable64(PRFileDesc *fd)
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static PRInt32 PR_CALLBACK PipeAvailable(PRFileDesc *fd)
|
||||||
|
{
|
||||||
|
PRInt32 rv;
|
||||||
|
rv = _PR_MD_PIPEAVAILABLE(fd);
|
||||||
|
return rv;
|
||||||
|
}
|
||||||
|
|
||||||
|
static PRInt64 PR_CALLBACK PipeAvailable64(PRFileDesc *fd)
|
||||||
|
{
|
||||||
|
PRInt64 rv;
|
||||||
|
LL_I2L(rv, _PR_MD_PIPEAVAILABLE(fd));
|
||||||
|
return rv;
|
||||||
|
}
|
||||||
|
|
||||||
static PRStatus PR_CALLBACK FileInfo(PRFileDesc *fd, PRFileInfo *info)
|
static PRStatus PR_CALLBACK FileInfo(PRFileDesc *fd, PRFileInfo *info)
|
||||||
{
|
{
|
||||||
PRInt32 rv;
|
PRInt32 rv;
|
||||||
|
@ -256,6 +270,44 @@ PR_IMPLEMENT(const PRIOMethods*) PR_GetFileMethods(void)
|
||||||
return &_pr_fileMethods;
|
return &_pr_fileMethods;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static PRIOMethods _pr_pipeMethods = {
|
||||||
|
PR_DESC_PIPE,
|
||||||
|
FileClose,
|
||||||
|
FileRead,
|
||||||
|
FileWrite,
|
||||||
|
#ifdef WIN32
|
||||||
|
FileAvailable,
|
||||||
|
FileAvailable64,
|
||||||
|
#else
|
||||||
|
PipeAvailable,
|
||||||
|
PipeAvailable64,
|
||||||
|
#endif
|
||||||
|
FileSync,
|
||||||
|
(PRSeekFN)_PR_InvalidInt,
|
||||||
|
(PRSeek64FN)_PR_InvalidInt64,
|
||||||
|
(PRFileInfoFN)_PR_InvalidStatus,
|
||||||
|
(PRFileInfo64FN)_PR_InvalidStatus,
|
||||||
|
(PRWritevFN)_PR_InvalidInt,
|
||||||
|
(PRConnectFN)_PR_InvalidStatus,
|
||||||
|
(PRAcceptFN)_PR_InvalidDesc,
|
||||||
|
(PRBindFN)_PR_InvalidStatus,
|
||||||
|
(PRListenFN)_PR_InvalidStatus,
|
||||||
|
(PRShutdownFN)_PR_InvalidStatus,
|
||||||
|
(PRRecvFN)_PR_InvalidInt,
|
||||||
|
(PRSendFN)_PR_InvalidInt,
|
||||||
|
(PRRecvfromFN)_PR_InvalidInt,
|
||||||
|
(PRSendtoFN)_PR_InvalidInt,
|
||||||
|
FilePoll,
|
||||||
|
(PRAcceptreadFN)_PR_InvalidInt,
|
||||||
|
(PRTransmitfileFN)_PR_InvalidInt,
|
||||||
|
(PRGetsocknameFN)_PR_InvalidStatus,
|
||||||
|
(PRGetpeernameFN)_PR_InvalidStatus,
|
||||||
|
(PRGetsockoptFN)_PR_InvalidStatus,
|
||||||
|
(PRSetsockoptFN)_PR_InvalidStatus,
|
||||||
|
(PRGetsocketoptionFN)_PR_InvalidStatus,
|
||||||
|
(PRSetsocketoptionFN)_PR_InvalidStatus
|
||||||
|
};
|
||||||
|
|
||||||
PR_IMPLEMENT(PRFileDesc*) PR_Open(const char *name, PRIntn flags, PRIntn mode)
|
PR_IMPLEMENT(PRFileDesc*) PR_Open(const char *name, PRIntn flags, PRIntn mode)
|
||||||
{
|
{
|
||||||
PRInt32 osfd;
|
PRInt32 osfd;
|
||||||
|
@ -553,13 +605,13 @@ PR_IMPLEMENT(PRStatus) PR_CreatePipe(
|
||||||
PR_SetError(PR_UNKNOWN_ERROR, GetLastError());
|
PR_SetError(PR_UNKNOWN_ERROR, GetLastError());
|
||||||
return PR_FAILURE;
|
return PR_FAILURE;
|
||||||
}
|
}
|
||||||
*readPipe = PR_AllocFileDesc((PRInt32)readEnd, &_pr_fileMethods);
|
*readPipe = PR_AllocFileDesc((PRInt32)readEnd, &_pr_pipeMethods);
|
||||||
if (NULL == *readPipe) {
|
if (NULL == *readPipe) {
|
||||||
CloseHandle(readEnd);
|
CloseHandle(readEnd);
|
||||||
CloseHandle(writeEnd);
|
CloseHandle(writeEnd);
|
||||||
return PR_FAILURE;
|
return PR_FAILURE;
|
||||||
}
|
}
|
||||||
*writePipe = PR_AllocFileDesc((PRInt32)writeEnd, &_pr_fileMethods);
|
*writePipe = PR_AllocFileDesc((PRInt32)writeEnd, &_pr_pipeMethods);
|
||||||
if (NULL == *writePipe) {
|
if (NULL == *writePipe) {
|
||||||
PR_Close(*readPipe);
|
PR_Close(*readPipe);
|
||||||
CloseHandle(writeEnd);
|
CloseHandle(writeEnd);
|
||||||
|
@ -582,13 +634,13 @@ PR_IMPLEMENT(PRStatus) PR_CreatePipe(
|
||||||
PR_SetError(PR_UNKNOWN_ERROR, errno);
|
PR_SetError(PR_UNKNOWN_ERROR, errno);
|
||||||
return PR_FAILURE;
|
return PR_FAILURE;
|
||||||
}
|
}
|
||||||
*readPipe = PR_AllocFileDesc(pipefd[0], &_pr_fileMethods);
|
*readPipe = PR_AllocFileDesc(pipefd[0], &_pr_pipeMethods);
|
||||||
if (NULL == *readPipe) {
|
if (NULL == *readPipe) {
|
||||||
close(pipefd[0]);
|
close(pipefd[0]);
|
||||||
close(pipefd[1]);
|
close(pipefd[1]);
|
||||||
return PR_FAILURE;
|
return PR_FAILURE;
|
||||||
}
|
}
|
||||||
*writePipe = PR_AllocFileDesc(pipefd[1], &_pr_fileMethods);
|
*writePipe = PR_AllocFileDesc(pipefd[1], &_pr_pipeMethods);
|
||||||
if (NULL == *writePipe) {
|
if (NULL == *writePipe) {
|
||||||
PR_Close(*readPipe);
|
PR_Close(*readPipe);
|
||||||
close(pipefd[1]);
|
close(pipefd[1]);
|
||||||
|
|
|
@ -43,17 +43,20 @@ void PR_CALLBACK pl_FDDestructor(PRFileDesc *fd)
|
||||||
*/
|
*/
|
||||||
static PRStatus PR_CALLBACK pl_TopClose (PRFileDesc *fd)
|
static PRStatus PR_CALLBACK pl_TopClose (PRFileDesc *fd)
|
||||||
{
|
{
|
||||||
PRStatus status;
|
PRFileDesc *top;
|
||||||
PR_ASSERT(fd != NULL);
|
PR_ASSERT(fd != NULL);
|
||||||
PR_ASSERT(fd->lower != NULL);
|
PR_ASSERT(fd->lower != NULL);
|
||||||
PR_ASSERT(fd->secret == NULL);
|
PR_ASSERT(fd->secret == NULL);
|
||||||
PR_ASSERT(fd->methods->file_type == PR_DESC_LAYERED);
|
PR_ASSERT(fd->methods->file_type == PR_DESC_LAYERED);
|
||||||
|
|
||||||
status = (fd->lower->methods->close)(fd->lower);
|
if (fd->higher != NULL)
|
||||||
fd->lower = fd->higher = NULL;
|
{
|
||||||
|
PR_SetError(PR_BAD_DESCRIPTOR_ERROR, 0);
|
||||||
fd->dtor(fd);
|
return PR_FAILURE;
|
||||||
return status;
|
}
|
||||||
|
top = PR_PopIOLayer(fd, PR_TOP_IO_LAYER);
|
||||||
|
top->dtor(top);
|
||||||
|
return (fd->methods->close)(fd);
|
||||||
}
|
}
|
||||||
|
|
||||||
static PRInt32 PR_CALLBACK pl_DefRead (PRFileDesc *fd, void *buf, PRInt32 amount)
|
static PRInt32 PR_CALLBACK pl_DefRead (PRFileDesc *fd, void *buf, PRInt32 amount)
|
||||||
|
|
|
@ -92,6 +92,7 @@ PRStatus PR_CALLBACK _PR_SocketGetSocketOption(PRFileDesc *fd, PRSocketOptionDat
|
||||||
case PR_SockOpt_Reuseaddr:
|
case PR_SockOpt_Reuseaddr:
|
||||||
case PR_SockOpt_Keepalive:
|
case PR_SockOpt_Keepalive:
|
||||||
case PR_SockOpt_NoDelay:
|
case PR_SockOpt_NoDelay:
|
||||||
|
case PR_SockOpt_Broadcast:
|
||||||
{
|
{
|
||||||
#ifdef WIN32 /* Winsock */
|
#ifdef WIN32 /* Winsock */
|
||||||
BOOL value;
|
BOOL value;
|
||||||
|
@ -242,6 +243,7 @@ PRStatus PR_CALLBACK _PR_SocketSetSocketOption(PRFileDesc *fd, const PRSocketOpt
|
||||||
case PR_SockOpt_Reuseaddr:
|
case PR_SockOpt_Reuseaddr:
|
||||||
case PR_SockOpt_Keepalive:
|
case PR_SockOpt_Keepalive:
|
||||||
case PR_SockOpt_NoDelay:
|
case PR_SockOpt_NoDelay:
|
||||||
|
case PR_SockOpt_Broadcast:
|
||||||
{
|
{
|
||||||
#ifdef WIN32 /* Winsock */
|
#ifdef WIN32 /* Winsock */
|
||||||
BOOL value;
|
BOOL value;
|
||||||
|
@ -454,14 +456,14 @@ PRStatus _PR_MapOptionName(
|
||||||
0, SO_LINGER, SO_REUSEADDR, SO_KEEPALIVE, SO_RCVBUF, SO_SNDBUF,
|
0, SO_LINGER, SO_REUSEADDR, SO_KEEPALIVE, SO_RCVBUF, SO_SNDBUF,
|
||||||
IP_TTL, IP_TOS, IP_ADD_MEMBERSHIP, IP_DROP_MEMBERSHIP,
|
IP_TTL, IP_TOS, IP_ADD_MEMBERSHIP, IP_DROP_MEMBERSHIP,
|
||||||
IP_MULTICAST_IF, IP_MULTICAST_TTL, IP_MULTICAST_LOOP,
|
IP_MULTICAST_IF, IP_MULTICAST_TTL, IP_MULTICAST_LOOP,
|
||||||
TCP_NODELAY, TCP_MAXSEG
|
TCP_NODELAY, TCP_MAXSEG, SO_BROADCAST
|
||||||
};
|
};
|
||||||
static PRInt32 socketLevels[PR_SockOpt_Last] =
|
static PRInt32 socketLevels[PR_SockOpt_Last] =
|
||||||
{
|
{
|
||||||
0, SOL_SOCKET, SOL_SOCKET, SOL_SOCKET, SOL_SOCKET, SOL_SOCKET,
|
0, SOL_SOCKET, SOL_SOCKET, SOL_SOCKET, SOL_SOCKET, SOL_SOCKET,
|
||||||
IPPROTO_IP, IPPROTO_IP, IPPROTO_IP, IPPROTO_IP,
|
IPPROTO_IP, IPPROTO_IP, IPPROTO_IP, IPPROTO_IP,
|
||||||
IPPROTO_IP, IPPROTO_IP, IPPROTO_IP,
|
IPPROTO_IP, IPPROTO_IP, IPPROTO_IP,
|
||||||
IPPROTO_TCP, IPPROTO_TCP
|
IPPROTO_TCP, IPPROTO_TCP, SOL_SOCKET
|
||||||
};
|
};
|
||||||
|
|
||||||
if ((optname < PR_SockOpt_Linger)
|
if ((optname < PR_SockOpt_Linger)
|
||||||
|
|
|
@ -80,6 +80,7 @@ struct hostent {
|
||||||
#define INADDR_ANY kOTAnyInetAddress
|
#define INADDR_ANY kOTAnyInetAddress
|
||||||
#define SOL_SOCKET XTI_GENERIC // Any type of socket
|
#define SOL_SOCKET XTI_GENERIC // Any type of socket
|
||||||
#define SO_REUSEADDR IP_REUSEADDR
|
#define SO_REUSEADDR IP_REUSEADDR
|
||||||
|
#define SO_BROADCAST IP_BROADCAST
|
||||||
#define MSG_PEEK 0x2 // Just look at a message waiting, donÕt actually read it.
|
#define MSG_PEEK 0x2 // Just look at a message waiting, donÕt actually read it.
|
||||||
|
|
||||||
typedef unsigned long u_long;
|
typedef unsigned long u_long;
|
||||||
|
|
|
@ -30,11 +30,14 @@ CSRCS = \
|
||||||
unix.c \
|
unix.c \
|
||||||
unix_errors.c \
|
unix_errors.c \
|
||||||
uxproces.c \
|
uxproces.c \
|
||||||
uxwrap.c \
|
|
||||||
uxpoll.c \
|
|
||||||
uxshm.c \
|
uxshm.c \
|
||||||
|
uxwrap.c \
|
||||||
$(NULL)
|
$(NULL)
|
||||||
|
|
||||||
|
ifneq ($(USE_PTHREADS),1)
|
||||||
|
CSRCS += uxpoll.c
|
||||||
|
endif
|
||||||
|
|
||||||
PTH_USER_CSRCS = \
|
PTH_USER_CSRCS = \
|
||||||
pthreads_user.c \
|
pthreads_user.c \
|
||||||
$(NULL)
|
$(NULL)
|
||||||
|
|
|
@ -24,9 +24,12 @@ CSRCS = \
|
||||||
uxproces.c \
|
uxproces.c \
|
||||||
uxshm.c \
|
uxshm.c \
|
||||||
uxwrap.c \
|
uxwrap.c \
|
||||||
uxpoll.c \
|
|
||||||
$(NULL)
|
$(NULL)
|
||||||
|
|
||||||
|
ifneq ($(USE_PTHREADS),1)
|
||||||
|
CSRCS += uxpoll.c
|
||||||
|
endif
|
||||||
|
|
||||||
PTH_USER_CSRCS = \
|
PTH_USER_CSRCS = \
|
||||||
pthreads_user.c \
|
pthreads_user.c \
|
||||||
$(NULL)
|
$(NULL)
|
||||||
|
|
|
@ -27,6 +27,8 @@
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <sys/utsname.h>
|
||||||
|
|
||||||
#ifdef _PR_POLL_AVAILABLE
|
#ifdef _PR_POLL_AVAILABLE
|
||||||
#include <poll.h>
|
#include <poll.h>
|
||||||
|
@ -3691,6 +3693,25 @@ PR_IMPLEMENT(PRStatus) _MD_gethostname(char *name, PRUint32 namelen)
|
||||||
return PR_FAILURE;
|
return PR_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PR_IMPLEMENT(PRStatus) _MD_getsysinfo(PRSysInfo cmd, char *name, PRUint32 namelen)
|
||||||
|
{
|
||||||
|
struct utsname info;
|
||||||
|
|
||||||
|
PR_ASSERT((cmd == PR_SI_SYSNAME) || (cmd == PR_SI_RELEASE));
|
||||||
|
|
||||||
|
if (uname(&info) == -1) {
|
||||||
|
_PR_MD_MAP_DEFAULT_ERROR(errno);
|
||||||
|
return PR_FAILURE;
|
||||||
|
}
|
||||||
|
if (PR_SI_SYSNAME == cmd)
|
||||||
|
(void)PR_snprintf(name, namelen, info.sysname);
|
||||||
|
else if (PR_SI_RELEASE == cmd)
|
||||||
|
(void)PR_snprintf(name, namelen, info.release);
|
||||||
|
else
|
||||||
|
return PR_FAILURE;
|
||||||
|
return PR_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
*******************************************************************
|
*******************************************************************
|
||||||
*
|
*
|
||||||
|
|
|
@ -18,8 +18,7 @@
|
||||||
|
|
||||||
#if defined(_PR_PTHREADS)
|
#if defined(_PR_PTHREADS)
|
||||||
|
|
||||||
/* Some compilers don't like an empty source file. */
|
#error "This file should not be compiled"
|
||||||
static int dummy = 0;
|
|
||||||
|
|
||||||
#else /* defined(_PR_PTHREADS) */
|
#else /* defined(_PR_PTHREADS) */
|
||||||
|
|
||||||
|
@ -681,5 +680,5 @@ PRInt32 _MD_pr_poll(PRPollDesc *pds, PRIntn npds, PRIntervalTime timeout)
|
||||||
|
|
||||||
#endif /* defined(_PR_PTHREADS) */
|
#endif /* defined(_PR_PTHREADS) */
|
||||||
|
|
||||||
/* pruxpoll.c */
|
/* uxpoll.c */
|
||||||
|
|
||||||
|
|
|
@ -551,6 +551,75 @@ PRStatus _MD_WindowsGetHostName(char *name, PRUint32 namelen)
|
||||||
return PR_FAILURE;
|
return PR_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PRStatus _MD_WindowsGetSysInfo(PRSysInfo cmd, char *name, PRUint32 namelen)
|
||||||
|
{
|
||||||
|
OSVERSIONINFO osvi;
|
||||||
|
|
||||||
|
PR_ASSERT((cmd == PR_SI_SYSNAME) || (cmd == PR_SI_RELEASE));
|
||||||
|
|
||||||
|
ZeroMemory(&osvi, sizeof(OSVERSIONINFO));
|
||||||
|
osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
|
||||||
|
|
||||||
|
if (! GetVersionEx (&osvi) ) {
|
||||||
|
_PR_MD_MAP_DEFAULT_ERROR(GetLastError());
|
||||||
|
return PR_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (osvi.dwPlatformId) {
|
||||||
|
case VER_PLATFORM_WIN32_NT:
|
||||||
|
if (PR_SI_SYSNAME == cmd)
|
||||||
|
(void)PR_snprintf(name, namelen, "Windows_NT");
|
||||||
|
else if (PR_SI_RELEASE == cmd)
|
||||||
|
(void)PR_snprintf(name, namelen, "%d.%d",osvi.dwMajorVersion,
|
||||||
|
osvi.dwMinorVersion);
|
||||||
|
break;
|
||||||
|
case VER_PLATFORM_WIN32_WINDOWS:
|
||||||
|
if (PR_SI_SYSNAME == cmd) {
|
||||||
|
if ((osvi.dwMajorVersion > 4) ||
|
||||||
|
((osvi.dwMajorVersion == 4) && (osvi.dwMinorVersion > 0)))
|
||||||
|
(void)PR_snprintf(name, namelen, "Windows_98");
|
||||||
|
else
|
||||||
|
(void)PR_snprintf(name, namelen, "Windows_95");
|
||||||
|
} else if (PR_SI_RELEASE == cmd) {
|
||||||
|
(void)PR_snprintf(name, namelen, "%d.%d",osvi.dwMajorVersion,
|
||||||
|
osvi.dwMinorVersion);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
if (PR_SI_SYSNAME == cmd)
|
||||||
|
(void)PR_snprintf(name, namelen, "Windows_Unknown");
|
||||||
|
else if (PR_SI_RELEASE == cmd)
|
||||||
|
(void)PR_snprintf(name, namelen, "%d.%d",0,0);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return PR_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
PRStatus _MD_WindowsGetReleaseName(char *name, PRUint32 namelen)
|
||||||
|
{
|
||||||
|
OSVERSIONINFO osvi;
|
||||||
|
|
||||||
|
ZeroMemory(&osvi, sizeof(OSVERSIONINFO));
|
||||||
|
osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
|
||||||
|
|
||||||
|
if (! GetVersionEx (&osvi) ) {
|
||||||
|
_PR_MD_MAP_DEFAULT_ERROR(GetLastError());
|
||||||
|
return PR_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (osvi.dwPlatformId) {
|
||||||
|
case VER_PLATFORM_WIN32_NT:
|
||||||
|
case VER_PLATFORM_WIN32_WINDOWS:
|
||||||
|
(void)PR_snprintf(name, namelen, "%d.%d",osvi.dwMajorVersion,
|
||||||
|
osvi.dwMinorVersion);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
(void)PR_snprintf(name, namelen, "%d.%d",0,0);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return PR_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
**********************************************************************
|
**********************************************************************
|
||||||
*
|
*
|
||||||
|
|
|
@ -874,51 +874,27 @@ _PR_MD_RMDIR(const char *name)
|
||||||
PRStatus
|
PRStatus
|
||||||
_PR_MD_LOCKFILE(PRInt32 f)
|
_PR_MD_LOCKFILE(PRInt32 f)
|
||||||
{
|
{
|
||||||
PRInt32 rv;
|
PRStatus rc = PR_SUCCESS;
|
||||||
|
DWORD rv;
|
||||||
|
|
||||||
/*
|
rv = LockFile( (HANDLE)f,
|
||||||
* loop trying to LockFile(),
|
0l, 0l,
|
||||||
* pause for a few miliseconds when can't get the lock
|
0x0l, 0xffffffffl );
|
||||||
* and try again
|
if ( rv == 0 ) {
|
||||||
*/
|
DWORD rc = GetLastError();
|
||||||
for( rv = FALSE; rv == FALSE; /* do nothing */ )
|
PR_LOG( _pr_io_lm, PR_LOG_ERROR,
|
||||||
{
|
("_PR_MD_LOCKFILE() failed. Error: %d", rc ));
|
||||||
|
rc = PR_FAILURE;
|
||||||
rv = LockFile( (HANDLE) f,
|
}
|
||||||
0l, 0l,
|
|
||||||
0x7fffffff, 0xffffffff );
|
return rc;
|
||||||
if ( rv == FALSE )
|
|
||||||
{
|
|
||||||
DWORD rc = GetLastError();
|
|
||||||
Sleep( 50 ); // Sleep() a few milisecs and try again.
|
|
||||||
}
|
|
||||||
} /* end for() */
|
|
||||||
return PR_SUCCESS;
|
|
||||||
} /* end _PR_MD_LOCKFILE() */
|
} /* end _PR_MD_LOCKFILE() */
|
||||||
|
|
||||||
PRStatus
|
PRStatus
|
||||||
_PR_MD_TLOCKFILE(PRInt32 f)
|
_PR_MD_TLOCKFILE(PRInt32 f)
|
||||||
{
|
{
|
||||||
PRInt32 rv;
|
PR_SetError( PR_NOT_IMPLEMENTED_ERROR, 0 );
|
||||||
|
return PR_FAILURE;
|
||||||
/*
|
|
||||||
* loop trying to LockFile(),
|
|
||||||
* pause for a few miliseconds when can't get the lock
|
|
||||||
* and try again
|
|
||||||
*/
|
|
||||||
for( rv = FALSE; rv == FALSE; /* do nothing */ )
|
|
||||||
{
|
|
||||||
|
|
||||||
rv = LockFile( (HANDLE) f,
|
|
||||||
0l, 0l,
|
|
||||||
0x7fffffff, 0xffffffff );
|
|
||||||
if ( rv == FALSE )
|
|
||||||
{
|
|
||||||
DWORD rc = GetLastError();
|
|
||||||
Sleep( 50 ); // Sleep() a few milisecs and try again.
|
|
||||||
}
|
|
||||||
} /* end for() */
|
|
||||||
return PR_SUCCESS;
|
|
||||||
} /* end _PR_MD_TLOCKFILE() */
|
} /* end _PR_MD_TLOCKFILE() */
|
||||||
|
|
||||||
|
|
||||||
|
@ -929,7 +905,7 @@ _PR_MD_UNLOCKFILE(PRInt32 f)
|
||||||
|
|
||||||
rv = UnlockFile( (HANDLE) f,
|
rv = UnlockFile( (HANDLE) f,
|
||||||
0l, 0l,
|
0l, 0l,
|
||||||
0x7fffffff, 0xffffffff );
|
0x0l, 0xffffffffl );
|
||||||
|
|
||||||
if ( rv )
|
if ( rv )
|
||||||
{
|
{
|
||||||
|
@ -937,7 +913,7 @@ _PR_MD_UNLOCKFILE(PRInt32 f)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int err = GetLastError();
|
_PR_MD_MAP_DEFAULT_ERROR(GetLastError());
|
||||||
return PR_FAILURE;
|
return PR_FAILURE;
|
||||||
}
|
}
|
||||||
} /* end _PR_MD_UNLOCKFILE() */
|
} /* end _PR_MD_UNLOCKFILE() */
|
||||||
|
|
|
@ -68,17 +68,19 @@ PR_IMPLEMENT(PRStatus) PR_GetSystemInfo(PRSysInfo cmd, char *buf, PRUint32 bufle
|
||||||
|
|
||||||
case PR_SI_SYSNAME:
|
case PR_SI_SYSNAME:
|
||||||
/* Return the operating system name */
|
/* Return the operating system name */
|
||||||
|
#if defined(XP_UNIX) || defined(WIN32)
|
||||||
|
if (PR_FAILURE == _PR_MD_GETSYSINFO(cmd, buf, (PRUintn)buflen))
|
||||||
|
return PR_FAILURE;
|
||||||
|
#else
|
||||||
(void)PR_snprintf(buf, buflen, _PR_SI_SYSNAME);
|
(void)PR_snprintf(buf, buflen, _PR_SI_SYSNAME);
|
||||||
|
#endif
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PR_SI_RELEASE:
|
case PR_SI_RELEASE:
|
||||||
/* Return the version of the operating system */
|
/* Return the version of the operating system */
|
||||||
#if defined(XP_UNIX)
|
#if defined(XP_UNIX) || defined(WIN32)
|
||||||
{
|
if (PR_FAILURE == _PR_MD_GETSYSINFO(cmd, buf, (PRUintn)buflen))
|
||||||
struct utsname info;
|
return PR_FAILURE;
|
||||||
uname(&info);
|
|
||||||
(void)PR_snprintf(buf, buflen, info.release);
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
#if defined(XP_OS2)
|
#if defined(XP_OS2)
|
||||||
{
|
{
|
||||||
|
@ -101,6 +103,10 @@ PR_IMPLEMENT(PRStatus) PR_GetSystemInfo(PRSysInfo cmd, char *buf, PRUint32 bufle
|
||||||
/* Return the architecture of the machine (ie. x86, mips, alpha, ...)*/
|
/* Return the architecture of the machine (ie. x86, mips, alpha, ...)*/
|
||||||
(void)PR_snprintf(buf, buflen, _PR_SI_ARCHITECTURE);
|
(void)PR_snprintf(buf, buflen, _PR_SI_ARCHITECTURE);
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);
|
||||||
|
return PR_FAILURE;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
return PR_SUCCESS;
|
return PR_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,8 +69,11 @@ static PRVersionDescription prVersionDescription_libnspr3 =
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Version information for the 'ident' and 'what commands
|
* Version information for the 'ident' and 'what commands
|
||||||
|
*
|
||||||
|
* NOTE: the first component of the concatenated rcsid string
|
||||||
|
* must not end in a '$' to prevent rcs keyword substitution.
|
||||||
*/
|
*/
|
||||||
static char rcsid[] = "$Version: NSPR " PR_VERSION _DEBUG_STRING
|
static char rcsid[] = "$Header: NSPR " PR_VERSION _DEBUG_STRING
|
||||||
" " _BUILD_STRING " $";
|
" " _BUILD_STRING " $";
|
||||||
static char sccsid[] = "@(#)NSPR " PR_VERSION _DEBUG_STRING
|
static char sccsid[] = "@(#)NSPR " PR_VERSION _DEBUG_STRING
|
||||||
" " _BUILD_STRING;
|
" " _BUILD_STRING;
|
||||||
|
|
|
@ -2639,6 +2639,7 @@ static PRStatus pt_GetSocketOption(PRFileDesc *fd, PRSocketOptionData *data)
|
||||||
case PR_SockOpt_Reuseaddr:
|
case PR_SockOpt_Reuseaddr:
|
||||||
case PR_SockOpt_Keepalive:
|
case PR_SockOpt_Keepalive:
|
||||||
case PR_SockOpt_NoDelay:
|
case PR_SockOpt_NoDelay:
|
||||||
|
case PR_SockOpt_Broadcast:
|
||||||
{
|
{
|
||||||
PRIntn value;
|
PRIntn value;
|
||||||
length = sizeof(PRIntn);
|
length = sizeof(PRIntn);
|
||||||
|
@ -2757,6 +2758,7 @@ static PRStatus pt_SetSocketOption(PRFileDesc *fd, const PRSocketOptionData *dat
|
||||||
case PR_SockOpt_Reuseaddr:
|
case PR_SockOpt_Reuseaddr:
|
||||||
case PR_SockOpt_Keepalive:
|
case PR_SockOpt_Keepalive:
|
||||||
case PR_SockOpt_NoDelay:
|
case PR_SockOpt_NoDelay:
|
||||||
|
case PR_SockOpt_Broadcast:
|
||||||
{
|
{
|
||||||
PRIntn value = (data->value.reuse_addr) ? 1 : 0;
|
PRIntn value = (data->value.reuse_addr) ? 1 : 0;
|
||||||
rv = setsockopt(
|
rv = setsockopt(
|
||||||
|
@ -2865,6 +2867,39 @@ static PRIOMethods _pr_file_methods = {
|
||||||
(PRSetsocketoptionFN)_PR_InvalidStatus
|
(PRSetsocketoptionFN)_PR_InvalidStatus
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static PRIOMethods _pr_pipe_methods = {
|
||||||
|
PR_DESC_PIPE,
|
||||||
|
pt_Close,
|
||||||
|
pt_Read,
|
||||||
|
pt_Write,
|
||||||
|
pt_Available_s,
|
||||||
|
pt_Available64_s,
|
||||||
|
pt_Fsync,
|
||||||
|
(PRSeekFN)_PR_InvalidInt,
|
||||||
|
(PRSeek64FN)_PR_InvalidInt64,
|
||||||
|
(PRFileInfoFN)_PR_InvalidStatus,
|
||||||
|
(PRFileInfo64FN)_PR_InvalidStatus,
|
||||||
|
(PRWritevFN)_PR_InvalidInt,
|
||||||
|
(PRConnectFN)_PR_InvalidStatus,
|
||||||
|
(PRAcceptFN)_PR_InvalidDesc,
|
||||||
|
(PRBindFN)_PR_InvalidStatus,
|
||||||
|
(PRListenFN)_PR_InvalidStatus,
|
||||||
|
(PRShutdownFN)_PR_InvalidStatus,
|
||||||
|
(PRRecvFN)_PR_InvalidInt,
|
||||||
|
(PRSendFN)_PR_InvalidInt,
|
||||||
|
(PRRecvfromFN)_PR_InvalidInt,
|
||||||
|
(PRSendtoFN)_PR_InvalidInt,
|
||||||
|
pt_Poll,
|
||||||
|
(PRAcceptreadFN)_PR_InvalidInt,
|
||||||
|
(PRTransmitfileFN)_PR_InvalidInt,
|
||||||
|
(PRGetsocknameFN)_PR_InvalidStatus,
|
||||||
|
(PRGetpeernameFN)_PR_InvalidStatus,
|
||||||
|
(PRGetsockoptFN)_PR_InvalidStatus,
|
||||||
|
(PRSetsockoptFN)_PR_InvalidStatus,
|
||||||
|
(PRGetsocketoptionFN)_PR_InvalidStatus,
|
||||||
|
(PRSetsocketoptionFN)_PR_InvalidStatus
|
||||||
|
};
|
||||||
|
|
||||||
static PRIOMethods _pr_tcp_methods = {
|
static PRIOMethods _pr_tcp_methods = {
|
||||||
PR_DESC_SOCKET_TCP,
|
PR_DESC_SOCKET_TCP,
|
||||||
pt_Close,
|
pt_Close,
|
||||||
|
@ -3017,6 +3052,9 @@ static PRFileDesc *pt_SetMethods(PRIntn osfd, PRDescType type)
|
||||||
flags |= _PR_FCNTL_FLAGS;
|
flags |= _PR_FCNTL_FLAGS;
|
||||||
(void)fcntl(osfd, F_SETFL, flags);
|
(void)fcntl(osfd, F_SETFL, flags);
|
||||||
break;
|
break;
|
||||||
|
case PR_DESC_PIPE:
|
||||||
|
fd->methods = PR_GetPipeMethods();
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -3029,6 +3067,11 @@ PR_IMPLEMENT(const PRIOMethods*) PR_GetFileMethods()
|
||||||
return &_pr_file_methods;
|
return &_pr_file_methods;
|
||||||
} /* PR_GetFileMethods */
|
} /* PR_GetFileMethods */
|
||||||
|
|
||||||
|
PR_IMPLEMENT(const PRIOMethods*) PR_GetPipeMethods()
|
||||||
|
{
|
||||||
|
return &_pr_pipe_methods;
|
||||||
|
} /* PR_GetFileMethods */
|
||||||
|
|
||||||
PR_IMPLEMENT(const PRIOMethods*) PR_GetTCPMethods()
|
PR_IMPLEMENT(const PRIOMethods*) PR_GetTCPMethods()
|
||||||
{
|
{
|
||||||
return &_pr_tcp_methods;
|
return &_pr_tcp_methods;
|
||||||
|
@ -3658,7 +3701,7 @@ PR_IMPLEMENT(PRStatus) PR_CreatePipe(
|
||||||
PR_SetError(PR_UNKNOWN_ERROR, errno);
|
PR_SetError(PR_UNKNOWN_ERROR, errno);
|
||||||
return PR_FAILURE;
|
return PR_FAILURE;
|
||||||
}
|
}
|
||||||
*readPipe = pt_SetMethods(pipefd[0], PR_DESC_FILE);
|
*readPipe = pt_SetMethods(pipefd[0], PR_DESC_PIPE);
|
||||||
if (NULL == *readPipe)
|
if (NULL == *readPipe)
|
||||||
{
|
{
|
||||||
close(pipefd[0]);
|
close(pipefd[0]);
|
||||||
|
@ -3668,7 +3711,7 @@ PR_IMPLEMENT(PRStatus) PR_CreatePipe(
|
||||||
flags = fcntl(pipefd[0], F_GETFL, 0);
|
flags = fcntl(pipefd[0], F_GETFL, 0);
|
||||||
flags |= _PR_FCNTL_FLAGS;
|
flags |= _PR_FCNTL_FLAGS;
|
||||||
(void)fcntl(pipefd[0], F_SETFL, flags);
|
(void)fcntl(pipefd[0], F_SETFL, flags);
|
||||||
*writePipe = pt_SetMethods(pipefd[1], PR_DESC_FILE);
|
*writePipe = pt_SetMethods(pipefd[1], PR_DESC_PIPE);
|
||||||
if (NULL == *writePipe)
|
if (NULL == *writePipe)
|
||||||
{
|
{
|
||||||
PR_Close(*readPipe);
|
PR_Close(*readPipe);
|
||||||
|
|
|
@ -593,7 +593,7 @@ PR_IMPLEMENT(PRThreadPriority) PR_GetThreadPriority(const PRThread *thred)
|
||||||
|
|
||||||
PR_IMPLEMENT(void) PR_SetThreadPriority(PRThread *thred, PRThreadPriority newPri)
|
PR_IMPLEMENT(void) PR_SetThreadPriority(PRThread *thred, PRThreadPriority newPri)
|
||||||
{
|
{
|
||||||
PRIntn rv;
|
PRIntn rv = -1;
|
||||||
|
|
||||||
PR_ASSERT(NULL != thred);
|
PR_ASSERT(NULL != thred);
|
||||||
|
|
||||||
|
@ -605,7 +605,6 @@ PR_IMPLEMENT(void) PR_SetThreadPriority(PRThread *thred, PRThreadPriority newPri
|
||||||
#if defined(_PR_DCETHREADS)
|
#if defined(_PR_DCETHREADS)
|
||||||
rv = pthread_setprio(thred->id, pt_PriorityMap(newPri));
|
rv = pthread_setprio(thred->id, pt_PriorityMap(newPri));
|
||||||
/* pthread_setprio returns the old priority */
|
/* pthread_setprio returns the old priority */
|
||||||
PR_ASSERT(-1 != rv);
|
|
||||||
#elif defined(_POSIX_THREAD_PRIORITY_SCHEDULING)
|
#elif defined(_POSIX_THREAD_PRIORITY_SCHEDULING)
|
||||||
if (EPERM != pt_schedpriv)
|
if (EPERM != pt_schedpriv)
|
||||||
{
|
{
|
||||||
|
@ -613,19 +612,23 @@ PR_IMPLEMENT(void) PR_SetThreadPriority(PRThread *thred, PRThreadPriority newPri
|
||||||
struct sched_param schedule;
|
struct sched_param schedule;
|
||||||
|
|
||||||
rv = pthread_getschedparam(thred->id, &policy, &schedule);
|
rv = pthread_getschedparam(thred->id, &policy, &schedule);
|
||||||
PR_ASSERT(0 == rv);
|
if(0 == rv) {
|
||||||
schedule.sched_priority = pt_PriorityMap(newPri);
|
schedule.sched_priority = pt_PriorityMap(newPri);
|
||||||
rv = pthread_setschedparam(thred->id, policy, &schedule);
|
rv = pthread_setschedparam(thred->id, policy, &schedule);
|
||||||
if (EPERM == rv)
|
if (EPERM == rv)
|
||||||
{
|
{
|
||||||
pt_schedpriv = EPERM;
|
pt_schedpriv = EPERM;
|
||||||
PR_LOG(_pr_thread_lm, PR_LOG_MIN,
|
PR_LOG(_pr_thread_lm, PR_LOG_MIN,
|
||||||
("PR_SetThreadPriority: no thread scheduling privilege"));
|
("PR_SetThreadPriority: no thread scheduling privilege"));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
if (rv != 0)
|
||||||
|
rv = -1;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
thred->priority = newPri;
|
if (rv != -1)
|
||||||
|
thred->priority = newPri;
|
||||||
} /* PR_SetThreadPriority */
|
} /* PR_SetThreadPriority */
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
|
|
|
@ -249,7 +249,6 @@ int err;
|
||||||
PR_IMPLEMENT(void)
|
PR_IMPLEMENT(void)
|
||||||
PR_RWLock_Wlock(PRRWLock *rwlock)
|
PR_RWLock_Wlock(PRRWLock *rwlock)
|
||||||
{
|
{
|
||||||
PRInt32 lock_acquired = 0;
|
|
||||||
#if defined(DEBUG)
|
#if defined(DEBUG)
|
||||||
PRThread *me = PR_GetCurrentThread();
|
PRThread *me = PR_GetCurrentThread();
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -57,6 +57,7 @@ CSRCS = \
|
||||||
dtoa.c \
|
dtoa.c \
|
||||||
errcodes.c \
|
errcodes.c \
|
||||||
exit.c \
|
exit.c \
|
||||||
|
fdcach.c \
|
||||||
fileio.c \
|
fileio.c \
|
||||||
foreign.c \
|
foreign.c \
|
||||||
forktest.c \
|
forktest.c \
|
||||||
|
@ -267,7 +268,8 @@ endif
|
||||||
ifeq ($(OS_ARCH), HP-UX)
|
ifeq ($(OS_ARCH), HP-UX)
|
||||||
LDOPTS += -z -Wl,+s,+b,$(ABSOLUTE_LIB_DIR)
|
LDOPTS += -z -Wl,+s,+b,$(ABSOLUTE_LIB_DIR)
|
||||||
ifeq ($(USE_64),1)
|
ifeq ($(USE_64),1)
|
||||||
LDOPTS += -L/usr/lib/pa20_64 -lpthread +DD64
|
LDOPTS += +DA2.0W
|
||||||
|
EXTRA_LIBS = -lpthread
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
|
|
@ -765,6 +765,7 @@ static void PR_CALLBACK Server(void *arg)
|
||||||
|
|
||||||
server->listener = PR_Socket(domain, SOCK_STREAM, protocol);
|
server->listener = PR_Socket(domain, SOCK_STREAM, protocol);
|
||||||
|
|
||||||
|
memset(&serverAddress, 0, sizeof(serverAddress));
|
||||||
rv = PR_InitializeNetAddr(PR_IpAddrAny, DEFAULT_PORT, &serverAddress);
|
rv = PR_InitializeNetAddr(PR_IpAddrAny, DEFAULT_PORT, &serverAddress);
|
||||||
|
|
||||||
rv = PR_Bind(server->listener, &serverAddress);
|
rv = PR_Bind(server->listener, &serverAddress);
|
||||||
|
|
|
@ -66,6 +66,11 @@ int main()
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
status = PR_SetFDInheritable(in_pipe[0], PR_FALSE);
|
||||||
|
if (status == PR_FAILURE) {
|
||||||
|
fprintf(stderr, "PR_SetFDInheritable failed\n");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
status = PR_SetFDInheritable(in_pipe[1], PR_TRUE);
|
status = PR_SetFDInheritable(in_pipe[1], PR_TRUE);
|
||||||
if (status == PR_FAILURE) {
|
if (status == PR_FAILURE) {
|
||||||
fprintf(stderr, "PR_SetFDInheritable failed\n");
|
fprintf(stderr, "PR_SetFDInheritable failed\n");
|
||||||
|
@ -76,6 +81,11 @@ int main()
|
||||||
fprintf(stderr, "PR_SetFDInheritable failed\n");
|
fprintf(stderr, "PR_SetFDInheritable failed\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
status = PR_SetFDInheritable(out_pipe[1], PR_FALSE);
|
||||||
|
if (status == PR_FAILURE) {
|
||||||
|
fprintf(stderr, "PR_SetFDInheritable failed\n");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
attr = PR_NewProcessAttr();
|
attr = PR_NewProcessAttr();
|
||||||
if (attr == NULL) {
|
if (attr == NULL) {
|
||||||
|
|
|
@ -162,6 +162,7 @@ int main(int argc, char **argv)
|
||||||
failed_already=1;
|
failed_already=1;
|
||||||
goto exit_now;
|
goto exit_now;
|
||||||
}
|
}
|
||||||
|
memset(&addr, 0, sizeof(addr));
|
||||||
addr.inet.family = PR_AF_INET;
|
addr.inet.family = PR_AF_INET;
|
||||||
addr.inet.ip = PR_htonl(PR_INADDR_ANY);
|
addr.inet.ip = PR_htonl(PR_INADDR_ANY);
|
||||||
addr.inet.port = PR_htons(0);
|
addr.inet.port = PR_htons(0);
|
||||||
|
|
|
@ -105,6 +105,7 @@ int main(int argc, char **argv)
|
||||||
if (!debug_mode) failed_already=1;
|
if (!debug_mode) failed_already=1;
|
||||||
goto exit_now;
|
goto exit_now;
|
||||||
}
|
}
|
||||||
|
memset(&addr, 0, sizeof(addr));
|
||||||
addr.inet.family = PR_AF_INET;
|
addr.inet.family = PR_AF_INET;
|
||||||
addr.inet.ip = PR_htonl(PR_INADDR_ANY);
|
addr.inet.ip = PR_htonl(PR_INADDR_ANY);
|
||||||
addr.inet.port = PR_htons(0);
|
addr.inet.port = PR_htons(0);
|
||||||
|
|
|
@ -934,6 +934,7 @@ static void PR_CALLBACK Server(void *arg)
|
||||||
|
|
||||||
server->listener = PR_Socket(domain, SOCK_STREAM, protocol);
|
server->listener = PR_Socket(domain, SOCK_STREAM, protocol);
|
||||||
|
|
||||||
|
memset(&serverAddress, 0, sizeof(serverAddress));
|
||||||
rv = PR_InitializeNetAddr(PR_IpAddrAny, DEFAULT_PORT, &serverAddress);
|
rv = PR_InitializeNetAddr(PR_IpAddrAny, DEFAULT_PORT, &serverAddress);
|
||||||
|
|
||||||
rv = PR_Bind(server->listener, &serverAddress);
|
rv = PR_Bind(server->listener, &serverAddress);
|
||||||
|
|
|
@ -83,6 +83,7 @@ dlltest
|
||||||
dtoa
|
dtoa
|
||||||
errcodes
|
errcodes
|
||||||
exit
|
exit
|
||||||
|
fdcach
|
||||||
fileio
|
fileio
|
||||||
foreign
|
foreign
|
||||||
fsync
|
fsync
|
||||||
|
@ -162,6 +163,8 @@ version
|
||||||
writev
|
writev
|
||||||
xnotify"
|
xnotify"
|
||||||
|
|
||||||
|
rval=0
|
||||||
|
|
||||||
OBJDIR=`basename $PWD`
|
OBJDIR=`basename $PWD`
|
||||||
echo "\nNSPR Test Results - $OBJDIR\n"
|
echo "\nNSPR Test Results - $OBJDIR\n"
|
||||||
echo "BEGIN\t\t\t`date`"
|
echo "BEGIN\t\t\t`date`"
|
||||||
|
@ -176,7 +179,10 @@ if [ 0 = $? ] ; then
|
||||||
echo "\t\t\tPassed";
|
echo "\t\t\tPassed";
|
||||||
else
|
else
|
||||||
echo "\t\t\tFAILED";
|
echo "\t\t\tFAILED";
|
||||||
|
rval=1
|
||||||
fi;
|
fi;
|
||||||
echo "\nEND TEST: $prog\n" >> ${LOGFILE} 2>&1
|
echo "\nEND TEST: $prog\n" >> ${LOGFILE} 2>&1
|
||||||
done
|
done
|
||||||
echo "END\t\t\t`date`"
|
echo "END\t\t\t`date`"
|
||||||
|
|
||||||
|
exit $rval
|
||||||
|
|
|
@ -66,6 +66,7 @@ int main()
|
||||||
fprintf(stderr, "write to broken pipe failed but with wrong errno: %d\n", errno);
|
fprintf(stderr, "write to broken pipe failed but with wrong errno: %d\n", errno);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
close(pipefd[1]);
|
||||||
printf("write to broken pipe failed with EPIPE, as expected\n");
|
printf("write to broken pipe failed with EPIPE, as expected\n");
|
||||||
printf("PASSED\n");
|
printf("PASSED\n");
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -84,6 +84,7 @@ PRIntn main(PRIntn argc, char *argv)
|
||||||
|
|
||||||
"PR_SockOpt_NoDelay", /* don't delay send to coalesce packets */
|
"PR_SockOpt_NoDelay", /* don't delay send to coalesce packets */
|
||||||
"PR_SockOpt_MaxSegment", /* maximum segment size */
|
"PR_SockOpt_MaxSegment", /* maximum segment size */
|
||||||
|
"PR_SockOpt_Broadcast", /* Enable broadcast */
|
||||||
"PR_SockOpt_Last"
|
"PR_SockOpt_Last"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -143,6 +144,10 @@ PRIntn main(PRIntn argc, char *argv)
|
||||||
value = &ttl;
|
value = &ttl;
|
||||||
size = &ttlsize;
|
size = &ttlsize;
|
||||||
break;
|
break;
|
||||||
|
case PR_SockOpt_Broadcast:
|
||||||
|
value = &boolean;
|
||||||
|
size = &booleansize;
|
||||||
|
break;
|
||||||
case PR_SockOpt_IpTypeOfService: /* type of service and precedence */
|
case PR_SockOpt_IpTypeOfService: /* type of service and precedence */
|
||||||
case PR_SockOpt_AddMember: /* add an IP group membership */
|
case PR_SockOpt_AddMember: /* add an IP group membership */
|
||||||
case PR_SockOpt_DropMember: /* drop an IP group membership */
|
case PR_SockOpt_DropMember: /* drop an IP group membership */
|
||||||
|
@ -218,6 +223,10 @@ PRIntn main(PRIntn argc, char *argv)
|
||||||
data.value.max_segment = segment;
|
data.value.max_segment = segment;
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
|
case PR_SockOpt_Broadcast:
|
||||||
|
fd = udp;
|
||||||
|
data.value.broadcast = PR_TRUE;
|
||||||
|
break;
|
||||||
default: continue;
|
default: continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -239,6 +248,8 @@ PRIntn main(PRIntn argc, char *argv)
|
||||||
rv = PR_GetSocketOption(fd, &data);
|
rv = PR_GetSocketOption(fd, &data);
|
||||||
if (PR_FAILURE == rv) Failed("PR_GetSocketOption()", tag[option]);
|
if (PR_FAILURE == rv) Failed("PR_GetSocketOption()", tag[option]);
|
||||||
}
|
}
|
||||||
|
PR_Close(udp);
|
||||||
|
PR_Close(tcp);
|
||||||
}
|
}
|
||||||
#ifndef XP_MAC
|
#ifndef XP_MAC
|
||||||
PR_fprintf(err, "%s\n", (failed) ? "FAILED" : "PASSED");
|
PR_fprintf(err, "%s\n", (failed) ? "FAILED" : "PASSED");
|
||||||
|
|
|
@ -59,6 +59,12 @@ int main()
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
status = PR_SetFDInheritable(sock[0], PR_FALSE);
|
||||||
|
if (status == PR_FAILURE) {
|
||||||
|
fprintf(stderr, "PR_SetFDInheritable failed: (%d, %d)\n",
|
||||||
|
PR_GetError(), PR_GetOSError());
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
status = PR_SetFDInheritable(sock[1], PR_TRUE);
|
status = PR_SetFDInheritable(sock[1], PR_TRUE);
|
||||||
if (status == PR_FAILURE) {
|
if (status == PR_FAILURE) {
|
||||||
fprintf(stderr, "PR_SetFDInheritable failed: (%d, %d)\n",
|
fprintf(stderr, "PR_SetFDInheritable failed: (%d, %d)\n",
|
||||||
|
|
|
@ -41,7 +41,9 @@ typedef struct _DataRecord {
|
||||||
|
|
||||||
#define MAX_THREAD_CNT 100
|
#define MAX_THREAD_CNT 100
|
||||||
#define DEFAULT_THREAD_CNT 4
|
#define DEFAULT_THREAD_CNT 4
|
||||||
#define DEFAULT_DATA_CNT 4
|
#define DEFAULT_DATA_CNT 100
|
||||||
|
#define DEFAULT_LOOP_CNT 10000
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* sum of the first n numbers using the formula n*(n+1)/2
|
* sum of the first n numbers using the formula n*(n+1)/2
|
||||||
*/
|
*/
|
||||||
|
@ -52,6 +54,7 @@ typedef struct stack_data {
|
||||||
PRStack *list2;
|
PRStack *list2;
|
||||||
PRInt32 initial_data_value;
|
PRInt32 initial_data_value;
|
||||||
PRInt32 data_cnt;
|
PRInt32 data_cnt;
|
||||||
|
PRInt32 loops;
|
||||||
} stack_data;
|
} stack_data;
|
||||||
|
|
||||||
static void stackop(void *arg);
|
static void stackop(void *arg);
|
||||||
|
@ -71,11 +74,12 @@ PRIntn main(PRIntn argc, char **argv)
|
||||||
|
|
||||||
PRInt32 thread_cnt = DEFAULT_THREAD_CNT;
|
PRInt32 thread_cnt = DEFAULT_THREAD_CNT;
|
||||||
PRInt32 data_cnt = DEFAULT_DATA_CNT;
|
PRInt32 data_cnt = DEFAULT_DATA_CNT;
|
||||||
|
PRInt32 loops = DEFAULT_LOOP_CNT;
|
||||||
PRThread **threads;
|
PRThread **threads;
|
||||||
stack_data *thread_args;
|
stack_data *thread_args;
|
||||||
|
|
||||||
PLOptStatus os;
|
PLOptStatus os;
|
||||||
PLOptState *opt = PL_CreateOptState(argc, argv, "dt:c:");
|
PLOptState *opt = PL_CreateOptState(argc, argv, "dt:c:l:");
|
||||||
|
|
||||||
while (PL_OPT_EOL != (os = PL_GetNextOpt(opt)))
|
while (PL_OPT_EOL != (os = PL_GetNextOpt(opt)))
|
||||||
{
|
{
|
||||||
|
@ -91,6 +95,9 @@ PRIntn main(PRIntn argc, char **argv)
|
||||||
case 'c': /* data count */
|
case 'c': /* data count */
|
||||||
data_cnt = atoi(opt->value);
|
data_cnt = atoi(opt->value);
|
||||||
break;
|
break;
|
||||||
|
case 'l': /* loop count */
|
||||||
|
loops = atoi(opt->value);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -127,6 +134,7 @@ PRIntn main(PRIntn argc, char **argv)
|
||||||
|
|
||||||
thread_args[cnt].list1 = list1;
|
thread_args[cnt].list1 = list1;
|
||||||
thread_args[cnt].list2 = list2;
|
thread_args[cnt].list2 = list2;
|
||||||
|
thread_args[cnt].loops = loops;
|
||||||
thread_args[cnt].data_cnt = data_cnt;
|
thread_args[cnt].data_cnt = data_cnt;
|
||||||
thread_args[cnt].initial_data_value = 1 + cnt * data_cnt;
|
thread_args[cnt].initial_data_value = 1 + cnt * data_cnt;
|
||||||
|
|
||||||
|
@ -211,7 +219,7 @@ PRIntn main(PRIntn argc, char **argv)
|
||||||
|
|
||||||
static void stackop(void *thread_arg)
|
static void stackop(void *thread_arg)
|
||||||
{
|
{
|
||||||
PRInt32 val, cnt, index;
|
PRInt32 val, cnt, index, loops;
|
||||||
DataRecord *Items, *Item;
|
DataRecord *Items, *Item;
|
||||||
PRStack *list1, *list2;
|
PRStack *list1, *list2;
|
||||||
PRStackElem *node;
|
PRStackElem *node;
|
||||||
|
@ -219,6 +227,7 @@ static void stackop(void *thread_arg)
|
||||||
|
|
||||||
val = arg->initial_data_value;
|
val = arg->initial_data_value;
|
||||||
cnt = arg->data_cnt;
|
cnt = arg->data_cnt;
|
||||||
|
loops = arg->loops;
|
||||||
list1 = arg->list1;
|
list1 = arg->list1;
|
||||||
list2 = arg->list2;
|
list2 = arg->list2;
|
||||||
|
|
||||||
|
@ -244,6 +253,22 @@ static void stackop(void *thread_arg)
|
||||||
index++;
|
index++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* pop data records from list1 and add them back to list1
|
||||||
|
* generates contention for the stack accesses
|
||||||
|
*/
|
||||||
|
while (loops-- > 0) {
|
||||||
|
cnt = arg->data_cnt;
|
||||||
|
while (cnt-- > 0) {
|
||||||
|
node = PR_StackPop(list1);
|
||||||
|
if (node == NULL) {
|
||||||
|
PR_fprintf(errhandle, "Error - PR_StackPop returned NULL\n");
|
||||||
|
PR_ASSERT(node != NULL);
|
||||||
|
PR_ProcessExit(3);
|
||||||
|
}
|
||||||
|
PR_StackPush(list1, node);
|
||||||
|
}
|
||||||
|
}
|
||||||
/*
|
/*
|
||||||
* remove the data records from list1 and add them to list2
|
* remove the data records from list1 and add them to list2
|
||||||
*/
|
*/
|
||||||
|
|
Загрузка…
Ссылка в новой задаче