Merged NSPRPUB_19980508_BRANCH to the main trunk. The 19980508

branch is a temporary branch for us to copy the latest changes
from our internal development tree to the public mozilla tree.
This commit is contained in:
wtc 1998-05-14 18:09:56 +00:00
Родитель 49d0a3bce9
Коммит c8d051dcbb
28 изменённых файлов: 324 добавлений и 86 удалений

Просмотреть файл

@ -37,7 +37,7 @@ G++INCLUDES =
#OS_LIBS = -lsocket -lnsl -lgen -lresolv #OS_LIBS = -lsocket -lnsl -lgen -lresolv
PLATFORM_FLAGS = -Xa -fullwarn -DSONY PLATFORM_FLAGS = -Xa -fullwarn -DSONY
PORT_FLAGS = -DSYSV -DSVR4 -D__svr4 -D__svr4__ -D_PR_LOCAL_THREADS_ONLY PORT_FLAGS = -DSYSV -DSVR4 -D__svr4 -D__svr4__ -D_PR_LOCAL_THREADS_ONLY -DHAVE_SVID_GETTOD
OS_CFLAGS = $(PLATFORM_FLAGS) $(PORT_FLAGS) OS_CFLAGS = $(PLATFORM_FLAGS) $(PORT_FLAGS)

Просмотреть файл

@ -74,7 +74,7 @@ DEFINES += -D_X86_
DEFINES += -D_PR_GLOBAL_THREADS_ONLY DEFINES += -D_PR_GLOBAL_THREADS_ONLY
# Name of the binary code directories # Name of the binary code directories
ifeq ($(CPU_ARCH),x386) ifeq ($(CPU_ARCH),x86)
ifdef MOZ_LITE ifdef MOZ_LITE
OBJDIR_NAME = $(subst OS2,NAV,$(OS_CONFIG))$(OBJDIR_TAG).OBJ OBJDIR_NAME = $(subst OS2,NAV,$(OS_CONFIG))$(OBJDIR_TAG).OBJ
else else

Просмотреть файл

@ -53,7 +53,7 @@ MKSHLIB = $(LD) -G -z defs -h $(@:$(OBJDIR)/%.so=%.so)
#DSO_LDOPTS = -G -W l,-Blargedynsym #DSO_LDOPTS = -G -W l,-Blargedynsym
endif endif
ODD_CFLAGS += -DSVR4 -DSNI -DRELIANTUNIX -Dsinix -D_SVID_GETTOD ODD_CFLAGS += -DSVR4 -DSNI -DRELIANTUNIX -Dsinix -DHAVE_SVID_GETTOD
# On SINIX 5.43, need to define IP_MULTICAST in order to get the # On SINIX 5.43, need to define IP_MULTICAST in order to get the
# IP multicast macro and struct definitions in netinet/in.h. # IP multicast macro and struct definitions in netinet/in.h.

Просмотреть файл

@ -105,11 +105,6 @@ endif
ifeq (5.5,$(findstring 5.5,$(OS_RELEASE))) ifeq (5.5,$(findstring 5.5,$(OS_RELEASE)))
OS_DEFINES += -DSOLARIS2_5 OS_DEFINES += -DSOLARIS2_5
SOL_CFLAGS = -D_SVID_GETTOD
endif
ifeq ($(OS_RELEASE),5.6)
SOL_CFLAGS = -D_SVID_GETTOD
endif endif
ifneq ($(LOCAL_THREADS_ONLY),1) ifneq ($(LOCAL_THREADS_ONLY),1)

Просмотреть файл

@ -29,6 +29,22 @@ ifdef PR_CLIENT_BUILD_WINDOWS
SHELL = $(MOZ_TOOLS_FLIPPED)/bin/shmsdos.exe SHELL = $(MOZ_TOOLS_FLIPPED)/bin/shmsdos.exe
endif endif
#
# On NT, we use static thread local storage by default because it
# gives us better performance. However, we can't use static TLS
# on Alpha NT because the Alpha version of MSVC does not seem to
# support the -GT flag, which is necessary to make static TLS safe
# for fibers.
#
# On Win95, we use the TlsXXX() functions by default because that
# allows us to load the NSPR DLL at run time using LoadLibrary().
#
ifeq ($(OS_TARGET),WINNT)
ifneq ($(CPU_ARCH),ALPHA)
USE_STATIC_TLS = 1
endif
endif
CC = cl CC = cl
CCC = cl CCC = cl
LINK = link LINK = link
@ -96,17 +112,31 @@ endif
endif endif
DEFINES += -DWIN32 DEFINES += -DWIN32
ifeq ($(USE_STATIC_TLS),1)
DEFINES += -D_PR_USE_STATIC_TLS
endif
#
# NSPR uses fibers on NT. Therefore, if we use static local
# storage (i.e., __declspec(thread) variables), we need the -GT
# flag to turn off certain compiler optimizations so that fibers
# can use static TLS safely.
#
# Also, we optimize for Pentium (-G5) on NT.
#
ifeq ($(OS_TARGET),WINNT) ifeq ($(OS_TARGET),WINNT)
# ifeq ($(USE_STATIC_TLS),1)
# Win NT needs -GT so that fibers can work
#
OS_CFLAGS += -GT OS_CFLAGS += -GT
endif
ifeq ($(CPU_ARCH),x86)
OS_CFLAGS += -G5
endif
DEFINES += -DWINNT DEFINES += -DWINNT
else else
DEFINES += -DWIN95 -D_PR_GLOBAL_THREADS_ONLY DEFINES += -DWIN95 -D_PR_GLOBAL_THREADS_ONLY
endif endif
ifeq ($(CPU_ARCH),x386) ifeq ($(CPU_ARCH),x86)
DEFINES += -D_X86_ DEFINES += -D_X86_
else else
ifeq ($(CPU_ARCH),MIPS) ifeq ($(CPU_ARCH),MIPS)
@ -122,7 +152,7 @@ endif
# Name of the binary code directories # Name of the binary code directories
ifeq ($(CPU_ARCH),x386) ifeq ($(CPU_ARCH),x86)
CPU_ARCH_TAG = CPU_ARCH_TAG =
else else
CPU_ARCH_TAG = $(CPU_ARCH) CPU_ARCH_TAG = $(CPU_ARCH)

