Bugzilla bug #263: Merged the NetBSD port of NSPR contributed by

Frank van der Linden <frank@wins.uva.nl>.
This commit is contained in:
wtc%netscape.com 1998-07-17 23:33:36 +00:00
Родитель 2d9d10f11a
Коммит 98e45bf8c4
16 изменённых файлов: 665 добавлений и 25 удалений

62
nsprpub/config/NetBSD.mk Normal file
Просмотреть файл

@ -0,0 +1,62 @@
#
# 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 NetBSD
#
include $(MOD_DEPTH)/config/UNIX.mk
CC = gcc
CCC = g++
RANLIB = ranlib
OS_REL_CFLAGS =
ifeq (86,$(findstring 86,$(OS_TEST)))
CPU_ARCH = x86
else
CPU_ARCH = $(OS_TEST)
endif
OS_CFLAGS = $(DSO_CFLAGS) $(OS_REL_CFLAGS) -ansi -Wall -pipe -DNETBSD -DHAVE_STRERROR -DHAVE_BSD_FLOCK
ifeq ($(USE_PTHREADS),1)
OS_LIBS = -lc_r
# XXX probably should define _THREAD_SAFE too.
else
OS_LIBS = -lc
DEFINES += -D_PR_LOCAL_THREADS_ONLY
endif
ARCH = netbsd
DSO_CFLAGS = -fPIC
DSO_LDFLAGS =
DSO_LDOPTS = -Bshareable
ifeq ($(OS_TEST),alpha)
DSO_LDOPTS = -shared
endif
ifeq ($(OS_TEST),mips)
DSO_LDOPTS = -shared
endif
ifeq ($(OS_TEST),pmax)
DSO_LDOPTS = -shared
endif
MKSHLIB = $(LD) $(DSO_LDOPTS)
G++INCLUDES = -I/usr/include/g++

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

@ -55,6 +55,10 @@ ifeq ($(OS_ARCH),FreeBSD)
MDCPUCFG_H = _freebsd.cfg
endif
ifeq ($(OS_ARCH),NetBSD)
MDCPUCFG_H = _netbsd.cfg
endif
ifeq ($(OS_ARCH),HP-UX)
MDCPUCFG_H = _hpux.cfg
endif

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

@ -0,0 +1,262 @@
/* -*- 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 NETBSD
#define NETBSD
#endif
#if defined(__i386__) || defined(__arm32__)
#define IS_LITTLE_ENDIAN 1
#undef IS_BIG_ENDIAN
#define HAVE_LONG_LONG
#undef HAVE_ALIGNED_DOUBLES
#undef HAVE_ALIGNED_LONGLONGS
#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_BYTES_PER_WORD_LOG2 2
#define PR_BYTES_PER_DWORD_LOG2 3
#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 4
#define PR_ALIGN_OF_LONG 4
#define PR_ALIGN_OF_INT64 4
#define PR_ALIGN_OF_FLOAT 4
#define PR_ALIGN_OF_DOUBLE 4
#define PR_ALIGN_OF_POINTER 4
#elif defined(__sparc__)
#undef IS_LITTLE_ENDIAN 1
#define IS_BIG_ENDIAN 1
#define HAVE_LONG_LONG
#define HAVE_ALIGNED_DOUBLES
#define HAVE_ALIGNED_LONGLONGS
#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_BYTES_PER_WORD_LOG2 2
#define PR_BYTES_PER_DWORD_LOG2 3
#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 4
#define PR_ALIGN_OF_LONG 4
#define PR_ALIGN_OF_INT64 8
#define PR_ALIGN_OF_FLOAT 4
#define PR_ALIGN_OF_DOUBLE 8
#define PR_ALIGN_OF_POINTER 4
#elif defined(__alpha__)
#define IS_LITTLE_ENDIAN 1
#undef IS_BIG_ENDIAN
#define IS_64
#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 8
#define PR_BYTES_PER_FLOAT 4
#define PR_BYTES_PER_DOUBLE 8
#define PR_BYTES_PER_WORD 8
#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 64
#define PR_BITS_PER_FLOAT 32
#define PR_BITS_PER_DOUBLE 64
#define PR_BITS_PER_WORD 64
#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 6
#define PR_BITS_PER_FLOAT_LOG2 5
#define PR_BITS_PER_DOUBLE_LOG2 6
#define PR_BITS_PER_WORD_LOG2 6
#define PR_ALIGN_OF_SHORT 2
#define PR_ALIGN_OF_INT 4
#define PR_ALIGN_OF_LONG 8
#define PR_ALIGN_OF_INT64 8
#define PR_ALIGN_OF_FLOAT 4
#define PR_ALIGN_OF_DOUBLE 8
#define PR_ALIGN_OF_POINTER 8
#define PR_BYTES_PER_WORD_LOG2 3
#define PR_BYTES_PER_DWORD_LOG2 3
#elif defined(__powerpc__) || defined(__m68k__)
#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 4
#define PR_ALIGN_OF_LONG 4
#define PR_ALIGN_OF_INT64 4
#define PR_ALIGN_OF_FLOAT 4
#define PR_ALIGN_OF_DOUBLE 4
#define PR_ALIGN_OF_POINTER 4
#define PR_BYTES_PER_WORD_LOG2 2
#define PR_BYTES_PER_DWORD_LOG2 3
#else
#error Must define constants for type sizes here.
#endif
#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___ */

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

