nsprpub/pr/include/md/_nto.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/nsprpub/pr/include/md/_nto.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,188 @@
     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_nto_defs_h___
    1.10 +#define nspr_nto_defs_h___
    1.11 +
    1.12 +/*
    1.13 +** Internal configuration macros
    1.14 +*/
    1.15 +#define PR_LINKER_ARCH		"nto"
    1.16 +#define _PR_SI_SYSNAME		"NTO"
    1.17 +#define _PR_SI_ARCHITECTURE	"x86"
    1.18 +#define PR_DLL_SUFFIX		".so"
    1.19 +
    1.20 +#define _PR_VMBASE		0x30000000
    1.21 +#define _PR_STACK_VMBASE	0x50000000
    1.22 +#define _MD_DEFAULT_STACK_SIZE	65536L
    1.23 +#define _MD_MINIMUM_STACK_SIZE	131072L
    1.24 +#define _MD_MMAP_FLAGS		MAP_PRIVATE
    1.25 +
    1.26 +#ifndef	HAVE_WEAK_IO_SYMBOLS
    1.27 +#define	HAVE_WEAK_IO_SYMBOLS
    1.28 +#endif
    1.29 +
    1.30 +#undef  _PR_POLL_AVAILABLE
    1.31 +#undef  _PR_USE_POLL
    1.32 +#define _PR_HAVE_SOCKADDR_LEN
    1.33 +#undef  HAVE_BSD_FLOCK
    1.34 +#define HAVE_FCNTL_FILE_LOCKING
    1.35 +#define _PR_NO_LARGE_FILES
    1.36 +#define _PR_STAT_HAS_ONLY_ST_ATIME
    1.37 +#define PR_HAVE_POSIX_NAMED_SHARED_MEMORY
    1.38 +#define _PR_HAVE_POSIX_SEMAPHORES
    1.39 +
    1.40 +#undef FD_SETSIZE
    1.41 +#define FD_SETSIZE	4096
    1.42 +#include <sys/time.h>
    1.43 +#include <sys/types.h>
    1.44 +#include <sys/select.h>
    1.45 +
    1.46 +#undef  HAVE_STACK_GROWING_UP
    1.47 +#define	HAVE_DLL
    1.48 +#define	USE_DLFCN
    1.49 +#define NEED_STRFTIME_LOCK
    1.50 +#define NEED_TIME_R
    1.51 +#define _PR_NEED_STRCASECMP
    1.52 +
    1.53 +#ifndef HAVE_STRERROR
    1.54 +#define HAVE_STRERROR
    1.55 +#endif
    1.56 +
    1.57 +#define USE_SETJMP
    1.58 +
    1.59 +#include <setjmp.h>
    1.60 +
    1.61 +#define _SETJMP			setjmp
    1.62 +#define _LONGJMP		longjmp
    1.63 +#define _PR_CONTEXT_TYPE	jmp_buf
    1.64 +#define _PR_NUM_GCREGS		_JBLEN
    1.65 +#define _MD_GET_SP(_t)		(_t)->md.context[7]
    1.66 +
    1.67 +#define CONTEXT(_th)		((_th)->md.context)
    1.68 +
    1.69 +
    1.70 +/*
    1.71 +** Initialize the thread context preparing it to execute _main.
    1.72 +*/
    1.73 +#define _MD_INIT_CONTEXT(_thread, _sp, _main, status)	\
    1.74 +{							\
    1.75 +    *status = PR_TRUE;					\
    1.76 +    if(_SETJMP(CONTEXT(_thread))) (*_main)();		\
    1.77 +    _MD_GET_SP(_thread) = (int) ((_sp) - 128);		\
    1.78 +}
    1.79 +
    1.80 +#define _MD_SWITCH_CONTEXT(_thread)	\
    1.81 +    if (!_SETJMP(CONTEXT(_thread))) {	\
    1.82 +	(_thread)->md.errcode = errno;	\
    1.83 +	_PR_Schedule();			\
    1.84 +    }
    1.85 +
    1.86 +/*
    1.87 +** Restore a thread context, saved by _MD_SWITCH_CONTEXT
    1.88 +*/
    1.89 +#define _MD_RESTORE_CONTEXT(_thread)	\
    1.90 +{					\
    1.91 +    errno = (_thread)->md.errcode;	\
    1.92 +    _MD_SET_CURRENT_THREAD(_thread);	\
    1.93 +    _LONGJMP(CONTEXT(_thread), 1);	\
    1.94 +}
    1.95 +
    1.96 +/*
    1.97 +** Machine-dependent (MD) data structures.
    1.98 +*/
    1.99 +struct _MDThread {
   1.100 +    _PR_CONTEXT_TYPE context;
   1.101 +    int id;
   1.102 +    int errcode;
   1.103 +};
   1.104 +
   1.105 +struct _MDThreadStack {
   1.106 +    PRInt8 notused;
   1.107 +};
   1.108 +
   1.109 +struct _MDLock {
   1.110 +    PRInt8 notused;
   1.111 +};
   1.112 +
   1.113 +struct _MDSemaphore {
   1.114 +    PRInt8 notused;
   1.115 +};
   1.116 +
   1.117 +struct _MDCVar {
   1.118 +    PRInt8 notused;
   1.119 +};
   1.120 +
   1.121 +struct _MDSegment {
   1.122 +    PRInt8 notused;
   1.123 +};
   1.124 +
   1.125 +/*
   1.126 +** md-specific cpu structure field
   1.127 +*/
   1.128 +#define _PR_MD_MAX_OSFD		FD_SETSIZE
   1.129 +
   1.130 +struct _MDCPU_Unix {
   1.131 +    PRCList ioQ;
   1.132 +    PRUint32 ioq_timeout;
   1.133 +    PRInt32 ioq_max_osfd;
   1.134 +    PRInt32 ioq_osfd_cnt;
   1.135 +#ifndef _PR_USE_POLL
   1.136 +    fd_set fd_read_set, fd_write_set, fd_exception_set;
   1.137 +    PRInt16 fd_read_cnt[_PR_MD_MAX_OSFD], fd_write_cnt[_PR_MD_MAX_OSFD], fd_exception_cnt[_PR_MD_MAX_OSFD];
   1.138 +#else
   1.139 +    struct pollfd *ioq_pollfds;
   1.140 +    int ioq_pollfds_size;
   1.141 +#endif
   1.142 +};
   1.143 +
   1.144 +#define _PR_IOQ(_cpu)			((_cpu)->md.md_unix.ioQ)
   1.145 +#define _PR_ADD_TO_IOQ(_pq, _cpu)	PR_APPEND_LINK(&_pq.links, &_PR_IOQ(_cpu))
   1.146 +#define _PR_FD_READ_SET(_cpu)		((_cpu)->md.md_unix.fd_read_set)
   1.147 +#define _PR_FD_READ_CNT(_cpu)		((_cpu)->md.md_unix.fd_read_cnt)
   1.148 +#define _PR_FD_WRITE_SET(_cpu)		((_cpu)->md.md_unix.fd_write_set)
   1.149 +#define _PR_FD_WRITE_CNT(_cpu)		((_cpu)->md.md_unix.fd_write_cnt)
   1.150 +#define _PR_FD_EXCEPTION_SET(_cpu)	((_cpu)->md.md_unix.fd_exception_set)
   1.151 +#define _PR_FD_EXCEPTION_CNT(_cpu)	((_cpu)->md.md_unix.fd_exception_cnt)
   1.152 +#define _PR_IOQ_TIMEOUT(_cpu)		((_cpu)->md.md_unix.ioq_timeout)
   1.153 +#define _PR_IOQ_MAX_OSFD(_cpu)		((_cpu)->md.md_unix.ioq_max_osfd)
   1.154 +#define _PR_IOQ_OSFD_CNT(_cpu)		((_cpu)->md.md_unix.ioq_osfd_cnt)
   1.155 +#define _PR_IOQ_POLLFDS(_cpu)		((_cpu)->md.md_unix.ioq_pollfds)
   1.156 +#define _PR_IOQ_POLLFDS_SIZE(_cpu)	((_cpu)->md.md_unix.ioq_pollfds_size)
   1.157 +
   1.158 +#define _PR_IOQ_MIN_POLLFDS_SIZE(_cpu)	32
   1.159 +
   1.160 +struct _MDCPU {
   1.161 +	struct _MDCPU_Unix md_unix;
   1.162 +};
   1.163 +
   1.164 +#define _MD_INIT_LOCKS()
   1.165 +#define _MD_NEW_LOCK(lock)		PR_SUCCESS
   1.166 +#define _MD_FREE_LOCK(lock)
   1.167 +#define _MD_LOCK(lock)
   1.168 +#define _MD_UNLOCK(lock)
   1.169 +#define _MD_INIT_IO()
   1.170 +#define _MD_IOQ_LOCK()
   1.171 +#define _MD_IOQ_UNLOCK()
   1.172 +
   1.173 +#define _MD_INTERVAL_USE_GTOD
   1.174 +#define _MD_EARLY_INIT			_MD_EarlyInit
   1.175 +#define _MD_FINAL_INIT			_PR_UnixInit
   1.176 +#define _MD_INIT_RUNNING_CPU(cpu)	_MD_unix_init_running_cpu(cpu)
   1.177 +#define _MD_INIT_THREAD			_MD_InitializeThread
   1.178 +#define _MD_EXIT_THREAD(thread)
   1.179 +#define	_MD_SUSPEND_THREAD(thread)
   1.180 +#define	_MD_RESUME_THREAD(thread)
   1.181 +#define _MD_CLEAN_THREAD(_thread)
   1.182 +
   1.183 +/*
   1.184 +** We wrapped the select() call.  _MD_SELECT refers to the built-in,
   1.185 +** unwrapped version.
   1.186 +*/
   1.187 +#define _MD_SELECT		select
   1.188 +
   1.189 +#define SA_RESTART 0
   1.190 +
   1.191 +#endif /* nspr_nto_defs_h___ */

mercurial