_solaris.h revision 677833bc953b6cb418c701facbdcf4aa18d6c44e
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is the Netscape Portable Runtime (NSPR).
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998-2000
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nspr_solaris_defs_h___
#define nspr_solaris_defs_h___
/*
* Internal configuration macros
*/
#define PR_LINKER_ARCH "solaris"
#define _PR_SI_SYSNAME "SOLARIS"
#ifdef sparc
#define _PR_SI_ARCHITECTURE "sparc"
#define _PR_SI_ARCHITECTURE "x86"
#else
#endif
#define PR_DLL_SUFFIX ".so"
#define _PR_VMBASE 0x30000000
#define _PR_STACK_VMBASE 0x50000000
#define _MD_MMAP_FLAGS MAP_SHARED
#ifndef HAVE_WEAK_IO_SYMBOLS
#define HAVE_WEAK_IO_SYMBOLS
#endif
#define HAVE_DLL
#define USE_DLFCN
#define NEED_STRFTIME_LOCK
/*
* Intel x86 has atomic instructions.
*
* Sparc v8 does not have instructions to efficiently implement
* only and pthreads versions, we use the default atomic routine
* implementation in pratom.c. The obsolete global threads only
* version uses a global mutex_t to implement the atomic routines
* in solaris.c, which is actually equivalent to the default
* implementation.
*
* 64-bit Solaris requires sparc v9, which has atomic instructions.
*/
#define _PR_HAVE_ATOMIC_OPS
#endif
#if defined(_PR_GLOBAL_THREADS_ONLY) || defined(_PR_PTHREADS)
/*
* We have assembly language implementation of atomic
* stacks for the 32-bit sparc and x86 architectures only.
*
* Note: We ran into thread starvation problem with the
* 32-bit sparc assembly language implementation of atomic
* stacks, so we do not use it now. (Bugzilla bug 113740)
*/
#if !defined(sparc)
#define _PR_HAVE_ATOMIC_CAS
#endif
#endif
#define _PR_POLL_AVAILABLE
#define _PR_USE_POLL
#define _PR_STAT_HAS_ST_ATIM
#ifdef SOLARIS2_5
#define _PR_HAVE_SYSV_SEMAPHORES
#define PR_HAVE_SYSV_NAMED_SHARED_MEMORY
#else
#define _PR_HAVE_POSIX_SEMAPHORES
#endif
#define _PR_HAVE_GETIPNODEBYNAME
#define _PR_HAVE_GETIPNODEBYADDR
#define _PR_HAVE_GETADDRINFO
#define _PR_INET6_PROBE
#define _PR_ACCEPT_INHERIT_NONBLOCK
#ifdef _PR_INET6
#define _PR_HAVE_INET_NTOP
#else
#define AF_INET6 26
struct addrinfo {
int ai_flags;
int ai_family;
int ai_socktype;
int ai_protocol;
char *ai_canonname;
};
#define AI_CANONNAME 0x0010
#define AI_V4MAPPED 0x0001
#define AI_ALL 0x0002
#define AI_ADDRCONFIG 0x0004
#define _PR_HAVE_MD_SOCKADDR_IN6
/* isomorphic to struct in6_addr on Solaris 8 */
struct _md_in6_addr {
union {
} _S6_un;
};
/* isomorphic to struct sockaddr_in6 on Solaris 8 */
struct _md_sockaddr_in6 {
struct _md_in6_addr sin6_addr;
};
#endif
#if defined(_PR_GLOBAL_THREADS_ONLY) || defined(_PR_PTHREADS)
#define _PR_HAVE_GETHOST_R
#define _PR_HAVE_GETHOST_R_POINTER
#endif
#include "prinrval.h"
#if defined(_PR_HAVE_ATOMIC_OPS)
/*
** Atomic Operations
*/
#define _MD_INIT_ATOMIC()
#define _MD_ATOMIC_ADD _MD_AtomicAdd
#define _MD_ATOMIC_SET _MD_AtomicSet
#endif /* _PR_HAVE_ATOMIC_OPS */
#if defined(_PR_PTHREADS)
NSPR_API(void) _MD_EarlyInit(void);
#define _MD_EARLY_INIT _MD_EarlyInit
#define _MD_FINAL_INIT _PR_UnixInit
#elif defined(_PR_GLOBAL_THREADS_ONLY)
#include "prthread.h"
#include <ucontext.h>
/*
** Iinitialization Related definitions
*/
NSPR_API(void) _MD_EarlyInit(void);
#define _MD_EARLY_INIT _MD_EarlyInit
#define _MD_FINAL_INIT _PR_UnixInit
/*
** Clean-up the thread machine dependent data structure
*/
#define _MD_INIT_THREAD _MD_InitializeThread
void (*start)(void *),
#define _MD_CREATE_THREAD _MD_CreateThread
#define _PR_CONTEXT_TYPE ucontext_t
#include <thread.h>
#include <synch.h>
extern struct PRLock *_pr_schedLock;
/*
** Thread Local Storage
*/
#define THREAD_KEY_T thread_key_t
extern struct PRThread *_pr_attached_thread_tls();
extern struct PRThread *_pr_current_thread_tls();
extern struct _PRCPU *_pr_current_cpu_tls();
extern struct PRThread *_pr_last_thread_tls();
extern THREAD_KEY_T threadid_key;
extern THREAD_KEY_T cpuid_key;
extern THREAD_KEY_T last_thread_key;
#define _MD_GET_ATTACHED_THREAD() _pr_attached_thread_tls()
#define _MD_CURRENT_THREAD() _pr_current_thread_tls()
#define _MD_CURRENT_CPU() _pr_current_cpu_tls()
#define _MD_LAST_THREAD() _pr_last_thread_tls()
#define _MD_SET_CURRENT_THREAD(newval) \
#define _MD_SET_CURRENT_CPU(newval) \
#define _MD_SET_LAST_THREAD(newval) \
/* XXXX Needs to be defined - Prashant */
#define _MD_SUSPEND_CPU(cpu)
#define _MD_RESUME_CPU(cpu)
extern void _MD_Begin_SuspendAll(void);
extern void _MD_End_SuspendAll(void);
extern void _MD_End_ResumeAll(void);
#define _MD_BEGIN_SUSPEND_ALL() _MD_Begin_SuspendAll()
#define _MD_BEGIN_RESUME_ALL()
#define _MD_END_SUSPEND_ALL() _MD_End_SuspendAll()
#define _MD_END_RESUME_ALL() _MD_End_ResumeAll()
#define _MD_INIT_LOCKS()
#define _MD_NEW_LOCK(md_lockp) (mutex_init(&((md_lockp)->lock),USYNC_THREAD,NULL) ? PR_FAILURE : PR_SUCCESS)
struct _MDLock;
#ifndef PROFILE_LOCKS
#else
if (rv == 0) { \
} else { \
} \
#endif
#define _MD_ATTACH_THREAD(threadp)
#define THR_KEYCREATE thr_keycreate
#include <time.h>
/*
* segmentation fault, we use an emulated version _pr_solx86_clock_gettime(),
* which is implemented using gettimeofday().
*/
#if defined(i386) && defined(SOLARIS2_4)
#else
#endif /* i386 && SOLARIS2_4 */
#define _MD_SAVE_ERRNO(_thread)
#define _MD_RESTORE_ERRNO(_thread)
extern struct _MDLock _pr_ioq_lock;
#define _MD_WAKEUP_WAITER _MD_WakeupWaiter
NSPR_API(void) _MD_InitIO(void);
#define _MD_INIT_IO _MD_InitIO
#define _MD_SWITCH_CONTEXT(_thread)
#define _MD_RESTORE_CONTEXT(_newThread)
struct _MDLock {
#ifdef PROFILE_LOCKS
#endif
};
struct _MDCVar {
};
struct _MDSemaphore {
};
struct _MDThread {
struct _MDSemaphore waiter_sem;
};
struct _MDThreadStack {
};
struct _MDSegment {
};
/*
* md-specific cpu structure field, common to all Unix platforms
*/
#define _PR_MD_MAX_OSFD FD_SETSIZE
struct _MDCPU_Unix {
#ifndef _PR_USE_POLL
#else
struct pollfd *ioq_pollfds;
int ioq_pollfds_size;
#endif /* _PR_USE_POLL */
};
struct _MDCPU {
struct _MDCPU_Unix md_unix;
};
/* The following defines the unwrapped versions of select() and poll(). */
#define _MD_SELECT _select
#include <poll.h>
/*
** Missing function prototypes
*/
#else /* _PR_GLOBAL_THREADS_ONLY */
/*
* LOCAL_THREADS_ONLY implementation on Solaris
*/
#include "prthread.h"
#include <errno.h>
#include <ucontext.h>
#include <synch.h>
/*
** Iinitialization Related definitions
*/
NSPR_API(void) _MD_EarlyInit(void);
NSPR_API(void) _MD_SolarisInit();
#define _MD_EARLY_INIT _MD_EarlyInit
#define _MD_FINAL_INIT _MD_SolarisInit
#define _MD_INIT_THREAD _MD_InitializeThread
#ifdef USE_SETJMP
#include <setjmp.h>
#define _PR_CONTEXT_TYPE jmp_buf
#ifdef sparc
#else
#endif
#define PR_NUM_GCREGS _JBLEN
#else /* ! USE_SETJMP */
#ifdef sparc
#define _PR_CONTEXT_TYPE ucontext_t
/*
** Sparc's use register windows. the _MD_GetRegisters for the sparc's
** doesn't actually store anything into the argument buffer; instead the
** register windows are homed to the stack. I assume that the stack
** always has room for the registers to spill to...
*/
#define PR_NUM_GCREGS 0
#else
#define PR_NUM_GCREGS _JBLEN
#endif
#endif /* ! USE_SETJMP */
#include <time.h>
/*
* segmentation fault, we use an emulated version _pr_solx86_clock_gettime(),
* which is implemented using gettimeofday().
*/
#ifdef i386
#else
#endif /* i386 */
#ifdef sparc
#ifdef USE_SETJMP
#define _MD_SWITCH_CONTEXT(_thread) \
_PR_Schedule(); \
}
#define _MD_RESTORE_CONTEXT(_newThread) \
{ \
}
#else
/*
** Initialize the thread context preparing it to execute _main.
*/
getcontext(uc); \
/*
** Switch away from the current thread context by saving its state and
** calling the thread scheduler. Reload cpu when we come back from the
** context switch because it might have changed.
*/
#define _MD_SWITCH_CONTEXT(_thread) \
_PR_Schedule(); \
} \
/*
** Restore a thread context that was saved by _MD_SWITCH_CONTEXT or
** initialized by _MD_INIT_CONTEXT.
*/
#define _MD_RESTORE_CONTEXT(_newThread) \
setcontext(uc); \
#endif
#else /* x86 solaris */
#ifdef USE_SETJMP
#define _MD_SWITCH_CONTEXT(_thread) \
_PR_Schedule(); \
}
#define _MD_RESTORE_CONTEXT(_newThread) \
{ \
}
#else /* USE_SETJMP */
#define WINDOWSIZE 0
int getedi(void);
void setedi(int);
getcontext(uc); \
/* Force sp to be double aligned! */ \
uc->uc_mcontext.gregs[USP] = (int) ((unsigned long)(_sp - WINDOWSIZE - SA(MINFRAME)) & 0xfffffff8); \
/* getcontext() may return 1, contrary to what the man page says */
#define _MD_SWITCH_CONTEXT(_thread) \
if (! getcontext(uc)) { \
_PR_Schedule(); \
} else { \
_MD_LAST_THREAD()->no_sched = 0; \
} \
/*
** Restore a thread context, saved by _PR_SWITCH_CONTEXT
*/
#define _MD_RESTORE_CONTEXT(_newthread) \
setcontext(uc); \
#endif /* USE_SETJMP */
#endif /* sparc */
struct _MDLock {
};
struct _MDCVar {
};
struct _MDSemaphore {
};
struct _MDThread {
int errcode;
int id;
};
struct _MDThreadStack {
};
struct _MDSegment {
};
/*
* md-specific cpu structure field
*/
#define _PR_MD_MAX_OSFD FD_SETSIZE
struct _MDCPU_Unix {
#ifndef _PR_USE_POLL
#else
struct pollfd *ioq_pollfds;
int ioq_pollfds_size;
#endif /* _PR_USE_POLL */
};
struct _MDCPU {
struct _MDCPU_Unix md_unix;
};
#ifndef _PR_PTHREADS
#define _MD_INIT_LOCKS()
#endif
#define _MD_FREE_LOCK(lock)
#define _MD_UNLOCK(lock)
#define _MD_INIT_IO()
#define _MD_IOQ_LOCK()
#define _MD_IOQ_UNLOCK()
#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)
extern void _MD_YIELD(void);
/* The following defines the unwrapped versions of select() and poll(). */
#define _MD_SELECT _select
#include <stropts.h>
#include <poll.h>
/*
** Missing function prototypes
*/
#endif /* _PR_GLOBAL_THREADS_ONLY */
extern void _MD_solaris_map_sendfile_error(int err);
#endif /* nspr_solaris_defs_h___ */