@ -0,0 +1,168 @@
/* -*- 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_netbsd_defs_h___
#define nspr_netbsd_defs_h___
#include <sys/syscall.h>
#define PR_LINKER_ARCH "netbsd"
#define _PR_SI_SYSNAME "NetBSD"
#if defined(__i386__)
#define _PR_SI_ARCHITECTURE "x86"
#elif defined(__alpha__)
#define _PR_SI_ARCHITECTURE "alpha"
#elif defined(__m68k__)
#define _PR_SI_ARCHITECTURE "m68k"
#elif defined(__powerpc__)
#define _PR_SI_ARCHITECTURE "powerpc"
#elif defined(__sparc__)
#define _PR_SI_ARCHITECTURE "sparc"
#elif defined(__arm32__)
#define _PR_SI_ARCHITECTURE "arm32"
#endif
#define PR_DLL_SUFFIX ".so.1.0"
#define _PR_VMBASE 0x30000000
#define _PR_STACK_VMBASE 0x50000000
#define _MD_DEFAULT_STACK_SIZE 65536L
#define _MD_MMAP_FLAGS MAP_PRIVATE
#undef HAVE_STACK_GROWING_UP
#define HAVE_DLL
#define USE_DLFCN
#define _PR_HAVE_SOCKADDR_LEN
#define USE_SETJMP
#ifndef _PR_PTHREADS
#include <setjmp.h>
#define PR_CONTEXT_TYPE sigjmp_buf
#define CONTEXT(_th) ((_th)->md.context)
#if defined(__i386__) || defined(__sparc__) || defined(__m68k__) || defined(__powerpc__)
#define JB_SP_INDEX 2
#elif defined(__alpha__)
#define JB_SP_INDEX 34
#elif defined(__arm32__)
#define JB_SP_INDEX JMPBUF_REG_R13
#else
#error "Need to define SP index in jmp_buf here"
#endif
#define _MD_GET_SP(_th) (_th)->md.context[JB_SP_INDEX]
#define PR_NUM_GCREGS _JBLEN
/*
** Initialize a thread context to run "_main()" when started
*/
#define _MD_INIT_CONTEXT(_thread, _sp, _main, status) \
{ \
*status = PR_TRUE; \
if (sigsetjmp(CONTEXT(_thread), 1)) { \
_main(); \
} \
_MD_GET_SP(_thread) = (unsigned char*) ((_sp) - 64); \
}
#define _MD_SWITCH_CONTEXT(_thread) \
if (!sigsetjmp(CONTEXT(_thread), 1)) { \
(_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); \
siglongjmp(CONTEXT(_thread), 1); \
}
/* Machine-dependent (MD) data structures */
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()
#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) _MD_suspend_thread
#define _MD_RESUME_THREAD(thread) _MD_resume_thread
#define _MD_CLEAN_THREAD(_thread)
#endif /* ! _PR_PTHREADS */
#define _MD_EARLY_INIT _MD_EarlyInit
#define _MD_FINAL_INIT _PR_UnixInit
#define _MD_GET_INTERVAL _PR_UNIX_GetInterval
#define _MD_INTERVAL_PER_SEC _PR_UNIX_TicksPerSecond
/*
* We wrapped the select() call. _MD_SELECT refers to the built-in,
* unwrapped version.
*/
#define _MD_SELECT(nfds,r,w,e,tv) syscall(SYS_select,nfds,r,w,e,tv)
#define _MD_POLL(fds,nfds,timeout) syscall(SYS_poll,fds,nfds,timeout)
#if NetBSD1_3 == 1L
typedef unsigned int nfds_t;
#endif
#endif /* nspr_netbsd_defs_h___ */

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