Просмотреть файл

@ -144,7 +144,7 @@ endif
ifeq ($(OS_ARCH), WINNT) ifeq ($(OS_ARCH), WINNT)
CPU_ARCH := $(shell uname -p) CPU_ARCH := $(shell uname -p)
ifeq ($(CPU_ARCH),I386) ifeq ($(CPU_ARCH),I386)
CPU_ARCH = x386 CPU_ARCH = x86
endif endif
else else
# #
@ -167,7 +167,7 @@ ifeq ($(OS_ARCH), Windows_NT)
# MKS's uname -m returns "586" on a Pentium machine. # MKS's uname -m returns "586" on a Pentium machine.
# #
ifneq (,$(findstring 86,$(CPU_ARCH))) ifneq (,$(findstring 86,$(CPU_ARCH)))
CPU_ARCH = x386 CPU_ARCH = x86
endif endif
else else
# #
@ -181,7 +181,7 @@ ifeq ($(OS_ARCH), CYGWIN32_NT)
# GNU-Win32's uname -m returns "i686" on a Pentium Pro machine. # GNU-Win32's uname -m returns "i686" on a Pentium Pro machine.
# #
ifneq (,$(findstring 86,$(CPU_ARCH))) ifneq (,$(findstring 86,$(CPU_ARCH)))
CPU_ARCH = x386 CPU_ARCH = x86
endif endif
endif endif
endif endif

Просмотреть файл

@ -85,7 +85,7 @@ DLL := $(addprefix $(OBJDIR)/, $(DLL))
endif endif
CPU_ARCH = x386 CPU_ARCH = x86
OS_CFLAGS = -ml -3 -bd -zc -zu -bt=windows -d_X86_ -dWIN16 -d_WINDLL OS_CFLAGS = -ml -3 -bd -zc -zu -bt=windows -d_X86_ -dWIN16 -d_WINDLL
OS_EXE_CFLAGS = -ml -3 -bt=windows -d_X86_ -dWIN16 OS_EXE_CFLAGS = -ml -3 -bt=windows -d_X86_ -dWIN16
OS_LIB_FLAGS = -c -iro -n OS_LIB_FLAGS = -c -iro -n

Просмотреть файл

@ -402,11 +402,6 @@ PR_IMPLEMENT(void) _PR_MD_ENSURE_TLS();
#define _MD_CURRENT_CPU() pThreadLocalStorage->_pr_currentCPU #define _MD_CURRENT_CPU() pThreadLocalStorage->_pr_currentCPU
#define _MD_SET_CURRENT_CPU(_cpu) _PR_MD_ENSURE_TLS(); pThreadLocalStorage->_pr_currentCPU = (_cpu) #define _MD_SET_CURRENT_CPU(_cpu) _PR_MD_ENSURE_TLS(); pThreadLocalStorage->_pr_currentCPU = (_cpu)
/* lth. #define _MD_SET_INTSOFF(_val) (_pr_ints_off = (_val)) */
/* lth. #define _MD_GET_INTSOFF() _pr_ints_off */
/* lth. #define _MD_INCREMENT_INTSOFF() (_pr_ints_off++) */
/* lth. #define _MD_DECREMENT_INTSOFF() (_pr_ints_off--) */
/* --- Scheduler stuff --- */ /* --- Scheduler stuff --- */
#define LOCK_SCHEDULER() 0 #define LOCK_SCHEDULER() 0
#define UNLOCK_SCHEDULER() 0 #define UNLOCK_SCHEDULER() 0

Просмотреть файл

@ -464,6 +464,17 @@ extern PRStatus _MD_MemUnmap(void *addr, PRUint32 size);
extern PRStatus _MD_CloseFileMap(struct PRFileMap *fmap); extern PRStatus _MD_CloseFileMap(struct PRFileMap *fmap);
#define _MD_CLOSE_FILE_MAP _MD_CloseFileMap #define _MD_CLOSE_FILE_MAP _MD_CloseFileMap
/*
* The standard (XPG4) gettimeofday() (from BSD) takes two arguments.
* On some SVR4 derivatives, gettimeofday() takes only one argument.
* The GETTIMEOFDAY macro is intended to hide this difference.
*/
#ifdef HAVE_SVID_GETTOD
#define GETTIMEOFDAY(tp) gettimeofday(tp)
#else
#define GETTIMEOFDAY(tp) gettimeofday((tp), NULL)
#endif
#if defined(LINUX) && defined(_PR_PTHREADS) && !(__GLIBC__ >= 2) #if defined(LINUX) && defined(_PR_PTHREADS) && !(__GLIBC__ >= 2)
#define _PR_NEED_FAKE_POLL #define _PR_NEED_FAKE_POLL
#endif #endif

