nsprpub/pr/include/md/_openbsd.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/nsprpub/pr/include/md/_openbsd.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,209 @@
     1.4 +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.8 +
     1.9 +#ifndef nspr_openbsd_defs_h___
    1.10 +#define nspr_openbsd_defs_h___
    1.11 +
    1.12 +#include <sys/syscall.h>
    1.13 +
    1.14 +#define PR_LINKER_ARCH	"openbsd"
    1.15 +#define _PR_SI_SYSNAME  "OPENBSD"
    1.16 +#if defined(__i386__)
    1.17 +#define _PR_SI_ARCHITECTURE "x86"
    1.18 +#elif defined(__alpha__)
    1.19 +#define _PR_SI_ARCHITECTURE "alpha"
    1.20 +#elif defined(__amd64__)
    1.21 +#define _PR_SI_ARCHITECTURE "amd64"
    1.22 +#elif defined(__m68k__)
    1.23 +#define _PR_SI_ARCHITECTURE "m68k"
    1.24 +#elif defined(__powerpc__)
    1.25 +#define _PR_SI_ARCHITECTURE "powerpc"
    1.26 +#elif defined(__sparc__)
    1.27 +#define _PR_SI_ARCHITECTURE "sparc"
    1.28 +#elif defined(__arm__)
    1.29 +#define _PR_SI_ARCHITECTURE "arm"
    1.30 +#endif
    1.31 +
    1.32 +#define PR_DLL_SUFFIX		".so"
    1.33 +
    1.34 +#define _PR_VMBASE              0x30000000
    1.35 +#define _PR_STACK_VMBASE	0x50000000
    1.36 +#define _MD_DEFAULT_STACK_SIZE	65536L
    1.37 +#define _MD_MMAP_FLAGS          MAP_PRIVATE
    1.38 +
    1.39 +#undef  HAVE_STACK_GROWING_UP
    1.40 +#define HAVE_DLL
    1.41 +#define USE_DLFCN
    1.42 +#define _PR_HAVE_SOCKADDR_LEN
    1.43 +#define _PR_HAVE_LARGE_OFF_T
    1.44 +#define _PR_STAT_HAS_ST_ATIMESPEC
    1.45 +#define _PR_POLL_AVAILABLE
    1.46 +#define _PR_USE_POLL
    1.47 +#define _PR_HAVE_SYSV_SEMAPHORES
    1.48 +#define PR_HAVE_SYSV_NAMED_SHARED_MEMORY
    1.49 +
    1.50 +#define _PR_INET6
    1.51 +#define _PR_HAVE_INET_NTOP
    1.52 +#define _PR_HAVE_GETHOSTBYNAME2
    1.53 +#define _PR_HAVE_GETADDRINFO
    1.54 +#define _PR_INET6_PROBE
    1.55 +
    1.56 +#define USE_SETJMP
    1.57 +
    1.58 +#ifndef _PR_PTHREADS
    1.59 +#include <setjmp.h>
    1.60 +
    1.61 +#define PR_CONTEXT_TYPE	sigjmp_buf
    1.62 +
    1.63 +#define CONTEXT(_th) ((_th)->md.context)
    1.64 +
    1.65 +#if defined(__i386__) || defined(__sparc__) || defined(__m68k__)
    1.66 +#define JB_SP_INDEX 2
    1.67 +#elif defined(__powerpc__)
    1.68 +#define JB_SP_INDEX 1
    1.69 +#elif defined(__alpha__)
    1.70 +#define JB_SP_INDEX 34
    1.71 +#elif defined(__amd64__)
    1.72 +#define JB_SP_INDEX 6
    1.73 +#elif defined(__arm__)
    1.74 +#define JB_SP_INDEX 23
    1.75 +#else
    1.76 +#error "Need to define SP index in jmp_buf here"
    1.77 +#endif
    1.78 +#define _MD_GET_SP(_th)    (_th)->md.context[JB_SP_INDEX]
    1.79 +
    1.80 +#define PR_NUM_GCREGS	_JBLEN
    1.81 +
    1.82 +/*
    1.83 +** Initialize a thread context to run "_main()" when started
    1.84 +*/
    1.85 +#define _MD_INIT_CONTEXT(_thread, _sp, _main, status)  \
    1.86 +{  \
    1.87 +    *status = PR_TRUE;  \
    1.88 +    if (sigsetjmp(CONTEXT(_thread), 1)) {  \
    1.89 +        _main();  \
    1.90 +    }  \
    1.91 +    _MD_GET_SP(_thread) = (unsigned char*) ((_sp) - 64); \
    1.92 +}
    1.93 +
    1.94 +#define _MD_SWITCH_CONTEXT(_thread)  \
    1.95 +    if (!sigsetjmp(CONTEXT(_thread), 1)) {  \
    1.96 +        (_thread)->md.errcode = errno;  \
    1.97 +        _PR_Schedule();  \
    1.98 +    }
    1.99 +
   1.100 +/*
   1.101 +** Restore a thread context, saved by _MD_SWITCH_CONTEXT
   1.102 +*/
   1.103 +#define _MD_RESTORE_CONTEXT(_thread) \
   1.104 +{   \
   1.105 +    errno = (_thread)->md.errcode;  \
   1.106 +    _MD_SET_CURRENT_THREAD(_thread);  \
   1.107 +    siglongjmp(CONTEXT(_thread), 1);  \
   1.108 +}
   1.109 +
   1.110 +/* Machine-dependent (MD) data structures */
   1.111 +
   1.112 +struct _MDThread {
   1.113 +    PR_CONTEXT_TYPE context;
   1.114 +    int id;
   1.115 +    int errcode;
   1.116 +};
   1.117 +
   1.118 +struct _MDThreadStack {
   1.119 +    PRInt8 notused;
   1.120 +};
   1.121 +
   1.122 +struct _MDLock {
   1.123 +    PRInt8 notused;
   1.124 +};
   1.125 +
   1.126 +struct _MDSemaphore {
   1.127 +    PRInt8 notused;
   1.128 +};
   1.129 +
   1.130 +struct _MDCVar {
   1.131 +    PRInt8 notused;
   1.132 +};
   1.133 +
   1.134 +struct _MDSegment {
   1.135 +    PRInt8 notused;
   1.136 +};
   1.137 +
   1.138 +/*
   1.139 + * md-specific cpu structure field
   1.140 + */
   1.141 +#define _PR_MD_MAX_OSFD FD_SETSIZE
   1.142 +
   1.143 +struct _MDCPU_Unix {
   1.144 +    PRCList ioQ;
   1.145 +    PRUint32 ioq_timeout;
   1.146 +    PRInt32 ioq_max_osfd;
   1.147 +    PRInt32 ioq_osfd_cnt;
   1.148 +#ifndef _PR_USE_POLL
   1.149 +    fd_set fd_read_set, fd_write_set, fd_exception_set;
   1.150 +    PRInt16 fd_read_cnt[_PR_MD_MAX_OSFD],fd_write_cnt[_PR_MD_MAX_OSFD],
   1.151 +				fd_exception_cnt[_PR_MD_MAX_OSFD];
   1.152 +#else
   1.153 +	struct pollfd *ioq_pollfds;
   1.154 +	int ioq_pollfds_size;
   1.155 +#endif	/* _PR_USE_POLL */
   1.156 +};
   1.157 +
   1.158 +#define _PR_IOQ(_cpu)			((_cpu)->md.md_unix.ioQ)
   1.159 +#define _PR_ADD_TO_IOQ(_pq, _cpu) PR_APPEND_LINK(&_pq.links, &_PR_IOQ(_cpu))
   1.160 +#define _PR_FD_READ_SET(_cpu)		((_cpu)->md.md_unix.fd_read_set)
   1.161 +#define _PR_FD_READ_CNT(_cpu)		((_cpu)->md.md_unix.fd_read_cnt)
   1.162 +#define _PR_FD_WRITE_SET(_cpu)		((_cpu)->md.md_unix.fd_write_set)
   1.163 +#define _PR_FD_WRITE_CNT(_cpu)		((_cpu)->md.md_unix.fd_write_cnt)
   1.164 +#define _PR_FD_EXCEPTION_SET(_cpu)	((_cpu)->md.md_unix.fd_exception_set)
   1.165 +#define _PR_FD_EXCEPTION_CNT(_cpu)	((_cpu)->md.md_unix.fd_exception_cnt)
   1.166 +#define _PR_IOQ_TIMEOUT(_cpu)		((_cpu)->md.md_unix.ioq_timeout)
   1.167 +#define _PR_IOQ_MAX_OSFD(_cpu)		((_cpu)->md.md_unix.ioq_max_osfd)
   1.168 +#define _PR_IOQ_OSFD_CNT(_cpu)		((_cpu)->md.md_unix.ioq_osfd_cnt)
   1.169 +#define _PR_IOQ_POLLFDS(_cpu)		((_cpu)->md.md_unix.ioq_pollfds)
   1.170 +#define _PR_IOQ_POLLFDS_SIZE(_cpu)	((_cpu)->md.md_unix.ioq_pollfds_size)
   1.171 +
   1.172 +#define _PR_IOQ_MIN_POLLFDS_SIZE(_cpu)	32
   1.173 +
   1.174 +struct _MDCPU {
   1.175 +    struct _MDCPU_Unix md_unix;
   1.176 +};
   1.177 +
   1.178 +#define _MD_INIT_LOCKS()
   1.179 +#define _MD_NEW_LOCK(lock) PR_SUCCESS
   1.180 +#define _MD_FREE_LOCK(lock)
   1.181 +#define _MD_LOCK(lock)
   1.182 +#define _MD_UNLOCK(lock)
   1.183 +#define _MD_INIT_IO()
   1.184 +#define _MD_IOQ_LOCK()
   1.185 +#define _MD_IOQ_UNLOCK()
   1.186 +
   1.187 +#define _MD_INIT_RUNNING_CPU(cpu)       _MD_unix_init_running_cpu(cpu)
   1.188 +#define _MD_INIT_THREAD                 _MD_InitializeThread
   1.189 +#define _MD_EXIT_THREAD(thread)
   1.190 +#define _MD_SUSPEND_THREAD(thread)      _MD_suspend_thread
   1.191 +#define _MD_RESUME_THREAD(thread)       _MD_resume_thread
   1.192 +#define _MD_CLEAN_THREAD(_thread)
   1.193 +
   1.194 +#endif /* ! _PR_PTHREADS */
   1.195 +
   1.196 +#define _MD_EARLY_INIT                  _MD_EarlyInit
   1.197 +#define _MD_FINAL_INIT			_PR_UnixInit
   1.198 +#define _MD_INTERVAL_USE_GTOD
   1.199 +
   1.200 +/*
   1.201 + * We wrapped the select() call.  _MD_SELECT refers to the built-in,
   1.202 + * unwrapped version.
   1.203 + */
   1.204 +#define _MD_SELECT(nfds,r,w,e,tv) syscall(SYS_select,nfds,r,w,e,tv)
   1.205 +#include <poll.h>
   1.206 +#define _MD_POLL(fds,nfds,timeout) syscall(SYS_poll,fds,nfds,timeout)
   1.207 +
   1.208 +#if OpenBSD1_3 == 1L
   1.209 +typedef unsigned int nfds_t;
   1.210 +#endif
   1.211 +
   1.212 +#endif /* nspr_openbsd_defs_h___ */

mercurial