@ -69,7 +69,8 @@
(!memcmp(&(t), &pt_zero_tid, sizeof(pthread_t)))
#define PTHREAD_COPY_THR_HANDLE(st, dt) (dt) = (st)
#elif defined(IRIX) || defined(OSF1) || defined(AIX) || defined(SOLARIS) \
|| defined(HPUX) || defined(LINUX) || defined(FREEBSD)
|| defined(HPUX) || defined(LINUX) || defined(FREEBSD) \
|| defined(NETBSD)
#define PTHREAD_ZERO_THR_HANDLE(t) (t) = 0
#define PTHREAD_THR_HANDLE_IS_ZERO(t) (t) == 0
#define PTHREAD_COPY_THR_HANDLE(st, dt) (dt) = (st)
@ -134,7 +135,8 @@ PR_EXTERN(PRIntn) pt_hpux_privcheck(void);
* These platforms don't have pthread_atfork()
*/
#if defined(_PR_DCETHREADS) || defined(FREEBSD) \
|| (defined(LINUX) && defined(__alpha))
|| (defined(LINUX) && defined(__alpha)) \
|| defined(NETBSD)
#define PT_NO_ATFORK
#endif
@ -142,7 +144,7 @@ PR_EXTERN(PRIntn) pt_hpux_privcheck(void);
* These platforms don't have sigtimedwait()
*/
#if (defined(AIX) && !defined(AIX4_3)) || defined(LINUX) \
|| defined(FREEBSD)
|| defined(FREEBSD) || defined(NETBSD)
#define PT_NO_SIGTIMEDWAIT
#endif
@ -184,7 +186,7 @@ PR_EXTERN(PRIntn) pt_hpux_privcheck(void);
*/
#define PT_PRIO_MIN 1
#define PT_PRIO_MAX 127
#elif defined(FREEBSD) /* XXX */
#elif defined(FREEBSD) || defined(NETBSD) /* XXX */
#define PT_PRIO_MIN 0
#define PT_PRIO_MAX 126
#else
@ -213,7 +215,7 @@ extern int (*_PT_aix_yield_fcn)();
#define PTHREAD_YIELD() sched_yield()
#elif defined(LINUX)
#define PTHREAD_YIELD() sched_yield()
#elif defined(FREEBSD)
#elif defined(FREEBSD) || defined(NETBSD)
#define PTHREAD_YIELD() pthread_yield()
#else
#error "Need to define PTHREAD_YIELD for this platform"

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

@ -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)
#include <sys/types.h>
#elif defined(LINUX)
#include <sys/time.h>

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

