jim 98/09/22 18:18:31
Modified: nsprpub/config nsinstall.c
nsprpub/pr/include/md Makefile _unixos.h prosdep.h
Added: nsprpub/config A_UX.mk
nsprpub/pr/include/md _aux.cfg _aux.h
nsprpub/pr/src/md/unix aux.c
Log:
Add a work in progress...
Revision Changes Path
1.2 +15 -4 apache-2.0/nsprpub/config/nsinstall.c
Index: nsinstall.c
===================================================================
RCS file: /export/home/cvs/apache-2.0/nsprpub/config/nsinstall.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- nsinstall.c 1998/06/30 08:36:32 1.1
+++ nsinstall.c 1998/09/23 01:18:29 1.2
@@ -24,6 +24,7 @@
#include <stdio.h> /* OSF/1 requires this before grp.h, so put it first */
#include <assert.h>
#include <fcntl.h>
+#include <errno.h>
#include <grp.h>
#include <pwd.h>
#include <stdio.h>
@@ -37,10 +38,15 @@
#define HAVE_LCHOWN
-#if defined(AIX) || defined(BSDI) || defined(HPUX) || defined(LINUX) ||
defined(SUNOS4) || defined(SCO) || defined(UNIXWARE) || defined(RHAPSODY)
+#if defined(AIX) || defined(BSDI) || defined(HPUX) || defined(linux) ||
defined(SUNOS4) || defined(SCO) || defined(UNIXWARE) || defined(RHAPSODY) ||
defined(AUX)
#undef HAVE_LCHOWN
#endif
+#if defined(AUX)
+extern char *optarg;
+extern int optind, opterr;
+#endif
+
/*
* Does getcwd() take NULL as the first argument and malloc
* the result buffer?
@@ -49,7 +55,7 @@
#define GETCWD_CAN_MALLOC
#endif
-#ifdef LINUX
+#ifdef linux
#include <getopt.h>
#endif
@@ -78,7 +84,8 @@
{
char *cp;
struct stat sb;
-
+ int res;
+
while (*path == '/' && path[1] == '/')
path++;
while ((cp = strrchr(path, '/')) && cp[1] == '\0')
@@ -91,7 +98,11 @@
}
*cp = '/';
}
- return mkdir(path, mode);
+ res = mkdir(path, mode);
+ if ((res != 0) && (errno == EEXIST))
+ return 0;
+ else
+ return res;
}
static uid_t
1.1 apache-2.0/nsprpub/config/A_UX.mk
Index: A_UX.mk
===================================================================
#
# The contents of this file are subject to the Netscape Public License
# Version 1.0 (the "NPL"); you may not use this file except in
# compliance with the NPL. You may obtain a copy of the NPL at
# http://www.mozilla.org/NPL/
#
# Software distributed under the NPL is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
# for the specific language governing rights and limitations under the
# NPL.
#
# The Initial Developer of this code under the NPL is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
# Reserved.
#
#
# Config stuff for SCO OpenServer for x86.
# SCO OpenServer 5, based on SVR3.2, is intended for small to
# medium customers.
#
include $(MOD_DEPTH)/config/UNIX.mk
CC = gcc -D_POSIX_SOURCE
CCC = g++
# CCC = $(DEPTH)/build/hcpp +.cpp +w
RANLIB = /bin/true
DEFINES += -D_PR_LOCAL_THREADS_ONLY
DEFAULT_IMPL_STRATEGY = _CLASSIC
#
# -DSCO - Changes to Netscape source (consistent with AIX, LINUX, etc..)
# -Dsco - Needed for /usr/include/X11/*
#
ifdef USE_AUTOCONF
OS_CFLAGS
else
OS_CFLAGS = -DAUX -DAUX3
endif
#OS_LIBS = -lpmapi -lsocket -lc
CPU_ARCH = m68k
ARCH = aux
NOSUCHFILE = /no-such-file
BSDECHO = /bin/echo
1.2 +12 -0 apache-2.0/nsprpub/pr/include/md/Makefile
Index: Makefile
===================================================================
RCS file: /export/home/cvs/apache-2.0/nsprpub/pr/include/md/Makefile,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- Makefile 1998/06/30 08:36:31 1.1
+++ Makefile 1998/09/23 01:18:29 1.2
@@ -55,6 +55,10 @@
MDCPUCFG_H = _freebsd.cfg
endif
+ifeq ($(OS_ARCH),NetBSD)
+MDCPUCFG_H = _netbsd.cfg
+endif
+
ifeq ($(OS_ARCH),HP-UX)
MDCPUCFG_H = _hpux.cfg
endif
@@ -101,6 +105,14 @@
ifeq ($(OS_ARCH),NCR)
MDCPUCFG_H = _ncr.cfg
+endif
+
+ifeq ($(OS_ARCH),DGUX)
+MDCPUCFG_H = _dgux.cfg
+endif
+
+ifeq ($(OS_ARCH),A_UX)
+MDCPUCFG_H = _aux.cfg
endif
export:: $(HEADERS) $(MDCPUCFG_H)
1.2 +3 -1 apache-2.0/nsprpub/pr/include/md/_unixos.h
Index: _unixos.h
===================================================================
RCS file: /export/home/cvs/apache-2.0/nsprpub/pr/include/md/_unixos.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- _unixos.h 1998/06/30 08:36:31 1.1
+++ _unixos.h 1998/09/23 01:18:30 1.2
@@ -49,7 +49,8 @@
|| defined(UNIXWARE) || defined(NCR) || defined(SNI) || defined(NEC)
\
|| defined(BSDI) || defined(SONY)
#include <sys/select.h>
-#elif defined(SUNOS4) || defined(SCO) || defined(FREEBSD) ||
defined(RHAPSODY)
+#elif defined(SUNOS4) || defined(SCO) || defined(FREEBSD) \
+ || defined(NETBSD) || defined(RHAPSODY) || defined(DGUX) ||
defined(AUX)
#include <sys/types.h>
#elif defined(LINUX)
#include <sys/time.h>
@@ -63,6 +64,7 @@
#define PR_PATH_SEPARATOR ':'
#define PR_PATH_SEPARATOR_STR ":"
#define GCPTR
+
typedef int (*FARPROC)();
/*
1.2 +9 -0 apache-2.0/nsprpub/pr/include/md/prosdep.h
Index: prosdep.h
===================================================================
RCS file: /export/home/cvs/apache-2.0/nsprpub/pr/include/md/prosdep.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- prosdep.h 1998/06/30 08:36:31 1.1
+++ prosdep.h 1998/09/23 01:18:30 1.2
@@ -59,6 +59,9 @@
#elif defined(FREEBSD)
#include "md/_freebsd.h"
+#elif defined(NETBSD)
+#include "md/_netbsd.h"
+
#elif defined(BSDI)
#include "md/_bsdi.h"
@@ -100,6 +103,12 @@
#elif defined(NCR)
#include "md/_ncr.h"
+
+#elif defined(DGUX)
+#include "md/_dgux.h"
+
+#elif defined(AUX)
+#include "md/_aux.h"
#else
#error unknown Unix flavor
1.1 apache-2.0/nsprpub/pr/include/md/_aux.cfg
Index: _aux.cfg
===================================================================
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*/
/*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#ifndef nspr_cpucfg___
#define nspr_cpucfg___
#ifndef XP_UNIX
#define XP_UNIX
#endif
#ifndef AUX
#define AUX
#endif
#undef IS_LITTLE_ENDIAN
#define IS_BIG_ENDIAN 1
#define PR_BYTES_PER_BYTE 1
#define PR_BYTES_PER_SHORT 2
#define PR_BYTES_PER_INT 4
#define PR_BYTES_PER_INT64 8
#define PR_BYTES_PER_LONG 4
#define PR_BYTES_PER_FLOAT 4
#define PR_BYTES_PER_DOUBLE 8
#define PR_BYTES_PER_WORD 4
#define PR_BYTES_PER_DWORD 8
#define PR_BITS_PER_BYTE 8
#define PR_BITS_PER_SHORT 16
#define PR_BITS_PER_INT 32
#define PR_BITS_PER_INT64 64
#define PR_BITS_PER_LONG 32
#define PR_BITS_PER_FLOAT 32
#define PR_BITS_PER_DOUBLE 64
#define PR_BITS_PER_WORD 32
#define PR_BITS_PER_BYTE_LOG2 3
#define PR_BITS_PER_SHORT_LOG2 4
#define PR_BITS_PER_INT_LOG2 5
#define PR_BITS_PER_INT64_LOG2 6
#define PR_BITS_PER_LONG_LOG2 5
#define PR_BITS_PER_FLOAT_LOG2 5
#define PR_BITS_PER_DOUBLE_LOG2 6
#define PR_BITS_PER_WORD_LOG2 5
#define PR_ALIGN_OF_SHORT 2
#define PR_ALIGN_OF_INT 2
#define PR_ALIGN_OF_LONG 2
#define PR_ALIGN_OF_INT64 2
#define PR_ALIGN_OF_FLOAT 2
#define PR_ALIGN_OF_DOUBLE 2
#define PR_ALIGN_OF_POINTER 2
#define PR_BYTES_PER_WORD_LOG2 2
#define PR_BYTES_PER_DWORD_LOG2 3
#undef HAVE_LONG_LONG
/*
* XXX These two macros need to be investigated for different architectures.
*/
#undef HAVE_ALIGNED_DOUBLES
#undef HAVE_ALIGNED_LONGLONGS
#ifndef NO_NSPR_10_SUPPORT
#define BYTES_PER_BYTE PR_BYTES_PER_BYTE
#define BYTES_PER_SHORT PR_BYTES_PER_SHORT
#define BYTES_PER_INT PR_BYTES_PER_INT
#define BYTES_PER_INT64 PR_BYTES_PER_INT64
#define BYTES_PER_LONG PR_BYTES_PER_LONG
#define BYTES_PER_FLOAT PR_BYTES_PER_FLOAT
#define BYTES_PER_DOUBLE PR_BYTES_PER_DOUBLE
#define BYTES_PER_WORD PR_BYTES_PER_WORD
#define BYTES_PER_DWORD PR_BYTES_PER_DWORD
#define BITS_PER_BYTE PR_BITS_PER_BYTE
#define BITS_PER_SHORT PR_BITS_PER_SHORT
#define BITS_PER_INT PR_BITS_PER_INT
#define BITS_PER_INT64 PR_BITS_PER_INT64
#define BITS_PER_LONG PR_BITS_PER_LONG
#define BITS_PER_FLOAT PR_BITS_PER_FLOAT
#define BITS_PER_DOUBLE PR_BITS_PER_DOUBLE
#define BITS_PER_WORD PR_BITS_PER_WORD
#define BITS_PER_BYTE_LOG2 PR_BITS_PER_BYTE_LOG2
#define BITS_PER_SHORT_LOG2 PR_BITS_PER_SHORT_LOG2
#define BITS_PER_INT_LOG2 PR_BITS_PER_INT_LOG2
#define BITS_PER_INT64_LOG2 PR_BITS_PER_INT64_LOG2
#define BITS_PER_LONG_LOG2 PR_BITS_PER_LONG_LOG2
#define BITS_PER_FLOAT_LOG2 PR_BITS_PER_FLOAT_LOG2
#define BITS_PER_DOUBLE_LOG2 PR_BITS_PER_DOUBLE_LOG2
#define BITS_PER_WORD_LOG2 PR_BITS_PER_WORD_LOG2
#define ALIGN_OF_SHORT PR_ALIGN_OF_SHORT
#define ALIGN_OF_INT PR_ALIGN_OF_INT
#define ALIGN_OF_LONG PR_ALIGN_OF_LONG
#define ALIGN_OF_INT64 PR_ALIGN_OF_INT64
#define ALIGN_OF_FLOAT PR_ALIGN_OF_FLOAT
#define ALIGN_OF_DOUBLE PR_ALIGN_OF_DOUBLE
#define ALIGN_OF_POINTER PR_ALIGN_OF_POINTER
#define ALIGN_OF_WORD PR_ALIGN_OF_WORD
#define BYTES_PER_WORD_LOG2 PR_BYTES_PER_WORD_LOG2
#define BYTES_PER_DWORD_LOG2 PR_BYTES_PER_DWORD_LOG2
#define WORDS_PER_DWORD_LOG2 PR_WORDS_PER_DWORD_LOG2
#endif /* NO_NSPR_10_SUPPORT */
#endif /* nspr_cpucfg___ */
1.1 apache-2.0/nsprpub/pr/include/md/_aux.h
Index: _aux.h
===================================================================
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*/
/*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#ifndef nspr_aux_defs_h___
#define nspr_aux_defs_h___
/*
* Internal configuration macros
*/
#define PR_LINKER_ARCH "aux"
#define _PR_SI_SYSNAME "A/UX"
#define _PR_SI_ARCHITECTURE "m68k"
#define _PR_VMBASE 0x30000000
#define _PR_STACK_VMBASE 0x50000000
#define _MD_DEFAULT_STACK_SIZE 65536L
#undef HAVE_DLL
#undef USE_DLFCN
#define _PR_RECV_BROKEN /* recv doesn't work on Unix Domain Sockets */
#if !defined (HAVE_STRERROR)
#define HAVE_STRERROR
#endif
#ifndef HAVE_WEAK_IO_SYMBOLS
#define HAVE_WEAK_IO_SYMBOLS
#endif
#undef HAVE_STACK_GROWING_UP
#define HAVE_NETCONFIG
#define NEED_STRFTIME_LOCK
#define NEED_TIME_R
#define NEED_LOCALTIME_R
#define NEED_GMTIME_R
#define NEED_ASCTIME_R
#define NEED_STRTOK_R
#define NEED_CTIME_R
#define _PR_NEED_STRCASECMP
#define USE_SETJMP
#include <setjmp.h>
#define _SETJMP setjmp
#define _LONGJMP longjmp
#define _PR_CONTEXT_TYPE jmp_buf
#define _MD_GET_SP(_t) (_t)->md.context[4]
#define _PR_NUM_GCREGS _JBLEN
#define CONTEXT(_th) ((_th)->md.context)
/*
** Initialize the thread context preparing it to execute _main.
*/
#define _MD_INIT_CONTEXT(_thread, _sp, _main, status) \
{ \
*status = PR_TRUE; \
if(_SETJMP(CONTEXT(_thread))) (*_main)(); \
_MD_GET_SP(_thread) = (int) ((_sp) - 128); \
}
#define _MD_SWITCH_CONTEXT(_thread) \
if (!_SETJMP(CONTEXT(_thread))) { \
(_thread)->md.errcode = errno; \
_PR_Schedule(); \
}
/*
** Restore a thread context, saved by _MD_SWITCH_CONTEXT
*/
#define _MD_RESTORE_CONTEXT(_thread) \
{ \
errno = (_thread)->md.errcode; \
_MD_SET_CURRENT_THREAD(_thread); \
_LONGJMP(CONTEXT(_thread), 1); \
}
/* Machine-dependent (MD) data structures.
* Don't use SVR4 native threads (yet).
*/
struct _MDThread {
_PR_CONTEXT_TYPE context;
int id;
int errcode;
};
struct _MDThreadStack {
PRInt8 notused;
};
struct _MDLock {
PRInt8 notused;
};
struct _MDSemaphore {
PRInt8 notused;
};
struct _MDCVar {
PRInt8 notused;
};
struct _MDSegment {
PRInt8 notused;
};
struct _MDCPU {
struct _MDCPU_Unix md_unix;
};
#define _MD_INIT_LOCKS()
#define _MD_NEW_LOCK(lock) PR_SUCCESS
#define _MD_FREE_LOCK(lock)
#define _MD_LOCK(lock)
#define _MD_UNLOCK(lock)
#define _MD_INIT_IO()
#define _MD_IOQ_LOCK()
#define _MD_IOQ_UNLOCK()
/*
* The following are copied from _sunos.h, _aix.h. This means
* some of them should probably be moved into _unixos.h. But
* _irix.h seems to be quite different in regard to these macros.
*/
#define _MD_GET_INTERVAL _PR_UNIX_GetInterval
#define _MD_INTERVAL_PER_SEC _PR_UNIX_TicksPerSecond
#define _MD_EARLY_INIT _MD_EarlyInit
#define _MD_FINAL_INIT _PR_UnixInit
#define _MD_INIT_RUNNING_CPU(cpu) _MD_unix_init_running_cpu(cpu)
#define _MD_INIT_THREAD _MD_InitializeThread
#define _MD_EXIT_THREAD(thread)
#define _MD_SUSPEND_THREAD(thread)
#define _MD_RESUME_THREAD(thread)
#define _MD_CLEAN_THREAD(_thread)
/*
* We wrapped the select() call. _MD_SELECT refers to the built-in,
* unwrapped version.
*/
#include <sys/time.h>
#include <sys/types.h>
extern int _select(int nfds, fd_set *readfds, fd_set *writefds,
fd_set *execptfds, struct timeval *timeout);
#define _MD_SELECT _select
/*
#define _MD_POLL _poll
extern int _poll(struct pollfd *fds, unsigned long nfds, int timeout);
*/
#endif /* nspr_aux_defs_h */
1.1 apache-2.0/nsprpub/pr/src/md/unix/aux.c
Index: aux.c
===================================================================
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*/
/*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
/*
* A/UX 3.1.1 - cloned from NCR
*/
#include "primpl.h"
#include <setjmp.h>
void _MD_EarlyInit(void)
{
}
PRWord *_MD_HomeGCRegisters(PRThread *t, int isCurrent, int *np)
{
if (isCurrent) {
(void) setjmp(CONTEXT(t));
}
*np = sizeof(CONTEXT(t)) / sizeof(PRWord);
return (PRWord *) CONTEXT(t);
}
#ifdef ALARMS_BREAK_TCP /* I don't think they do */
PRInt32 _MD_connect(PRInt32 osfd, const PRNetAddr *addr, PRInt32 addrlen,
PRIntervalTime timeout)
{
PRInt32 rv;
_MD_BLOCK_CLOCK_INTERRUPTS();
rv = _connect(osfd,addr,addrlen);
_MD_UNBLOCK_CLOCK_INTERRUPTS();
}
PRInt32 _MD_accept(PRInt32 osfd, PRNetAddr *addr, PRInt32 addrlen,
PRIntervalTime timeout)
{
PRInt32 rv;
_MD_BLOCK_CLOCK_INTERRUPTS();
rv = _accept(osfd,addr,addrlen);
_MD_UNBLOCK_CLOCK_INTERRUPTS();
return(rv);
}
#endif
/*
* These are also implemented in pratom.c using NSPR locks. Any reason
* this might be better or worse? If you like this better, define
* _PR_HAVE_ATOMIC_OPS in include/md/unixware.h
*/
#ifdef _PR_HAVE_ATOMIC_OPS
/* Atomic operations */
#include <stdio.h>
static FILE *_uw_semf;
void
_MD_INIT_ATOMIC(void)
{
/* Sigh. Sure wish SYSV semaphores weren't such a pain to use */
if ((_uw_semf = tmpfile()) == NULL)
PR_ASSERT(0);
return;
}
void
_MD_ATOMIC_INCREMENT(PRInt32 *val)
{
flockfile(_uw_semf);
(*val)++;
unflockfile(_uw_semf);
}
void
_MD_ATOMIC_DECREMENT(PRInt32 *val)
{
flockfile(_uw_semf);
(*val)--;
unflockfile(_uw_semf);
}
void
_MD_ATOMIC_SET(PRInt32 *val, PRInt32 newval)
{
flockfile(_uw_semf);
*val = newval;
unflockfile(_uw_semf);
}
#endif
void
_MD_SET_PRIORITY(_MDThread *thread, PRUintn newPri)
{
return;
}
PRStatus
_MD_InitializeThread(PRThread *thread)
{
return PR_SUCCESS;
}
PRStatus
_MD_WAIT(PRThread *thread, PRIntervalTime ticks)
{
PR_ASSERT(!(thread->flags & _PR_GLOBAL_SCOPE));
_PR_MD_SWITCH_CONTEXT(thread);
return PR_SUCCESS;
}
PRStatus
_MD_WAKEUP_WAITER(PRThread *thread)
{
if (thread) {
PR_ASSERT(!(thread->flags & _PR_GLOBAL_SCOPE));
}
return PR_SUCCESS;
}
/* These functions should not be called for A/UX */
void
_MD_YIELD(void)
{
PR_NOT_REACHED("_MD_YIELD should not be called for A/UX.");
}
PRStatus
_MD_CREATE_THREAD(
PRThread *thread,
void (*start) (void *),
PRUintn priority,
PRThreadScope scope,
PRThreadState state,
PRUint32 stackSize)
{
PR_NOT_REACHED("_MD_CREATE_THREAD should not be called for A/UX.");
return PR_FAILURE;
}
/*
This is temp. replacement for localtime_r. Normally PR_ExplodeTime should
be used as to my understanding
*/
/*
** $$$$$ THEN WHY ARE WE DOING THIS? - AOF $$$$$
*/
#define NEED_LOCALTIME_R
#define NEED_GMTIME_R
#define NEED_ASCTIME_R
#define NEED_STRTOK_R
#define NEED_CTIME_R
#if defined (NEED_LOCALTIME_R) || defined (NEED_CTIME_R) || defined
(NEED_ASCTIME_R) || defined (NEED_GMTIME_R) || defined (NEED_STRTOK_R)
#include "prlock.h"
#endif
#if defined (NEED_LOCALTIME_R)
static PRLock *localtime_r_monitor = NULL;
struct tm *localtime_r (const time_t *clock, struct tm *result)
{
struct tm *tmPtr;
int needLock = PR_Initialized(); /* We need to use a lock to protect
* against NSPR threads only when the
* NSPR thread system is activated. */
if (needLock) {
if (localtime_r_monitor == NULL) {
localtime_r_monitor = PR_NewLock();
}
PR_Lock(localtime_r_monitor);
}
/*
* On Windows, localtime() returns a NULL pointer if 'clock'
* represents a time before midnight January 1, 1970. In
* that case, we also return a NULL pointer and the struct tm
* object pointed to by 'result' is not modified.
*/
tmPtr = localtime(clock);
if (tmPtr) {
*result = *tmPtr;
} else {
result = NULL;
}
if (needLock) PR_Unlock(localtime_r_monitor);
return result;
}
#endif
#if defined (NEED_GMTIME_R)
static PRLock *gmtime_r_monitor = NULL;
struct tm *gmtime_r (const time_t *clock, struct tm *result)
{
struct tm *tmPtr;
int needLock = PR_Initialized(); /* We need to use a lock to protect
* against NSPR threads only when the
* NSPR thread system is activated. */
if (needLock) {
if (gmtime_r_monitor == NULL) {
gmtime_r_monitor = PR_NewLock();
}
PR_Lock(gmtime_r_monitor);
}
tmPtr = gmtime(clock);
if (tmPtr) {
*result = *tmPtr;
} else {
result = NULL;
}
if (needLock) PR_Unlock(gmtime_r_monitor);
return result;
}
#endif
#if defined (NEED_CTIME_R)
static PRLock *ctime_r_monitor = NULL;
char *ctime_r (const time_t *clock, char *buf, int buflen)
{
char *cbuf;
int needLock = PR_Initialized(); /* We need to use a lock to protect
* against NSPR threads only when the
* NSPR thread system is activated. */
if (needLock) {
if (ctime_r_monitor == NULL) {
ctime_r_monitor = PR_NewLock();
}
PR_Lock(ctime_r_monitor);
}
cbuf = ctime (clock);
if (cbuf) {
strncpy (buf, cbuf, buflen - 1);
buf[buflen - 1] = 0;
}
if (needLock) PR_Unlock(ctime_r_monitor);
return cbuf;
}
#endif
#if defined (NEED_ASCTIME_R)
static PRLock *asctime_r_monitor = NULL;
char *asctime_r (const struct tm *tm, char *buf, int buflen)
{
char *cbuf;
int needLock = PR_Initialized(); /* We need to use a lock to protect
* against NSPR threads only when the
* NSPR thread system is activated. */
if (needLock) {
if (asctime_r_monitor == NULL) {
asctime_r_monitor = PR_NewLock();
}
PR_Lock(asctime_r_monitor);
}
cbuf = asctime (tm);
if (cbuf) {
strncpy (buf, cbuf, buflen - 1);
buf[buflen - 1] = 0;
}
if (needLock) PR_Unlock(asctime_r_monitor);
return cbuf;
}
#endif
#if defined (NEED_STRTOK_R)
char *
strtok_r (s, delim, last)
register char *s;
register const char *delim;
register char **last;
{
register char *spanp;
register int c, sc;
char *tok;
if (s == NULL && (s = *last) == NULL)
return (NULL);
/*
* Skip (span) leading delimiters (s += strspn(s, delim), sort of).
*/
cont:
c = *s++;
for (spanp = (char *)delim; (sc = *spanp++) != 0;) {
if (c == sc)
goto cont;
}
if (c == 0) { /* no non-delimiter characters */
*last = NULL;
return (NULL);
}
tok = s - 1;
/*
* Scan token (scan for delimiters: s += strcspn(s, delim), sort of).
* Note that delim must have one NUL; we stop if we see that, too.
*/
for (;;) {
c = *s++;
spanp = (char *)delim;
do {
if ((sc = *spanp++) == c) {
if (c == 0)
s = NULL;
else
s[-1] = 0;
*last = s;
return (tok);
}
} while (sc != 0);
}
/* NOTREACHED */
}
#endif