Просмотреть файл

@ -45,8 +45,6 @@
#define HAVE_SOCKET_KEEPALIVE #define HAVE_SOCKET_KEEPALIVE
#define _PR_HAVE_ATOMIC_OPS #define _PR_HAVE_ATOMIC_OPS
typedef char * caddr_t;
/* --- Common User-Thread/Native-Thread Definitions --------------------- */ /* --- Common User-Thread/Native-Thread Definitions --------------------- */
extern struct PRLock *_pr_schedLock; extern struct PRLock *_pr_schedLock;

Просмотреть файл

@ -39,9 +39,6 @@
#define HAVE_SOCKET_KEEPALIVE #define HAVE_SOCKET_KEEPALIVE
#define _PR_HAVE_ATOMIC_OPS #define _PR_HAVE_ATOMIC_OPS
typedef char * caddr_t;
typedef int ptrdiff_t; /* used in prnetdb.h */
/* --- Common User-Thread/Native-Thread Definitions --------------------- */ /* --- Common User-Thread/Native-Thread Definitions --------------------- */
/* --- Globals --- */ /* --- Globals --- */
@ -378,15 +375,15 @@ extern __declspec(thread) struct PRThread *_pr_currentThread;
extern __declspec(thread) struct PRThread *_pr_thread_last_run; extern __declspec(thread) struct PRThread *_pr_thread_last_run;
#define _MD_LAST_THREAD() _pr_thread_last_run #define _MD_LAST_THREAD() _pr_thread_last_run
#define _MD_SET_LAST_THREAD(_thread) (_pr_thread_last_run = (0)) #define _MD_SET_LAST_THREAD(_thread) (_pr_thread_last_run = 0)
extern __declspec(thread) struct _PRCPU *_pr_currentCPU; extern __declspec(thread) struct _PRCPU *_pr_currentCPU;
#define _MD_CURRENT_CPU() _pr_currentCPU #define _MD_CURRENT_CPU() _pr_currentCPU
#define _MD_SET_CURRENT_CPU(_cpu) (_pr_currentCPU = (0)) #define _MD_SET_CURRENT_CPU(_cpu) (_pr_currentCPU = 0)
#else /* _PR_USE_STATIC_TLS */ #else /* _PR_USE_STATIC_TLS */
extern DWORD _pr_currentThreadIndex; extern DWORD _pr_currentThreadIndex;
#define _MD_CURRENT_THREAD() ((PRThread *) TlsGetValue(_pr_currentThreadIndex)) #define _MD_CURRENT_THREAD() ((PRThread *) TlsGetValue(_pr_currentThreadIndex))
#define _MD_SET_CURRENT_THREAD(_thread) TlsSetValue(_pr_currentThreadIndex, _thread) #define _MD_SET_CURRENT_THREAD(_thread) TlsSetValue(_pr_currentThreadIndex, (_thread))
extern DWORD _pr_lastThreadIndex; extern DWORD _pr_lastThreadIndex;
#define _MD_LAST_THREAD() ((PRThread *) TlsGetValue(_pr_lastThreadIndex)) #define _MD_LAST_THREAD() ((PRThread *) TlsGetValue(_pr_lastThreadIndex))
@ -397,12 +394,6 @@ extern DWORD _pr_currentCPUIndex;
#define _MD_SET_CURRENT_CPU(_cpu) TlsSetValue(_pr_currentCPUIndex, 0) #define _MD_SET_CURRENT_CPU(_cpu) TlsSetValue(_pr_currentCPUIndex, 0)
#endif /* _PR_USE_STATIC_TLS */ #endif /* _PR_USE_STATIC_TLS */
// wtc. extern __declspec(thread) PRUintn _pr_ints_off;
// lth. #define _MD_SET_INTSOFF(_val) (_pr_ints_off = (_val))
// lth. #define _MD_GET_INTSOFF() _pr_ints_off
// lth. #define _MD_INCREMENT_INTSOFF() (_pr_ints_off++)
// lth. #define _MD_DECREMENT_INTSOFF() (_pr_ints_off--)
/* --- Scheduler stuff --- */ /* --- Scheduler stuff --- */
#define LOCK_SCHEDULER() 0 #define LOCK_SCHEDULER() 0
#define UNLOCK_SCHEDULER() 0 #define UNLOCK_SCHEDULER() 0

Просмотреть файл