@ -59,6 +59,9 @@ PR_BEGIN_EXTERN_C
#elif defined(FREEBSD)
#include "md/_freebsd.h"
#elif defined(NETBSD)
#include "md/_netbsd.h"
#elif defined(BSDI)
#include "md/_bsdi.h"

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

@ -42,7 +42,7 @@ static void GetPageSize(void)
/* Get page size */
#ifdef XP_UNIX
#if defined SUNOS4 || defined LINUX || defined BSDI || defined AIX \
|| defined FREEBSD || defined RHAPSODY
|| defined FREEBSD || defined NETBSD || defined RHAPSODY
_pr_pageSize = getpagesize();
#elif defined(HPUX)
/* I have no idea. Don't get me started. --Rob */

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

@ -57,6 +57,10 @@ FREEBSD_CSRCS = \
freebsd.c \
$(NULL)
NETBSD_CSRCS = \
netbsd.c \
$(NULL)
BSDI_CSRCS = \
bsdi.c \
$(NULL)
@ -123,6 +127,9 @@ endif
ifeq ($(OS_ARCH),FreeBSD)
CSRCS += $(FREEBSD_CSRCS)
endif
ifeq ($(OS_ARCH),NetBSD)
CSRCS += $(NETBSD_CSRCS)
endif
ifeq ($(OS_ARCH),BSD_OS)
CSRCS += $(BSDI_CSRCS)
endif

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

@ -0,0 +1,102 @@
/* -*- 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.
*/
#include "primpl.h"
#include <signal.h>
#include <poll.h>
#include <sys/syscall.h>
void _MD_EarlyInit(void)
{
/*
* Ignore FPE because coercion of a NaN to an int causes SIGFPE
* to be raised.
*/
struct sigaction act;
act.sa_handler = SIG_IGN;
sigemptyset(&act.sa_mask);
act.sa_flags = SA_RESTART;
sigaction(SIGFPE, &act, 0);
}
PRWord *_MD_HomeGCRegisters(PRThread *t, int isCurrent, int *np)
{
#ifndef _PR_PTHREADS
if (isCurrent) {
(void) sigsetjmp(CONTEXT(t), 1);
}
*np = sizeof(CONTEXT(t)) / sizeof(PRWord);
return (PRWord *) CONTEXT(t);
#else
*np = 0;
return NULL;
#endif
}
#ifndef _PR_PTHREADS
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 NetBSD */
void
_MD_YIELD(void)
{
PR_NOT_REACHED("_MD_YIELD should not be called for NetBSD.");
}
PRStatus
_MD_CREATE_THREAD(
PRThread *thread,
void (*start) (void *),
PRThreadPriority priority,
PRThreadScope scope,
PRThreadState state,
PRUint32 stackSize)
{
PR_NOT_REACHED("_MD_CREATE_THREAD should not be called for NetBSD.");
return PR_FAILURE;
}
#endif /* ! _PR_PTHREADS */

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

@ -49,6 +49,10 @@ FREEBSD_CSRCS = \
freebsd.c \
$(NULL)
NETBSD_CSRCS = \
netbsd.c \
$(NULL)
BSDI_CSRCS = \
bsdi.c \
$(NULL)
@ -116,6 +120,9 @@ endif
ifeq ($(OS_ARCH),FreeBSD)
CSRCS += $(FREEBSD_CSRCS)
endif
ifeq ($(OS_ARCH),NetBSD)
CSRCS += $(NETBSD_CSRCS)
endif
ifeq ($(OS_ARCH),BSD_OS)
CSRCS += $(BSDI_CSRCS)
endif

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

@ -48,7 +48,7 @@
|| defined(SUNOS4) || defined(NCR) || defined(RHAPSODY)
#define _PRSockLen_t int
#elif (defined(AIX) && !defined(AIX4_1)) || defined(FREEBSD) \
|| defined(UNIXWARE)
|| defined(NETBSD) || defined(UNIXWARE)
#define _PRSockLen_t size_t
#else
#error "Cannot determine architecture"

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

