diff --git a/nsprpub/config/BeOS.mk b/nsprpub/config/BeOS.mk new file mode 100644 index 00000000000..93c56f35dce --- /dev/null +++ b/nsprpub/config/BeOS.mk @@ -0,0 +1,121 @@ +# +# 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 BeOS (all architectures) +###################################################################### + +###################################################################### +# Version-independent +###################################################################### + +DEFINES += +XP_DEFINE = -DXP_BEOS + +OBJ_SUFFIX = o +LIB_SUFFIX = a +DLL_SUFFIX = so +AR = ar cr $@ + +ifdef BUILD_OPT +DEFINES = -UDEBUG -DNDEBUG +OBJDIR_TAG = _OPT +else +DEFINES = -DDEBUG -UNDEBUG +OBJDIR_TAG = _DBG +endif + +ifeq (PC,$(findstring PC,$(OS_TEST))) +CPU_ARCH = x86 +CC = gcc +CCC = g++ +LD = gcc +RANLIB = ranlib +DSO_LDOPTS = -nostart +PORT_FLAGS = -DHAVE_STRERROR +ifdef BUILD_OPT +OPTIMIZER = -O2 +LDFLAGS += -s +else +OPTIMIZER = -gdwarf-2 -O0 +endif +else +CPU_ARCH = ppc +CC = mwcc +CCC = mwcc +LD = mwld +RANLIB = ranlib +DSO_LDOPTS = -xms -export pragma \ + -init _init_routine_ \ + -term _term_routine_ \ + -lroot -lnet \ + /boot/develop/lib/ppc/glue-noinit.a \ + /boot/develop/lib/ppc/init_term_dyn.o \ + /boot/develop/lib/ppc/start_dyn.o + +PORT_FLAGS = -DHAVE_STRERROR -D_POSIX_SOURCE +ifdef BUILD_OPT +OPTIMIZER = -O2 +else +OPTIMIZER = -g -O0 +endif +endif +CPU_ARCH_TAG = _$(CPU_ARCH) + +OS_INCLUDES = -I- -I. +#G++INCLUDES = -I/usr/include/g++ + +PLATFORM_FLAGS = -DBeOS -DBEOS $(OS_INCLUDES) + +OS_CFLAGS = $(DSO_CFLAGS) $(PLATFORM_FLAGS) $(PORT_FLAGS) + +USE_BTHREADS = 1 + +MKSHLIB = $(LD) $(DSO_LDOPTS) + +OBJDIR_NAME = $(OS_CONFIG)_$(CPU_ARCH)$(OBJDIR_TAG).OBJ + +#################################################################### +# +# One can define the makefile variable NSDISTMODE to control +# how files are published to the 'dist' directory. If not +# defined, the default is "install using relative symbolic +# links". The two possible values are "copy", which copies files +# but preserves source mtime, and "absolute_symlink", which +# installs using absolute symbolic links. The "absolute_symlink" +# option requires NFSPWD. +# +#################################################################### + +NSINSTALL = $(MOD_DEPTH)/config/$(OBJDIR_NAME)/nsinstall + +ifeq ($(NSDISTMODE),copy) +# copy files, but preserve source mtime +INSTALL = $(NSINSTALL) -t +else +ifeq ($(NSDISTMODE),absolute_symlink) +# install using absolute symbolic links +INSTALL = $(NSINSTALL) -L `$(NFSPWD)` +else +# install using relative symbolic links +INSTALL = $(NSINSTALL) -R +endif +endif + +define MAKE_OBJDIR +if test ! -d $(@D); then rm -rf $(@D); $(NSINSTALL) -D $(@D); fi +endef diff --git a/nsprpub/pr/include/md/_beos.cfg b/nsprpub/pr/include/md/_beos.cfg new file mode 100644 index 00000000000..38af63daa73 --- /dev/null +++ b/nsprpub/pr/include/md/_beos.cfg @@ -0,0 +1,128 @@ +/* -*- 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 + * 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_BEOS +#define XP_BEOS +#undef XP_UNIX +#endif + +#ifndef BEOS +#define BEOS +#endif + +#ifdef __powerpc__ +#undef IS_LITTLE_ENDIAN +#define IS_BIG_ENDIAN 1 +#else +#define IS_LITTLE_ENDIAN 1 +#undef IS_BIG_ENDIAN +#endif + +#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 + +#define HAVE_LONG_LONG +/* + * XXX These two macros need to be investigated for different architectures. + */ +#define HAVE_ALIGNED_DOUBLES +#define 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___ */ diff --git a/nsprpub/pr/include/md/_beos.h b/nsprpub/pr/include/md/_beos.h new file mode 100644 index 00000000000..ae430a7f993 --- /dev/null +++ b/nsprpub/pr/include/md/_beos.h @@ -0,0 +1,571 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * 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_beos_defs_h___ +#define nspr_beos_defs_h___ + +#include "prtypes.h" +#include "prio.h" +#include "prthread.h" +#include "prproces.h" +#include "prmem.h" +#include "obsolete/prsem.h" +#include + +#include +#include +#include + +/* + * Internal configuration macros + */ + +#define PR_LINKER_ARCH "beos" +#define _PR_SI_SYSNAME "BEOS" +#ifdef __powerpc__ +#define _PR_SI_ARCHITECTURE "ppc" +#else +#define _PR_SI_ARCHITECTURE "x86" +#endif +#define PR_DLL_SUFFIX ".so" + +#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 _PR_NO_CLOCK_TIMER + +/* + * The Atomic operations + */ + +#define _PR_HAVE_ATOMIC_OPS +#define _MD_INIT_ATOMIC _MD_AtomicInit +#define _MD_ATOMIC_INCREMENT _MD_AtomicIncrement +#define _MD_ATOMIC_ADD _MD_AtomicAdd +#define _MD_ATOMIC_DECREMENT _MD_AtomicDecrement +#define _MD_ATOMIC_SET _MD_AtomicSet + +#define HAVE_CVAR_BUILT_ON_SEM +#define _PR_GLOBAL_THREADS_ONLY +#define _PR_BTHREADS +#define _PR_NEED_FAKE_POLL + +/* Define threading functions and objects as native BeOS */ +struct _MDThread { + thread_id tid; /* BeOS thread handle */ + bool is_joinable; /* TRUE if PR_JOINABLE */ + bool is_joining; /* TRUE if we were woken up to join */ +}; + +struct _MDThreadStack { + PRInt8 notused; +}; + +/* + * Lock and Semaphore related definitions + */ + +struct _MDLock { + sem_id semaphoreID; + int32 benaphoreCount; +}; + +struct _MDCVar { + sem_id sem1; + sem_id sem2; + int16 count; +}; + +struct _MDSemaphore { + sem_id sid; +}; + +/* +** CPU-related definitions +*/ +struct _MDCPU { + int8 unused; +}; + +/* +** Process-related definitions +*/ +struct _MDProcess { + pid_t pid; +}; + +struct _MDSegment { + PRInt8 notused; +}; + +/* +** File- and directory-related definitions +*/ + +#define BE_SOCK_SHUTDOWN_READ 0x01 +#define BE_SOCK_SHUTDOWN_WRITE 0x02 + +struct _MDFileDesc { + PRInt32 osfd; + PRInt32 sock_state; + PRBool accepted_socket; + PRNetAddr peer_addr; + PRBool connectValueValid; + int connectReturnValue; + int connectReturnError; +}; + +struct _MDDir { + DIR *d; +}; + +#define PR_DIRECTORY_SEPARATOR '/' +#define PR_DIRECTORY_SEPARATOR_STR "/" +#define PR_PATH_SEPARATOR ':' +#define PR_PATH_SEPARATOR_STR ":" + +#undef HAVE_SOCKET_REUSEADDR +#undef HAVE_SOCKET_KEEPALIVE + +#define GETTIMEOFDAY(tp) gettimeofday((tp), NULL) + +/* --- Memory-mapped files stuff --- not implemented on BeOS */ + +struct _MDFileMap { + PRInt8 unused; +}; + +/* + * Network related definitions. + */ + +#define IPPROTO_IP 0 +#define AF_UNIX 2 +#define TCP_NODELAY SO_NONBLOCK +#define SO_LINGER -1 +#define SO_ERROR 4 + +#define _PR_INTERRUPT_CHECK_INTERVAL_SECS 5 + +/* these aren't actually used. if they are, we're screwed */ +struct protoent { + char *p_name; /* official protocol name */ + char **p_aliases; /* alias list */ + int p_proto; /* protocol # */ +}; + +struct protoent* getprotobyname(const char* name); +struct protoent* getprotobynumber(int number); + +/* + * malloc() related definitions. + */ + +#undef _PR_OVERRIDE_MALLOC + +/* Miscellaneous */ + +#define _MD_ERRNO() (errno) + +#define _MD_CLEANUP_BEFORE_EXIT _MD_cleanup_before_exit +#define _MD_EXIT _MD_exit + +#define _MD_GET_ENV getenv +#define _MD_PUT_ENV putenv + +#define _MD_EARLY_INIT _MD_early_init +#define _MD_FINAL_INIT _MD_final_init + +/* CPU Stuff */ + +#define _MD_INIT_CPUS _MD_init_cpus +#define _MD_WAKEUP_CPUS _MD_wakeup_cpus +#define _MD_START_INTERRUPTS _MD_start_interrupts +#define _MD_STOP_INTERRUPTS _MD_stop_interrupts +#define _MD_DISABLE_CLOCK_INTERRUPTS _MD_disable_clock_interrupts +#define _MD_BLOCK_CLOCK_INTERRUPTS _MD_block_clock_interrupts +#define _MD_UNBLOCK_CLOCK_INTERRUPTS _MD_unblock_clock_interrupts +#define _MD_CLOCK_INTERRUPT _MD_clock_interrupt +#define _MD_INIT_STACK _MD_init_stack +#define _MD_CLEAR_STACK _MD_clear_stack +// #define _MD_GET_INTSOFF _MD_get_intsoff +// #define _MD_SET_INTSOFF _MD_set_intsoff +#define _MD_CURRENT_CPU _MD_current_cpu +#define _MD_SET_CURRENT_CPU _MD_set_current_cpu +#define _MD_INIT_RUNNING_CPU _MD_init_running_cpu +#define _MD_PAUSE_CPU _MD_pause_cpu + +/* Thread stuff */ + +#define _MD_CURRENT_THREAD() PR_GetCurrentThread() +// #define _MD_GET_ATTACHED_THREAD _MD_get_attached_thread +#define _MD_LAST_THREAD _MD_last_thread +#define _MD_SET_CURRENT_THREAD _MD_set_current_THREAD +#define _MD_SET_LAST_THREAD _MD_set_last_thread +#define _MD_INIT_THREAD _MD_init_thread +#define _MD_EXIT_THREAD _MD_exit_thread +#define _MD_INIT_ATTACHED_THREAD _MD_init_attached_thread + +#define _MD_SUSPEND_THREAD _MD_suspend_thread +#define _MD_RESUME_THREAD _MD_resume_thread +#define _MD_SUSPEND_CPU _MD_suspend_cpu +#define _MD_RESUME_CPU _MD_resume_cpu +#define _MD_BEGIN_SUSPEND_ALL _MD_begin_suspend_all +#define _MD_END_SUSPEND_ALL _MD_end_suspend_all +#define _MD_BEGIN_RESUME_ALL _MD_begin_resume_all +#define _MD_END_RESUME_ALL _MD_end_resume_all + +#define _MD_GET_SP _MD_get_sp + +#define _MD_CLEAN_THREAD _MD_clean_thread +#define _MD_CREATE_PRIMORDIAL_USER_THREAD _MD_create_primordial_user_thread +#define _MD_CREATE_USER_THREAD _MD_create_user_thread +#define _MD_INIT_PRIMORDIAL_THREAD _MD_init_primordial_thread +#define _MD_CREATE_THREAD _MD_create_thread +#define _MD_YIELD _MD_yield +#define _MD_SET_PRIORITY _MD_set_priority + +#define _MD_SUSPENDALL _MD_suspendall +#define _MD_RESUMEALL _MD_resumeall + +#define _MD_SWITCH_CONTEXT _MD_switch_context +#define _MD_RESTORE_CONTEXT _MD_restore_context + +#define _MD_WAIT _MD_wait +#define _MD_WAKEUP_WAITER _MD_wakeup_waiter + +#define _MD_SETTHREADAFFINITYMASK _MD_setthreadaffinitymask +#define _MD_GETTHREADAFFINITYMASK _MD_getthreadaffinitymask + +/* Thread Synchronization */ + +#define _MD_INIT_LOCKS _MD_init_locks +#define _MD_NEW_LOCK _MD_new_lock +#define _MD_FREE_LOCK _MD_free_lock +#define _MD_LOCK _MD_lock +#define _MD_TEST_AND_LOCK _MD_test_and_lock +#define _MD_UNLOCK _MD_unlock +#define _MD_IOQ_LOCK _MD_ioq_lock +#define _MD_IOQ_UNLOCK _MD_ioq_unlock +#define _MD_NEW_SEM _MD_new_sem +#define _MD_DESTROY_SEM _MD_destroy_sem +#define _MD_TIMED_WAIT_SEM _MD_timed_wait_sem +#define _MD_WAIT_SEM _MD_wait_sem +#define _MD_POST_SEM _MD_post_sem +// #define _MD_NEW_CV _MD_new_cv +// #define _MD_FREE_CV _MD_free_cv +// #define _MD_WAIT_CV _MD_wait_cv +// #define _MD_NOTIFY_CV _MD_notify_cv +// #define _MD_NOTIFYALL_CV _MD_notifyall_cv + +/* File I/O */ + +/* don't need any I/O initializations */ +#define _MD_INIT_IO() +#define _MD_INIT_FILEDESC(fd) + +#define _MD_OPEN_DIR _MD_open_dir +#define _MD_READ_DIR _MD_read_dir +#define _MD_CLOSE_DIR _MD_close_dir +#define _MD_MAKE_NONBLOCK _MD_make_nonblock +#define _MD_OPEN _MD_open +#define _MD_CLOSE_FILE _MD_close_file +#define _MD_READ _MD_read +#define _MD_WRITE _MD_write +#define _MD_WRITEV _MD_writev +#define _MD_LSEEK _MD_lseek +#define _MD_LSEEK64 _MD_lseek64 +#define _MD_FSYNC _MD_fsync +#define _MD_DELETE _MD_delete +#define _MD_GETFILEINFO _MD_getfileinfo +#define _MD_GETFILEINFO64 _MD_getfileinfo64 +#define _MD_GETOPENFILEINFO _MD_getopenfileinfo +#define _MD_GETOPENFILEINFO64 _MD_getopenfileinfo64 +#define _MD_RENAME _MD_rename +#define _MD_ACCESS _MD_access +#define _MD_STAT stat +#define _MD_MKDIR _MD_mkdir +#define _MD_RMDIR _MD_rmdir +#define _MD_PR_POLL _MD_pr_poll + +/* Network I/O */ + +#define _MD_CLOSE_SOCKET _MD_close_socket +#define _MD_CONNECT _MD_connect +#define _MD_ACCEPT _MD_accept +#define _MD_BIND _MD_bind +#define _MD_LISTEN _MD_listen +#define _MD_SHUTDOWN _MD_shutdown +#define _MD_RECV _MD_recv +#define _MD_SEND _MD_send +#define _MD_ACCEPT_READ _MD_accept_read +#define _MD_TRANSMITFILE _MD_transmitfile +#define _MD_GETSOCKNAME _MD_getsockname +#define _MD_GETPEERNAME _MD_getpeername +#define _MD_GETSOCKOPT _MD_getsockopt +#define _MD_SETSOCKOPT _MD_setsockopt +#define _MD_RECVFROM _MD_recvfrom +#define _MD_SENDTO _MD_sendto +#define _MD_SOCKETPAIR _MD_socketpair +#define _MD_SOCKET _MD_socket +#define _MD_SOCKETAVAILABLE _MD_socketavailable + +#define _MD_GET_SOCKET_ERROR() (errno) +#define _MD_GETHOSTNAME _MD_gethostname + +#define _MD_SELECT select + +/* Process management */ + +#define _MD_CREATE_PROCESS _MD_create_process +#define _MD_DETACH_PROCESS _MD_detach_process +#define _MD_WAIT_PROCESS _MD_wait_process +#define _MD_KILL_PROCESS _MD_kill_process + +/* Atomic data operations */ + +// #define _MD_INIT_ATOMIC _MD_init_atomic +// #define _MD_ATOMIC_INCREMENT _MD_atomic_increment +// #define _MD_ATOMIC_DECREMENT _MD_atomic_decrement +// #define _MD_ATOMIC_SET _MD_atomic_set + +/* memory management */ + +#define _MD_INIT_SEGS _MD_init_segs +#define _MD_ALLOC_SEGMENT _MD_alloc_segment +#define _MD_FREE_SEGMENT _MD_free_segment + +/* Memory mapped file I/O */ + +#define _MD_CREATE_FILE_MAP _MD_create_file_map +#define _MD_MEM_MAP _MD_mem_map +#define _MD_MEM_UNMAP _MD_mem_unmap +#define _MD_CLOSE_FILE_MAP _MD_close_file_map + +/* Time related */ + +#define _MD_NOW _MD_now +#define _MD_INTERVAL_INIT _MD_interval_init +#define _MD_GET_INTERVAL _MD_get_interval +#define _MD_INTERVAL_PER_SEC _MD_interval_per_sec + +/* File locking */ + +#define _MD_LOCKFILE _MD_lockfile +#define _MD_TLOCKFILE _MD_tlockfile +#define _MD_UNLOCKFILE _MD_unlockfile + +/** + * Prototypes for machine dependent function implementations. (Too bad + * NSPR's MD system blows so much that we have to reiterate every stinking + * thing we implement here in our MD header file.) + */ + +/* Miscellaneous */ + +PR_EXTERN(void) _MD_cleanup_before_exit(void); +PR_EXTERN(void) _MD_exit(PRIntn status); + +PR_EXTERN(char*) _MD_get_env(const char *name); +PR_EXTERN(PRIntn) _MD_put_env(const char *name); + +PR_EXTERN(void) _MD_early_init(void); +PR_EXTERN(void) _MD_final_init(void); + +/* CPU Stuff */ + +PR_EXTERN(void) _MD_init_cpus(); +PR_EXTERN(void) _MD_wakeup_cpus(); +PR_EXTERN(void) _MD_start_interrupts(void); +PR_EXTERN(void) _MD_stop_interrupts(void); +PR_EXTERN(void) _MD_disable_clock_interrupts(void); +PR_EXTERN(void) _MD_block_clock_interrupts(void); +PR_EXTERN(void) _MD_unblock_clock_interrupts(void); +PR_EXTERN(void) _MD_clock_interrupt(void); +// PR_EXTERN(void) _MD_init_stack(PRThreadStack *ts, PRIntn redzone); +// PR_EXTERN(void) _MD_clear_stack(PRThreadStack* ts); +// PR_EXTERN(PRInt32) _MD_get_intsoff(void); +// PR_EXTERN(void) _MD_set_intsoff(PRInt32 _val); +// PR_EXTERN(_PRCPU*) _MD_current_cpu(void); +// PR_EXTERN(void) _MD_set_current_cpu(_PRCPU *cpu); +// PR_EXTERN(void) _MD_init_running_cpu(_PRCPU *cpu); +PR_EXTERN(PRInt32) _MD_pause_cpu(PRIntervalTime timeout); + +/* Thread stuff */ + +// PR_EXTERN(PRThread*) _MD_current_thread(void); +PR_EXTERN(PRThread*) _MD_get_attached_thread(void); +PR_EXTERN(PRThread*) _MD_last_thread(void); +PR_EXTERN(void) _MD_set_current_thread(PRThread *thread); +PR_EXTERN(void) _MD_set_last_thread(PRThread *thread); +PR_EXTERN(PRStatus) _MD_init_thread(PRThread *thread); +PR_EXTERN(void) _MD_exit_thread(PRThread *thread); +PR_EXTERN(PRStatus) _MD_init_attached_thread(PRThread *thread); + +PR_EXTERN(void) _MD_suspend_thread(PRThread *thread); +PR_EXTERN(void) _MD_resume_thread(PRThread *thread); +// PR_EXTERN(void) _MD_suspend_cpu(_PRCPU *cpu); +// PR_EXTERN(void) _MD_resume_cpu(_PRCPU *cpu); +PR_EXTERN(void) _MD_begin_suspend_all(void); +PR_EXTERN(void) _MD_end_suspend_all(void); +PR_EXTERN(void) _MD_begin_resume_all(void); +PR_EXTERN(void) _MD_end_resume_all(void); + +PR_EXTERN(void *) _MD_get_sp(PRThread *thread); + +PR_EXTERN(void) _MD_clean_thread(PRThread *thread); +PR_EXTERN(void) _MD_create_primordial_user_thread(PRThread *); +PR_EXTERN(PRThread*) _MD_create_user_thread(PRUint32 stacksize, void (*start)(void *), void *arg); +PR_EXTERN(void) _MD_init_primordial_thread(PRThread *thread); +PR_EXTERN(PRStatus) _MD_create_thread(PRThread *thread, void (*start)(void *), PRThreadPriority priority, PRThreadScope scope, PRThreadState state, PRUint32 stackSize); +PR_EXTERN(void) _MD_yield(void); +PR_EXTERN(void) _MD_set_priority(struct _MDThread *md, PRThreadPriority newPri); + +PR_EXTERN(void) _MD_suspendall(void); +PR_EXTERN(void) _MD_resumeall(void); + +PR_EXTERN(void) _MD_init_context(PRThread *thread, char *top, void (*start) (void), PRBool *status); +PR_EXTERN(void) _MD_switch_context(PRThread *thread); +PR_EXTERN(void) _MD_restore_context(PRThread *thread); + +PR_EXTERN(PRStatus) _MD_wait(PRThread *, PRIntervalTime timeout); +PR_EXTERN(PRStatus) _MD_wakeup_waiter(PRThread *); + +PR_EXTERN(PRInt32) _MD_setthreadaffinitymask(PRThread *thread, PRUint32 mask ); +PR_EXTERN(PRInt32) _MD_getthreadaffinitymask(PRThread *thread, PRUint32 *mask); + +/* Thread Synchronization */ + +PR_EXTERN(void) _MD_init_locks(void); +PR_EXTERN(PRStatus) _MD_new_lock(struct _MDLock *md); +PR_EXTERN(void) _MD_free_lock(struct _MDLock *md); +PR_EXTERN(void) _MD_lock(struct _MDLock *md); +PR_EXTERN(PRBool) _MD_test_and_lock(struct _MDLock *md); +PR_EXTERN(void) _MD_unlock(struct _MDLock *md); +PR_EXTERN(void) _MD_ioq_lock(void); +PR_EXTERN(void) _MD_ioq_unlock(void); +PR_EXTERN(void) _MD_new_sem(struct _MDSemaphore *md, PRUintn value); +PR_EXTERN(void) _MD_destroy_sem(struct _MDSemaphore *md); +PR_EXTERN(PRStatus) _MD_timed_wait_sem(struct _MDSemaphore *md, PRIntervalTime timeout); +PR_EXTERN(PRStatus) _MD_wait_sem(struct _MDSemaphore *md); +PR_EXTERN(void) _MD_post_sem(struct _MDSemaphore *md); +// PR_EXTERN(PRInt32) _MD_new_cv(struct _MDCVar *md); +// PR_EXTERN(void) _MD_free_cv(struct _MDCVar *md); +// PR_EXTERN(void) _MD_wait_cv(struct _MDCVar *mdCVar, struct _MDLock *mdLock, PRIntervalTime timeout); +// PR_EXTERN(void) _MD_notify_cv(struct _MDCVar *md, struct _MDLock *lock); +// PR_EXTERN(void) _MD_notifyall_cv(struct _MDCVar *md, struct _MDLock *lock); + +/* File I/O */ + +// PR_EXTERN(void) _MD_init_io(void); +PR_EXTERN(PRStatus) _MD_open_dir(struct _MDDir *md,const char *name); +PR_EXTERN(char *) _MD_read_dir(struct _MDDir *md, PRIntn flags); +PR_EXTERN(PRInt32) _MD_close_dir(struct _MDDir *md); +PR_EXTERN(void) _MD_make_nonblock(PRFileDesc *fd); +PR_EXTERN(PRInt32) _MD_open(const char *name, PRIntn osflags, PRIntn mode); +PR_EXTERN(PRInt32) _MD_close_file(PRInt32 osfd); +PR_EXTERN(PRInt32) _MD_read(PRFileDesc *fd, void *buf, PRInt32 amount); +PR_EXTERN(PRInt32) _MD_write(PRFileDesc *fd, const void *buf, PRInt32 amount); +PR_EXTERN(PRInt32) _MD_writev(PRFileDesc *fd, struct PRIOVec *iov, PRInt32 iov_size, PRIntervalTime timeout); +PR_EXTERN(PRInt32) _MD_lseek(PRFileDesc *fd, PRInt32 offset, int whence); +PR_EXTERN(PRInt64) _MD_lseek64(PRFileDesc *fd, PRInt64 offset, int whence); +PR_EXTERN(PRInt32) _MD_fsync(PRFileDesc *fd); +PR_EXTERN(PRInt32) _MD_delete(const char *name); +PR_EXTERN(PRInt32) _MD_getfileinfo(const char *fn, PRFileInfo *info); +PR_EXTERN(PRInt32) _MD_getfileinfo64(const char *fn, PRFileInfo64 *info); +PR_EXTERN(PRInt32) _MD_getopenfileinfo(const PRFileDesc *fd, PRFileInfo *info); +PR_EXTERN(PRInt32) _MD_getopenfileinfo64(const PRFileDesc *fd, PRFileInfo64 *info); +PR_EXTERN(PRInt32) _MD_rename(const char *from, const char *to); +PR_EXTERN(PRInt32) _MD_access(const char *name, PRIntn how); +PR_EXTERN(PRInt32) _MD_stat(const char *name, struct stat *buf); +PR_EXTERN(PRInt32) _MD_mkdir(const char *name, PRIntn mode); +PR_EXTERN(PRInt32) _MD_rmdir(const char *name); +PR_EXTERN(PRInt32) _MD_pr_poll(PRPollDesc *pds, PRIntn npds, PRIntervalTime timeout); + +/* Network I/O */ +PR_EXTERN(PRInt32) _MD_close_socket(PRInt32 osfd); +PR_EXTERN(PRInt32) _MD_connect(PRFileDesc *fd, const PRNetAddr *addr, PRUint32 addrlen, PRIntervalTime timeout); +PR_EXTERN(PRInt32) _MD_accept(PRFileDesc *fd, PRNetAddr *addr, PRUint32 *addrlen, PRIntervalTime timeout); +PR_EXTERN(PRInt32) _MD_bind(PRFileDesc *fd, const PRNetAddr *addr, PRUint32 addrlen); +PR_EXTERN(PRInt32) _MD_listen(PRFileDesc *fd, PRIntn backlog); +PR_EXTERN(PRInt32) _MD_shutdown(PRFileDesc *fd, PRIntn how); +PR_EXTERN(PRInt32) _MD_recv(PRFileDesc *fd, void *buf, PRInt32 amount, PRIntn flags, PRIntervalTime timeout); +PR_EXTERN(PRInt32) _MD_send(PRFileDesc *fd, const void *buf, PRInt32 amount, PRIntn flags, PRIntervalTime timeout); +PR_EXTERN(PRInt32) _MD_accept_read(PRFileDesc *sd, PRInt32 *newSock, PRNetAddr **raddr, void *buf, PRInt32 amount, PRIntervalTime timeout); +// PR_EXTERN(PRInt32) _MD_fast_accept(PRFileDesc *fd, PRNetAddr *addr, PRUint32 *addrlen, PRIntervalTime timeout, PRBool fast, _PR_AcceptTimeoutCallback callback, void *callbackArg); +// PR_EXTERN(PRInt32) _MD_fast_accept_read(PRFileDesc *sd, PRInt32 *newSock, PRNetAddr **raddr, void *buf, PRInt32 amount, PRIntervalTime timeout, PRBool fast, _PR_AcceptTimeoutCallback callback, void *callbackArg); +// PR_EXTERN(void) _MD_update_accept_context(PRInt32 s, PRInt32 ls); +PR_EXTERN(PRInt32) _MD_transmitfile(PRFileDesc *sock, PRFileDesc *file, const void *headers, PRInt32 hlen, PRInt32 flags, PRIntervalTime timeout); +PR_EXTERN(PRStatus) _MD_getsockname(PRFileDesc *fd, PRNetAddr *addr, PRUint32 *addrlen); +PR_EXTERN(PRStatus) _MD_getpeername(PRFileDesc *fd, PRNetAddr *addr, PRUint32 *addrlen); +PR_EXTERN(PRStatus) _MD_getsockopt(PRFileDesc *fd, PRInt32 level, PRInt32 optname, char* optval, PRInt32* optlen); +PR_EXTERN(PRStatus) _MD_setsockopt(PRFileDesc *fd, PRInt32 level, PRInt32 optname, const char* optval, PRInt32 optlen); +PR_EXTERN(PRInt32) _MD_recvfrom(PRFileDesc *fd, void *buf, PRInt32 amount, PRIntn flags, PRNetAddr *addr, PRUint32 *addrlen, PRIntervalTime timeout); +PR_EXTERN(PRInt32) _MD_sendto(PRFileDesc *fd, const void *buf, PRInt32 amount, PRIntn flags, const PRNetAddr *addr, PRUint32 addrlen, PRIntervalTime timeout); +PR_EXTERN(PRInt32) _MD_socketpair(int af, int type, int flags, PRInt32 *osfd); +PR_EXTERN(PRInt32) _MD_socket(int af, int type, int flags); +PR_EXTERN(PRInt32) _MD_socketavailable(PRFileDesc *fd); + +// PR_EXTERN(PRInt32) _MD_get_socket_error(void); +PR_EXTERN(PRStatus) _MD_gethostname(char *name, PRUint32 namelen); + +/* Process management */ + +PR_EXTERN(PRProcess *) _MD_create_process(const char *path, char *const *argv, char *const *envp, const PRProcessAttr *attr); +PR_EXTERN(PRStatus) _MD_detach_process(PRProcess *process); +PR_EXTERN(PRStatus) _MD_wait_process(PRProcess *process, PRInt32 *exitCode); +PR_EXTERN(PRStatus) _MD_kill_process(PRProcess *process); + +/* Atomic data operations */ + +// PR_EXTERN(void) _MD_init_atomic(void); +// PR_EXTERN(PRInt32) _MD_atomic_increment(PRInt32 *); +// PR_EXTERN(PRInt32) _MD_atomic_decrement(PRInt32 *); +// PR_EXTERN(PRInt32) _MD_atomic_set(PRInt32 *, PRInt32); + +/* Memory management */ + +PR_EXTERN(void) _MD_init_segs(void); +PR_EXTERN(PRStatus) _MD_alloc_segment(PRSegment *seg, PRUint32 size, void *vaddr); +PR_EXTERN(void) _MD_free_segment(PRSegment *seg); + +/* Memory mapped file I/O */ + +PR_EXTERN(PRStatus) _MD_create_file_map(PRFileMap *fmap, PRInt64 size); +PR_EXTERN(void *) _MD_mem_map(PRFileMap *fmap, PRInt64 offset, PRUint32 len); +PR_EXTERN(PRStatus) _MD_mem_unmap(void *addr, PRUint32 size); +PR_EXTERN(PRStatus) _MD_close_file_map(PRFileMap *fmap); + +/* Time related */ + +PR_EXTERN(PRTime) _MD_now(void); +PR_EXTERN(void) _MD_interval_init(void); +PR_EXTERN(PRIntervalTime) _MD_get_interval(void); +PR_EXTERN(PRIntervalTime) _MD_interval_per_sec(void); + +/* File locking */ + +PR_EXTERN(PRStatus) _MD_lockfile(PRInt32 osfd); +PR_EXTERN(PRStatus) _MD_tlockfile(PRInt32 osfd); +PR_EXTERN(PRStatus) _MD_unlockfile(PRInt32 osfd); + +#endif /* _nspr_beos_defs_h___*/