@ -50,10 +50,6 @@
#define HAVE_SOCKET_KEEPALIVE #define HAVE_SOCKET_KEEPALIVE
#define _PR_HAVE_ATOMIC_OPS #define _PR_HAVE_ATOMIC_OPS
typedef char * caddr_t;
typedef int ptrdiff_t; /* used in prnetdb.h */
/* --- Common User-Thread/Native-Thread Definitions --------------------- */ /* --- Common User-Thread/Native-Thread Definitions --------------------- */
/* --- Globals --- */ /* --- Globals --- */
@ -374,6 +370,8 @@ extern PRStatus _PR_KillWindowsProcess(struct PRProcess *process);
/* --- Native-Thread Specific Definitions ------------------------------- */ /* --- Native-Thread Specific Definitions ------------------------------- */
#ifdef _PR_USE_STATIC_TLS
extern __declspec(thread) struct PRThread *_pr_current_fiber; extern __declspec(thread) struct PRThread *_pr_current_fiber;
#define _MD_CURRENT_THREAD() _pr_current_fiber #define _MD_CURRENT_THREAD() _pr_current_fiber
#define _MD_SET_CURRENT_THREAD(_thread) (_pr_current_fiber = (_thread)) #define _MD_SET_CURRENT_THREAD(_thread) (_pr_current_fiber = (_thread))
@ -389,8 +387,26 @@ extern __declspec(thread) struct _PRCPU *_pr_current_cpu;
extern __declspec(thread) PRUintn _pr_ints_off; extern __declspec(thread) PRUintn _pr_ints_off;
#define _MD_SET_INTSOFF(_val) (_pr_ints_off = (_val)) #define _MD_SET_INTSOFF(_val) (_pr_ints_off = (_val))
#define _MD_GET_INTSOFF() _pr_ints_off #define _MD_GET_INTSOFF() _pr_ints_off
#define _MD_INCREMENT_INTSOFF() (_pr_ints_off++)
#define _MD_DECREMENT_INTSOFF() (_pr_ints_off--) #else /* _PR_USE_STATIC_TLS */
extern DWORD _pr_currentFiberIndex;
#define _MD_CURRENT_THREAD() ((PRThread *) TlsGetValue(_pr_currentFiberIndex))
#define _MD_SET_CURRENT_THREAD(_thread) TlsSetValue(_pr_currentFiberIndex, (_thread))
extern DWORD _pr_lastFiberIndex;
#define _MD_LAST_THREAD() ((PRThread *) TlsGetValue(_pr_lastFiberIndex))
#define _MD_SET_LAST_THREAD(_thread) TlsSetValue(_pr_lastFiberIndex, (_thread))
extern DWORD _pr_currentCPUIndex;
#define _MD_CURRENT_CPU() ((struct _PRCPU *) TlsGetValue(_pr_currentCPUIndex))
#define _MD_SET_CURRENT_CPU(_cpu) TlsSetValue(_pr_currentCPUIndex, (_cpu))
extern DWORD _pr_intsOffIndex;
#define _MD_SET_INTSOFF(_val) TlsSetValue(_pr_intsOffIndex, (LPVOID) (_val))
#define _MD_GET_INTSOFF() ((PRUintn) TlsGetValue(_pr_intsOffIndex))
#endif /* _PR_USE_STATIC_TLS */
/* --- Initialization stuff --- */ /* --- Initialization stuff --- */
#define _MD_INIT_LOCKS() #define _MD_INIT_LOCKS()

Просмотреть файл