@ -160,8 +160,12 @@ void _MD_unix_map_unlink_error(int err)
case EROFS:
PR_SetError(PR_READ_ONLY_FILESYSTEM_ERROR, err);
break;
#if !defined(OSF1) && !defined(FREEBSD) && !defined(BSDI) && !defined(RHAPSODY)
#ifdef EMULTIHOP
case EMULTIHOP:
PR_SetError(PR_REMOTE_FILE_ERROR, err);
break;
#endif
#ifdef ENOLINK
case ENOLINK:
PR_SetError(PR_REMOTE_FILE_ERROR, err);
break;
@ -184,11 +188,13 @@ void _MD_unix_map_stat_error(int err)
case EINTR:
PR_SetError(PR_PENDING_INTERRUPT_ERROR, err);
break;
case ETIMEDOUT:
#if !defined(OSF1) && !defined(FREEBSD) && !defined(BSDI) && !defined(RHAPSODY)
#ifdef EMULTIHOP
case EMULTIHOP:
#endif
#ifdef ENOLINK
case ENOLINK:
#endif
case ETIMEDOUT:
PR_SetError(PR_REMOTE_FILE_ERROR, err);
break;
case ELOOP:
@ -278,8 +284,12 @@ void _MD_unix_map_rename_error(int err)
case ELOOP:
PR_SetError(PR_LOOP_ERROR, err);
break;
#if !defined(OSF1) && !defined(FREEBSD) && !defined(BSDI) && !defined(RHAPSODY)
#ifdef EMULTIHOP
case EMULTIHOP:
PR_SetError(PR_REMOTE_FILE_ERROR, err);
break;
#endif
#ifdef ENOLINK
case ENOLINK:
PR_SetError(PR_REMOTE_FILE_ERROR, err);
break;
@ -329,8 +339,10 @@ void _MD_unix_map_access_error(int err)
case ELOOP:
PR_SetError(PR_LOOP_ERROR, err);
break;
#if !defined(OSF1) && !defined(FREEBSD) && !defined(BSDI) && !defined(RHAPSODY)
#ifdef EMULTIHOP
case EMULTIHOP:
#endif
#ifdef ENOLINK
case ENOLINK:
#endif
case ETIMEDOUT:
@ -395,8 +407,12 @@ void _MD_unix_map_mkdir_error(int err)
case EIO:
PR_SetError(PR_IO_ERROR, err);
break;
#if !defined(OSF1) && !defined(FREEBSD) && !defined(BSDI) && !defined(RHAPSODY)
#ifdef EMULTIHOP
case EMULTIHOP:
PR_SetError(PR_REMOTE_FILE_ERROR, err);
break;
#endif
#ifdef ENOLINK
case ENOLINK:
PR_SetError(PR_REMOTE_FILE_ERROR, err);
break;
@ -432,8 +448,10 @@ void _MD_unix_map_rmdir_error(int err)
case ELOOP:
PR_SetError(PR_LOOP_ERROR, err);
break;
#if !defined(OSF1) && !defined(FREEBSD) && !defined(BSDI) && !defined(RHAPSODY)
#ifdef EMULTIHOP
case EMULTIHOP:
#endif
#ifdef ENOLINK
case ENOLINK:
#endif
case ETIMEDOUT:
@ -1344,11 +1362,13 @@ void _MD_unix_map_open_error(int err)
case EPERM:
PR_SetError(PR_NO_ACCESS_RIGHTS_ERROR, err);
break;
case ETIMEDOUT:
#if !defined(OSF1) && !defined(FREEBSD) && !defined(BSDI) && !defined(RHAPSODY)
#ifdef EMULTIHOP
case EMULTIHOP:
#endif
#ifdef ENOLINK
case ENOLINK:
#endif
case ETIMEDOUT:
PR_SetError(PR_REMOTE_FILE_ERROR, err);
break;
case EROFS:

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

