nsprpub/pr/include/md/_osf1.h

Fri, 16 Jan 2015 04:50:19 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Fri, 16 Jan 2015 04:50:19 +0100
branch
TOR_BUG_9701
changeset 13
44a2da4a2ab2
permissions
-rw-r--r--

Replace accessor implementation with direct member state manipulation, by
request https://trac.torproject.org/projects/tor/ticket/9701#comment:32

     1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     2 /* This Source Code Form is subject to the terms of the Mozilla Public
     3  * License, v. 2.0. If a copy of the MPL was not distributed with this
     4  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     6 #ifndef nspr_osf1_defs_h___
     7 #define nspr_osf1_defs_h___
     9 /*
    10  * Internal configuration macros
    11  */
    13 #define PR_LINKER_ARCH	"osf"
    14 #define _PR_SI_SYSNAME	"OSF"
    15 #define _PR_SI_ARCHITECTURE "alpha"
    16 #define PR_DLL_SUFFIX		".so"
    18 #define _PR_VMBASE              0x30000000
    19 #define _PR_STACK_VMBASE        0x50000000
    20 #define _MD_DEFAULT_STACK_SIZE  131072L
    21 #define _MD_MMAP_FLAGS          MAP_PRIVATE
    23 #undef  HAVE_STACK_GROWING_UP
    24 #undef 	HAVE_WEAK_IO_SYMBOLS
    25 #undef 	HAVE_WEAK_MALLOC_SYMBOLS
    26 #define HAVE_DLL
    27 #define HAVE_BSD_FLOCK
    29 #define NEED_TIME_R
    30 #define USE_DLFCN
    32 #define _PR_POLL_AVAILABLE
    33 #define _PR_USE_POLL
    34 #define _PR_STAT_HAS_ONLY_ST_ATIME
    35 #define _PR_HAVE_LARGE_OFF_T
    36 #define _PR_HAVE_GETIPNODEBYNAME
    37 #define _PR_HAVE_GETIPNODEBYADDR
    38 #define _PR_HAVE_GETADDRINFO
    39 #define _PR_INET6_PROBE
    40 #ifdef _PR_INET6
    41 #define _PR_HAVE_INET_NTOP
    42 #else
    43 #define AF_INET6 26
    44 #ifndef AI_CANONNAME
    45 #define AI_CANONNAME 0x00000002
    46 struct addrinfo {
    47     int              ai_flags;
    48     int              ai_family;
    49     int              ai_socktype;
    50     int              ai_protocol;
    51     size_t           ai_addrlen;
    52     char            *ai_canonname;
    53     struct sockaddr *ai_addr;
    54     struct addrinfo *ai_next;
    55 };
    56 #endif
    57 #define AI_V4MAPPED 0x00000010
    58 #define AI_ALL      0x00000008
    59 #define AI_ADDRCONFIG 0x00000020
    60 #endif
    61 #define _PR_HAVE_POSIX_SEMAPHORES
    62 #define PR_HAVE_POSIX_NAMED_SHARED_MEMORY
    64 #define USE_SETJMP
    66 #include <setjmp.h>
    68 /*
    69  * A jmp_buf is actually a struct sigcontext.  The sc_sp field of
    70  * struct sigcontext is the stack pointer.
    71  */
    72 #define _MD_GET_SP(_t) (((struct sigcontext *) (_t)->md.context)->sc_sp)
    73 #define PR_NUM_GCREGS _JBLEN
    74 #define CONTEXT(_th) ((_th)->md.context)
    76 /*
    77 ** Initialize a thread context to run "_main()" when started
    78 */
    79 #define _MD_INIT_CONTEXT(_thread, _sp, _main, status)	      \
    80 {									  \
    81         *status = PR_TRUE;              \
    82     if (setjmp(CONTEXT(_thread))) {				\
    83 	(*_main)();						\
    84     }								\
    85     _MD_GET_SP(_thread) = (long) ((_sp) - 64);			\
    86     _MD_GET_SP(_thread) &= ~15;					\
    87 }
    89 #define _MD_SWITCH_CONTEXT(_thread)  \
    90     if (!setjmp(CONTEXT(_thread))) { \
    91 	(_thread)->md.errcode = errno;  \
    92 	_PR_Schedule();		     \
    93     }
    95 /*
    96 ** Restore a thread context, saved by _MD_SWITCH_CONTEXT
    97 */
    98 #define _MD_RESTORE_CONTEXT(_thread) \
    99 {				     \
   100     errno = (_thread)->md.errcode;     \
   101     _MD_SET_CURRENT_THREAD(_thread);	\
   102     longjmp(CONTEXT(_thread), 1);    \
   103 }
   105 /* Machine-dependent (MD) data structures */
   107 struct _MDThread {
   108     jmp_buf context;
   109     int id;
   110     int errcode;
   111 };
   113 struct _MDThreadStack {
   114     PRInt8 notused;
   115 };
   117 struct _MDLock {
   118     PRInt8 notused;
   119 };
   121 struct _MDSemaphore {
   122     PRInt8 notused;
   123 };
   125 struct _MDCVar {
   126     PRInt8 notused;
   127 };
   129 struct _MDSegment {
   130     PRInt8 notused;
   131 };
   133 /*
   134  * md-specific cpu structure field
   135  */
   136 #define _PR_MD_MAX_OSFD FD_SETSIZE
   138 struct _MDCPU_Unix {
   139     PRCList ioQ;
   140     PRUint32 ioq_timeout;
   141     PRInt32 ioq_max_osfd;
   142     PRInt32 ioq_osfd_cnt;
   143 #ifndef _PR_USE_POLL
   144     fd_set fd_read_set, fd_write_set, fd_exception_set;
   145     PRInt16 fd_read_cnt[_PR_MD_MAX_OSFD],fd_write_cnt[_PR_MD_MAX_OSFD],
   146 				fd_exception_cnt[_PR_MD_MAX_OSFD];
   147 #else
   148 	struct pollfd *ioq_pollfds;
   149 	int ioq_pollfds_size;
   150 #endif	/* _PR_USE_POLL */
   151 };
   153 #define _PR_IOQ(_cpu)			((_cpu)->md.md_unix.ioQ)
   154 #define _PR_ADD_TO_IOQ(_pq, _cpu) PR_APPEND_LINK(&_pq.links, &_PR_IOQ(_cpu))
   155 #define _PR_FD_READ_SET(_cpu)		((_cpu)->md.md_unix.fd_read_set)
   156 #define _PR_FD_READ_CNT(_cpu)		((_cpu)->md.md_unix.fd_read_cnt)
   157 #define _PR_FD_WRITE_SET(_cpu)		((_cpu)->md.md_unix.fd_write_set)
   158 #define _PR_FD_WRITE_CNT(_cpu)		((_cpu)->md.md_unix.fd_write_cnt)
   159 #define _PR_FD_EXCEPTION_SET(_cpu)	((_cpu)->md.md_unix.fd_exception_set)
   160 #define _PR_FD_EXCEPTION_CNT(_cpu)	((_cpu)->md.md_unix.fd_exception_cnt)
   161 #define _PR_IOQ_TIMEOUT(_cpu)		((_cpu)->md.md_unix.ioq_timeout)
   162 #define _PR_IOQ_MAX_OSFD(_cpu)		((_cpu)->md.md_unix.ioq_max_osfd)
   163 #define _PR_IOQ_OSFD_CNT(_cpu)		((_cpu)->md.md_unix.ioq_osfd_cnt)
   164 #define _PR_IOQ_POLLFDS(_cpu)		((_cpu)->md.md_unix.ioq_pollfds)
   165 #define _PR_IOQ_POLLFDS_SIZE(_cpu)	((_cpu)->md.md_unix.ioq_pollfds_size)
   167 #define _PR_IOQ_MIN_POLLFDS_SIZE(_cpu)	32
   169 struct _MDCPU {
   170 	struct _MDCPU_Unix md_unix;
   171 };
   173 #ifndef _PR_PTHREADS
   174 #define _MD_INIT_LOCKS()
   175 #endif
   176 #define _MD_NEW_LOCK(lock) PR_SUCCESS
   177 #define _MD_FREE_LOCK(lock)
   178 #define _MD_LOCK(lock)
   179 #define _MD_UNLOCK(lock)
   180 #define _MD_INIT_IO()
   181 #define _MD_IOQ_LOCK()
   182 #define _MD_IOQ_UNLOCK()
   184 /*
   185  * The following are copied from _sunos.h, _aix.h.  This means
   186  * some of them should probably be moved into _unixos.h.  But
   187  * _irix.h seems to be quite different in regard to these macros.
   188  */
   189 #define _MD_INTERVAL_USE_GTOD
   191 #define _MD_EARLY_INIT		_MD_EarlyInit
   192 #define _MD_FINAL_INIT		_PR_UnixInit
   193 #define _MD_INIT_RUNNING_CPU(cpu) _MD_unix_init_running_cpu(cpu)
   194 #define _MD_INIT_THREAD         _MD_InitializeThread
   195 #define _MD_EXIT_THREAD(thread)
   196 #define	_MD_SUSPEND_THREAD(thread)
   197 #define	_MD_RESUME_THREAD(thread)
   198 #define _MD_CLEAN_THREAD(_thread)
   200 /* The following defines unwrapped versions of select() and poll(). */
   201 #include <sys/time.h>
   202 extern int __select (int, fd_set *, fd_set *, fd_set *, struct timeval *);
   203 #define _MD_SELECT              __select
   205 #include <sys/poll.h>
   206 #define _MD_POLL __poll
   207 extern int __poll(struct pollfd filedes[], unsigned int nfds, int timeout);
   209 /*
   210  * Atomic operations
   211  */
   212 #ifdef OSF1_HAVE_MACHINE_BUILTINS_H
   213 #include <machine/builtins.h>
   214 #define _PR_HAVE_ATOMIC_OPS
   215 #define _MD_INIT_ATOMIC()
   216 #define _MD_ATOMIC_INCREMENT(val) (__ATOMIC_INCREMENT_LONG(val) + 1)
   217 #define _MD_ATOMIC_ADD(ptr, val)  (__ATOMIC_ADD_LONG(ptr, val) + val)
   218 #define _MD_ATOMIC_DECREMENT(val) (__ATOMIC_DECREMENT_LONG(val) - 1)
   219 #define _MD_ATOMIC_SET(val, newval) __ATOMIC_EXCH_LONG(val, newval)
   220 #endif /* OSF1_HAVE_MACHINE_BUILTINS_H */
   222 #endif /* nspr_osf1_defs_h___ */

mercurial