@ -59,6 +59,12 @@ struct PRCListStr {
#define PR_NEXT_LINK(_e) \ #define PR_NEXT_LINK(_e) \
((_e)->next) ((_e)->next)
/* /*
** Return the element preceding element "_e"
*/
#define PR_PREV_LINK(_e) \
((_e)->prev)
/*
** Append an element "_e" to the end of the list "_l" ** Append an element "_e" to the end of the list "_l"
*/ */
#define PR_APPEND_LINK(_e,_l) PR_INSERT_BEFORE(_e,_l) #define PR_APPEND_LINK(_e,_l) PR_INSERT_BEFORE(_e,_l)

Просмотреть файл

@ -24,30 +24,91 @@
PR_BEGIN_EXTERN_C PR_BEGIN_EXTERN_C
/* /*
** prlog.h -- Declare interfaces to NSPR's Logging service
** **
** Define in your environment a NSPR_LOG_MODULES variable. The value of ** NSPR provides a logging service that is used by NSPR itself and is
** this variable has the form: ** available to client programs.
**
** To use the service from a client program, you should create a
** PRLogModuleInfo structure by calling PR_NewLogModule(). After
** creating the LogModule, you can write to the log using the PR_LOG()
** macro.
**
** Initialization of the log service is handled by NSPR initialization.
**
** At execution time, you must enable the log service. To enable the
** log service, set the environment variable: NSPR_LOG_MODULES
** variable.
**
** NSPR_LOG_MODULES variable has the form:
** **
** <moduleName>:<value>[, <moduleName>:<value>]* ** <moduleName>:<value>[, <moduleName>:<value>]*
** **
** where moduleName is one of named modules that support debugging (see ** Where:
** the header file for a particular module for more specific ** <moduleName> is the name passed to PR_NewLogModule().
** information). Value is one of the enum PRLogModuleLevel's legal ** <value> is a numeric constant, e.g. 5. This value is the maximum
** values. ** value of a log event, enumerated by PRLogModuleLevel, that you want
** written to the log.
**
** For example: to record all events of greater value than or equal to
** PR_LOG_ERROR for a LogModule names "gizmo", say:
**
** set NSPR_LOG_MODULES=gizmo:2
**
** Note that you must specify the numeric value of PR_LOG_ERROR.
**
** Special LogModule names are provided for controlling NSPR's log
** service at execution time. These controls should be set in the
** NSPR_LOG_MODULES environment variable at execution time to affect
** NSPR's log service for your application.
**
** The special LogModule "all" enables all LogModules. To enable all
** LogModule calls to PR_LOG(), say:
**
** set NSPR_LOG_MODULES=all:5
**
** The special LogModule name "sync" tells the NSPR log service to do
** unbuffered logging.
**
** The special LogModule name "buffsize:<size>" tells NSPR to set the
** log buffer to <size>.
** **
** Special modules exist for controlling the logging facility: ** The environment variable NSPR_LOG_FILE specifies the log file to use
** sync -- do unbuffered logging ** unless the default of "stderr" is acceptable.
** bufsize:size -- use a buffer of "size" bytes
**
** Define in your environment NSPR_LOG_FILE to specify the log file to
** use unless the default of "stderr" is acceptable.
** **
** To put log messages in your programs, use the PR_LOG macro: ** To put log messages in your programs, use the PR_LOG macro:
** **
** PR_LOG(<module>, <level>, (<printfString>, <args>*)); ** PR_LOG(<module>, <level>, (<printfString>, <args>*));
** **
** Where <module> is the address of a PRLogModuleInfo structure, and ** Where <module> is the address of a PRLogModuleInfo structure, and
** <level> is one of the following levels: ** <level> is one of the levels defined by the enumeration:
** PRLogModuleLevel. <args> is a printf() style of argument list. That
** is: (fmtstring, ...).
**
** Example:
**
** main() {
** PRIntn one = 1;
** PRLogModuleInfo * myLm = PR_NewLogModule("gizmo");
** PR_LOG( myLm, PR_LOG_ALWAYS, ("Log this! %d\n", one));
** return;
** }
**
** Note the use of printf() style arguments as the third agrument(s) to
** PR_LOG().
**
** After compiling and linking you application, set the environment:
**
** SET NSPR_LOGMODULES=gizmo:5
** SET NSPR_LOG_FILE=logfile.txt
**
** When you execute your application, the string "Log this! 1" will be
** written to the file "logfile.txt".
**
** Note to NSPR engineers: a number of PRLogModuleInfo structures are
** defined and initialized in prinit.c. See this module for ideas on
** what to log where.
**
*/ */
typedef enum PRLogModuleLevel { typedef enum PRLogModuleLevel {

Просмотреть файл

@ -249,6 +249,52 @@ void _PR_LogCleanup(void)
#endif /* PR_LOGGING */ #endif /* PR_LOGGING */
static void _PR_SetLogModuleLevel( PRLogModuleInfo *lm )
{
#ifdef PR_LOGGING
char *ev;
ev = PR_GetEnv("NSPR_LOG_MODULES");
if (ev && ev[0]) {
char module[64];
PRBool isSync = PR_FALSE;
PRIntn evlen = strlen(ev), pos = 0;
PRInt32 bufSize = DEFAULT_BUF_SIZE;
while (pos < evlen) {
PRIntn level = 1, count = 0, delta = 0;
PRLogModuleInfo *lm = logModules;
PRBool skip_modcheck;
count = sscanf(&ev[pos], "%64[A-Za-z0-9]%n:%d%n",
module, &delta, &level, &delta);
pos += delta;
if (count == 0) break;
/*
** If count == 2, then we got module and level. If count
** == 1, then level defaults to 1 (module enabled).
*/
skip_modcheck = (0 == strcasecmp (module, "all")) ? PR_TRUE : PR_FALSE;
while (lm != NULL)
{
if (skip_modcheck)
lm->level = (PRLogModuleLevel)level;
else if (strcasecmp(module, lm->name) == 0)
{
lm->level = level;
break;
}
lm = lm->next;
}
/*found:*/
count = sscanf(&ev[pos], " , %n", &delta);
pos += delta;
if (count == -1) break;
}
}
#endif /* PR_LOGGING */
} /* end _PR_SetLogModuleLevel() */
PR_IMPLEMENT(PRLogModuleInfo*) PR_NewLogModule(const char *name) PR_IMPLEMENT(PRLogModuleInfo*) PR_NewLogModule(const char *name)
{ {
PRLogModuleInfo *lm; PRLogModuleInfo *lm;
@ -262,6 +308,7 @@ PR_IMPLEMENT(PRLogModuleInfo*) PR_NewLogModule(const char *name)
lm->next = logModules; lm->next = logModules;
logModules = lm; logModules = lm;
} }
_PR_SetLogModuleLevel(lm);
return lm; return lm;
} }

Просмотреть файл

@ -946,6 +946,8 @@ PR_LoadStaticLibrary(const char *name, const PRStaticLinkTable *slt)
PRLibrary *lm=NULL; PRLibrary *lm=NULL;
PRLibrary* result = NULL; PRLibrary* result = NULL;
if (!_pr_initialized) _PR_ImplicitInitialization();
/* See if library is already loaded */ /* See if library is already loaded */
PR_EnterMonitor(pr_linker_lock); PR_EnterMonitor(pr_linker_lock);

Просмотреть файл

@ -238,11 +238,7 @@ PRUint32 ticks = PR_TicksPerSecond();
tmo.tv_nsec); tmo.tv_nsec);
/* pthreads wants this in absolute time, off we go ... */ /* pthreads wants this in absolute time, off we go ... */
#if defined(SOLARIS) && defined(_SVID_GETTOD) (void)GETTIMEOFDAY(&now);
(void)gettimeofday(&now);
#else
(void)gettimeofday(&now, NULL);
#endif
/* that one's usecs, this one's nsecs - grrrr! */ /* that one's usecs, this one's nsecs - grrrr! */
tmo.tv_sec += now.tv_sec; tmo.tv_sec += now.tv_sec;
tmo.tv_nsec += (PT_NANOPERMICRO * now.tv_usec); tmo.tv_nsec += (PT_NANOPERMICRO * now.tv_usec);

Просмотреть файл