@ -324,6 +324,8 @@ int poll(void *listptr, unsigned long nfds, long timeout)
int poll(struct pollfd filedes[], unsigned int nfds, int timeout)
#elif defined(HPUX9)
int poll(struct pollfd filedes[], int nfds, int timeout)
#elif defined(NETBSD)
int poll(struct pollfd *filedes, nfds_t nfds, int timeout)
#else
int poll(struct pollfd *filedes, unsigned long nfds, int timeout)
#endif

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

@ -75,7 +75,7 @@
#elif defined(IRIX) || (defined(AIX) && !defined(AIX4_1)) \
|| defined(OSF1) || defined(SOLARIS) \
|| defined(HPUX10_30) || defined(HPUX11) || defined(LINUX) \
|| defined(FREEBSD)
|| defined(FREEBSD) || defined(NETBSD)
#define _PRSelectFdSetArg_t fd_set *
#else
#error "Cannot determine architecture"
@ -2506,7 +2506,7 @@ static PRIOMethods _pr_udp_methods = {
#endif
#if defined(HPUX) || defined(OSF1) || defined(SOLARIS) || defined (IRIX) \
|| defined(AIX) || defined(LINUX) || defined(FREEBSD)
|| defined(AIX) || defined(LINUX) || defined(FREEBSD) || defined(NETBSD)
#define _PR_FCNTL_FLAGS O_NONBLOCK
#else
#error "Can't determine architecture"

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

@ -194,11 +194,11 @@ static PRThread* _PR_CreateThread(
if (EPERM != pt_schedpriv)
{
#if !defined(_PR_DCETHREADS) && !defined(FREEBSD)
#if !defined(_PR_DCETHREADS) && !defined(FREEBSD) && !defined(NETBSD)
struct sched_param schedule;
#endif
#if !defined(FREEBSD)
#if !defined(FREEBSD) && !defined(NETBSD)
rv = pthread_attr_setinheritsched(&tattr, PTHREAD_EXPLICIT_SCHED);
PR_ASSERT(0 == rv);
#endif
@ -208,7 +208,7 @@ static PRThread* _PR_CreateThread(
#if defined(_PR_DCETHREADS)
rv = pthread_attr_setprio(&tattr, pt_PriorityMap(priority));
PR_ASSERT(0 == rv);
#elif !defined(FREEBSD)
#elif !defined(FREEBSD) && !defined(NETBSD)
rv = pthread_attr_getschedparam(&tattr, &schedule);
PR_ASSERT(0 == rv);
schedule.sched_priority = pt_PriorityMap(priority);
@ -550,7 +550,7 @@ PR_IMPLEMENT(void) PR_SetThreadPriority(PRThread *thred, PRThreadPriority newPri
rv = pthread_setprio(thred->id, pt_PriorityMap(newPri));
/* pthread_setprio returns the old priority */
PR_ASSERT(-1 != rv);
#elif !defined(FREEBSD)
#elif !defined(FREEBSD) && !defined(NETBSD)
if (EPERM != pt_schedpriv)
{
int policy;
@ -751,7 +751,7 @@ void _PR_InitThreads(
* conflict with the use of these two signals in our GC support.
* So we don't know how to support GC on Linux pthreads.
*/
#if !defined(LINUX) && !defined(FREEBSD)
#if !defined(LINUX) && !defined(FREEBSD) && !defined(NETBSD)
init_pthread_gc_support();
#endif
@ -1036,7 +1036,7 @@ static void suspend_signal_handler(PRIntn sig)
pthread_cond_signal(&me->suspendResumeCV);
while (me->suspend & PT_THREAD_SUSPENDED)
{
#if !defined(FREEBSD) /*XXX*/
#if !defined(FREEBSD) && !defined(NETBSD) /*XXX*/
PRIntn rv;
sigwait(&sigwait_set, &rv);
#endif