@ -799,7 +799,7 @@ _pr_solx86_clock_gettime(clockid_t clock_id, struct timespec *tp)
return -1; return -1;
} }
gettimeofday(&tv); gettimeofday(&tv, NULL);
tp->tv_sec = tv.tv_sec; tp->tv_sec = tv.tv_sec;
tp->tv_nsec = tv.tv_usec * 1000; tp->tv_nsec = tv.tv_usec * 1000;
return 0; return 0;

Просмотреть файл

@ -2857,11 +2857,7 @@ PR_Now(void)
struct timeval tv; struct timeval tv;
PRInt64 s, us, s2us; PRInt64 s, us, s2us;
#if (defined(SOLARIS) && defined(_SVID_GETTOD)) || defined(SONY) GETTIMEOFDAY(&tv);
gettimeofday(&tv);
#else
gettimeofday(&tv, 0);
#endif
LL_I2L(s2us, PR_USEC_PER_SEC); LL_I2L(s2us, PR_USEC_PER_SEC);
LL_I2L(s, tv.tv_sec); LL_I2L(s, tv.tv_sec);
LL_I2L(us, tv.tv_usec); LL_I2L(us, tv.tv_usec);
@ -2875,11 +2871,7 @@ PRIntervalTime _PR_UNIX_GetInterval()
struct timeval time; struct timeval time;
PRIntervalTime ticks; PRIntervalTime ticks;
#if defined(_SVID_GETTOD) || defined(SONY) (void)GETTIMEOFDAY(&time); /* fallicy of course */
(void)gettimeofday(&time); /* fallicy of course */
#else
(void)gettimeofday(&time, NULL); /* fallicy of course */
#endif
ticks = (PRUint32)time.tv_sec * PR_MSEC_PER_SEC; /* that's in milliseconds */ ticks = (PRUint32)time.tv_sec * PR_MSEC_PER_SEC; /* that's in milliseconds */
ticks += (PRUint32)time.tv_usec / PR_USEC_PER_MSEC; /* so's that */ ticks += (PRUint32)time.tv_usec / PR_USEC_PER_MSEC; /* so's that */
return ticks; return ticks;

Просмотреть файл

@ -45,7 +45,13 @@ static struct _MDLock _pr_recycle_lock;
static PRInt32 _pr_recycle_array[RECYCLE_SIZE]; static PRInt32 _pr_recycle_array[RECYCLE_SIZE];
static PRInt32 _pr_recycle_tail = 0; static PRInt32 _pr_recycle_tail = 0;
#ifdef _PR_USE_STATIC_TLS
__declspec(thread) PRThread *_pr_io_restarted_io = NULL; __declspec(thread) PRThread *_pr_io_restarted_io = NULL;
#else
DWORD _pr_io_restartedIOIndex; /* The thread local storage slot for each
* thread is initialized to NULL. */
#endif
PRBool _nt_version_gets_lockfile_completion; PRBool _nt_version_gets_lockfile_completion;
struct _MDLock _pr_ioq_lock; struct _MDLock _pr_ioq_lock;
@ -471,7 +477,11 @@ _NT_ResumeIO(PRThread *thread, PRIntervalTime ticks)
PRBool fWait = PR_TRUE; PRBool fWait = PR_TRUE;
if (!_PR_IS_NATIVE_THREAD(thread)) { if (!_PR_IS_NATIVE_THREAD(thread)) {
#ifdef _PR_USE_STATIC_TLS
_pr_io_restarted_io = thread; _pr_io_restarted_io = thread;
#else
TlsSetValue(_pr_io_restartedIOIndex, thread);
#endif
} else { } else {
_PR_THREAD_LOCK(thread); _PR_THREAD_LOCK(thread);
if (!thread->io_pending) if (!thread->io_pending)

Просмотреть файл

@ -24,15 +24,25 @@ extern void _PR_Win32InitTimeZone(void); /* defined in ntmisc.c */
/* --- globals ------------------------------------------------ */ /* --- globals ------------------------------------------------ */
PRLock *_pr_schedLock = NULL; PRLock *_pr_schedLock = NULL;
_PRInterruptTable _pr_interruptTable[] = { { 0 } }; _PRInterruptTable _pr_interruptTable[] = { { 0 } };
#ifdef _PR_USE_STATIC_TLS
__declspec(thread) PRThread *_pr_current_fiber; __declspec(thread) PRThread *_pr_current_fiber;
__declspec(thread) PRThread *_pr_fiber_last_run; __declspec(thread) PRThread *_pr_fiber_last_run;
__declspec(thread) _PRCPU *_pr_current_cpu; __declspec(thread) _PRCPU *_pr_current_cpu;
__declspec(thread) PRUintn _pr_ints_off; __declspec(thread) PRUintn _pr_ints_off;
#else /* _PR_USE_STATIC_TLS */
DWORD _pr_currentFiberIndex;
DWORD _pr_lastFiberIndex;
DWORD _pr_currentCPUIndex;
DWORD _pr_intsOffIndex;
#endif /* _PR_USE_STATIC_TLS */
_MDLock _nt_idleLock; _MDLock _nt_idleLock;
PRCList _nt_idleList; PRCList _nt_idleList;
PRUint32 _nt_idleCount; PRUint32 _nt_idleCount;
#ifdef _PR_USE_STATIC_TLS
extern __declspec(thread) PRThread *_pr_io_restarted_io; extern __declspec(thread) PRThread *_pr_io_restarted_io;
/* Must check the restarted_io *before* decrementing no_sched to 0 */ /* Must check the restarted_io *before* decrementing no_sched to 0 */
@ -41,6 +51,21 @@ extern __declspec(thread) PRThread *_pr_io_restarted_io;
_nt_handle_restarted_io(_pr_io_restarted_io); \ _nt_handle_restarted_io(_pr_io_restarted_io); \
_PR_MD_LAST_THREAD()->no_sched = 0; _PR_MD_LAST_THREAD()->no_sched = 0;
#else /* _PR_USE_STATIC_TLS */
extern DWORD _pr_io_restartedIOIndex;
/* Must check the restarted_io *before* decrementing no_sched to 0 */
#define POST_SWITCH_WORK() \
PR_BEGIN_MACRO \
PRThread *restarted_io = (PRThread *) TlsGetValue(_pr_io_restartedIOIndex); \
if (restarted_io) \
_nt_handle_restarted_io(restarted_io); \
_PR_MD_LAST_THREAD()->no_sched = 0; \
PR_END_MACRO
#endif /* _PR_USE_STATIC_TLS */
void void
_nt_handle_restarted_io(PRThread *restarted_io) _nt_handle_restarted_io(PRThread *restarted_io)
{ {
@ -69,7 +94,11 @@ _nt_handle_restarted_io(PRThread *restarted_io)
_PR_THREAD_UNLOCK(restarted_io); _PR_THREAD_UNLOCK(restarted_io);
#ifdef _PR_USE_STATIC_TLS
_pr_io_restarted_io = NULL; _pr_io_restarted_io = NULL;
#else
TlsSetValue(_pr_io_restartedIOIndex, NULL);
#endif
} }
void void
@ -87,11 +116,27 @@ _PR_MD_EARLY_INIT()
PR_ASSERT(0); PR_ASSERT(0);
} }
#endif #endif
#ifndef _PR_USE_STATIC_TLS
_pr_currentFiberIndex = TlsAlloc();
_pr_lastFiberIndex = TlsAlloc();
_pr_currentCPUIndex = TlsAlloc();
_pr_intsOffIndex = TlsAlloc();
_pr_io_restartedIOIndex = TlsAlloc();
#endif
} }
void _PR_MD_CLEANUP_BEFORE_EXIT(void) void _PR_MD_CLEANUP_BEFORE_EXIT(void)
{ {
WSACleanup(); WSACleanup();
#ifndef _PR_USE_STATIC_TLS
TlsFree(_pr_currentFiberIndex);
TlsFree(_pr_lastFiberIndex);
TlsFree(_pr_currentCPUIndex);
TlsFree(_pr_intsOffIndex);
TlsFree(_pr_io_restartedIOIndex);
#endif
} }
void void

Просмотреть файл

@ -25,14 +25,16 @@
#define _PR_LOCK_ENV() #define _PR_LOCK_ENV()
#define _PR_UNLOCK_ENV() #define _PR_UNLOCK_ENV()
#elif defined(_PR_LOCAL_THREADS_ONLY) #elif defined(_PR_LOCAL_THREADS_ONLY)
extern _PRCPU * _pr_primordialCPU;
static PRIntn _is;
#define _PR_NEW_LOCK_ENV() #define _PR_NEW_LOCK_ENV()
#define _PR_LOCK_ENV() { PRIntn _is; _PR_INTSOFF(_is) #define _PR_LOCK_ENV() if (_pr_primordialCPU) _PR_INTSOFF(_is);
#define _PR_UNLOCK_ENV() _PR_INTSON(_is); } #define _PR_UNLOCK_ENV() if (_pr_primordialCPU) _PR_INTSON(_is);
#else #else
static PRLock *_pr_envLock; static PRLock *_pr_envLock = NULL;
#define _PR_NEW_LOCK_ENV() {_pr_envLock = PR_NewLock();} #define _PR_NEW_LOCK_ENV() {_pr_envLock = PR_NewLock();}
#define _PR_LOCK_ENV() PR_Lock(_pr_envLock) #define _PR_LOCK_ENV() { if (_pr_envLock) PR_Lock(_pr_envLock); }
#define _PR_UNLOCK_ENV() PR_Unlock(_pr_envLock) #define _PR_UNLOCK_ENV() { if (_pr_envLock) PR_Unlock(_pr_envLock); }
#endif #endif
/************************************************************************/ /************************************************************************/

Просмотреть файл

@ -230,11 +230,7 @@ static PRIntn pt_TimedWait(
tmo.tv_nsec = (PRInt32)PR_IntervalToMicroseconds(PT_NANOPERMICRO * tmo.tv_nsec); tmo.tv_nsec = (PRInt32)PR_IntervalToMicroseconds(PT_NANOPERMICRO * tmo.tv_nsec);
/* pthreads wants this in absolute time, off we go ... */ /* pthreads wants this in absolute time, off we go ... */
#if defined(SOLARIS) && defined(_SVID_GETTOD) (void)GETTIMEOFDAY(&now);
(void)gettimeofday(&now);
#else
(void)gettimeofday(&now, NULL);
#endif
/* that one's usecs, this one's nsecs - grrrr! */ /* that one's usecs, this one's nsecs - grrrr! */
tmo.tv_sec += now.tv_sec; tmo.tv_sec += now.tv_sec;
tmo.tv_nsec += (PT_NANOPERMICRO * now.tv_usec); tmo.tv_nsec += (PT_NANOPERMICRO * now.tv_usec);

Просмотреть файл

@ -18,7 +18,7 @@
#include "primpl.h" #include "primpl.h"
_PRCPU *_pr_primordialCPU; _PRCPU *_pr_primordialCPU = NULL;
PRInt32 _pr_md_idle_cpus; /* number of idle cpus */ PRInt32 _pr_md_idle_cpus; /* number of idle cpus */
/* /*

Просмотреть файл

@ -49,6 +49,7 @@ CSRCS = \
cvar2.c \ cvar2.c \
dceemu.c \ dceemu.c \
dlltest.c \ dlltest.c \
dtoa.c \
exit.c \ exit.c \
fileio.c \ fileio.c \
forktest.c \ forktest.c \
@ -73,6 +74,7 @@ CSRCS = \
multiwait.c \ multiwait.c \
many_cv.c \ many_cv.c \
nbconn.c \ nbconn.c \
nblayer.c \
nonblock.c \ nonblock.c \
op_2long.c \ op_2long.c \
op_filnf.c \ op_filnf.c \
@ -97,6 +99,7 @@ CSRCS = \
servr_kk.c \ servr_kk.c \
servr_ku.c \ servr_ku.c \
servr_uk.c \ servr_uk.c \
short_thread.c \
sigpipe.c \ sigpipe.c \
socket.c \ socket.c \
sockopt.c \ sockopt.c \
@ -108,6 +111,7 @@ CSRCS = \
suspend.c \ suspend.c \
switch.c \ switch.c \
system.c \ system.c \
testbit.c \
testfile.c \ testfile.c \
threads.c \ threads.c \
thruput.c \ thruput.c \
@ -409,6 +413,10 @@ LOGFILE = /dev/null
endif endif
endif endif
ifeq ($(OS_TARGET),Linux)
ECHO = /bin/echo
endif
ALWAYS: ALWAYS:
runtests:: $(PROGS) ALWAYS runtests:: $(PROGS) ALWAYS
@ -423,6 +431,6 @@ runtests:: $(PROGS) ALWAYS
$(ECHO) "\t\t\tPassed"; \ $(ECHO) "\t\t\tPassed"; \
else \ else \
$(ECHO) "\t\t\tFAILED"; \ $(ECHO) "\t\t\tFAILED"; \
fi \ fi; \
done done
@$(ECHO) "\nEND\t\t`date`\n" @$(ECHO) "\nEND\t\t`date`\n"

Просмотреть файл

@ -34,6 +34,19 @@
extern void SetupMacPrintfLog(char *logFile); extern void SetupMacPrintfLog(char *logFile);
#endif #endif
/* lth. re-define PR_LOG() */
#if 0
#undef PR_LOG_TEST
#undef PR_LOG
#define PR_LOG_TEST(_module,_level) ((_module)->level <= (_level))
#define PR_LOG(_module,_level,_args) \
{ \
if (PR_LOG_TEST(_module,_level)) \
PR_LogPrint _args ; \
}
#endif
static void Error(const char* msg) static void Error(const char* msg)
{ {
printf("\t%s\n", msg); printf("\t%s\n", msg);
@ -65,6 +78,28 @@ static void PR_CALLBACK forked(void *arg)
PR_LogPrint("%s forked thread exiting\n", (const char*)arg); PR_LogPrint("%s forked thread exiting\n", (const char*)arg);
} }
static void UserLogStuff( void )
{
PRLogModuleInfo *myLM;
PRIntn i;
myLM = PR_NewLogModule( "userStuff" );
if (! myLM )
{
printf("UserLogStuff(): can't create new log module\n" );
return;
}
PR_LOG( myLM, PR_LOG_NOTICE, ("Log a Notice %d\n", 1 ));
for (i = 0; i < 10 ; i++ )
{
PR_LOG( myLM, PR_LOG_DEBUG, ("Log Debug number: %d\n", i));
PR_Sleep( 300 );
}
} /* end UserLogStuff() */
int main(PRIntn argc, const char **argv) int main(PRIntn argc, const char **argv)
{ {
PRThread *thread; PRThread *thread;
@ -94,6 +129,8 @@ int main(PRIntn argc, const char **argv)
PR_LOCAL_THREAD, PR_JOINABLE_THREAD, 0); PR_LOCAL_THREAD, PR_JOINABLE_THREAD, 0);
PR_LogPrint("%s joining thread\n", argv[0]); PR_LogPrint("%s joining thread\n", argv[0]);
UserLogStuff();
PR_JoinThread(thread); PR_JoinThread(thread);
PR_LogFlush(); PR_LogFlush();

Просмотреть файл

@ -25,10 +25,10 @@
#include <unistd.h> #include <unistd.h>
#include <sys/time.h> #include <sys/time.h>
#if defined(SOLARIS) #if defined(HAVE_SVID_GETTOD)
#define GTOD(_a) gettimeofday(_a) #define GTOD(_a) gettimeofday(_a)
#else #else
#define GTOD(_a) gettimeofday(_a, NULL) #define GTOD(_a) gettimeofday((_a), NULL)
#endif #endif
static PRIntn rv = 0; static PRIntn rv = 0;

Просмотреть файл

@ -87,7 +87,7 @@ static void timeGettimeofday(void)
struct timeval tp; struct timeval tp;
for (;index--;) for (;index--;)
rv = gettimeofday(&tp); rv = gettimeofday(&tp, NULL);
} }
static void timePRTime32(void) static void timePRTime32(void)