1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 2 /* 3 * The contents of this file are subject to the Mozilla Public 4 * License Version 1.1 (the "License"); you may not use this file 5 * except in compliance with the License. You may obtain a copy of 6 * the License at http://www.mozilla.org/MPL/ 7 * 8 * Software distributed under the License is distributed on an "AS 9 * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or 10 * implied. See the License for the specific language governing 11 * rights and limitations under the License. 12 * 13 * The Original Code is the Netscape Portable Runtime (NSPR). 14 * 15 * The Initial Developer of the Original Code is Netscape 16 * Communications Corporation. Portions created by Netscape are 17 * Copyright (C) 1998-2000 Netscape Communications Corporation. All 18 * Rights Reserved. 19 * 20 * Contributor(s): 21 * 22 * Alternatively, the contents of this file may be used under the 23 * terms of the GNU General Public License Version 2 or later (the 24 * "GPL"), in which case the provisions of the GPL are applicable 25 * instead of those above. If you wish to allow use of your 26 * version of this file only under the terms of the GPL and not to 27 * allow others to use your version of this file under the MPL, 28 * indicate your decision by deleting the provisions above and 29 * replace them with the notice and other provisions required by 30 * the GPL. If you do not delete the provisions above, a recipient 31 * may use your version of this file under either the MPL or the 32 * GPL. 33 */ 34 35 #ifndef nspr_osf1_defs_h___ 36 #define nspr_osf1_defs_h___ 37 38 /* 39 * Internal configuration macros 40 */ 41 42 #define PR_LINKER_ARCH "osf" 43 #define _PR_SI_SYSNAME "OSF" 44 #define _PR_SI_ARCHITECTURE "alpha" 45 #define PR_DLL_SUFFIX ".so" 46 47 #define _PR_VMBASE 0x30000000 48 #define _PR_STACK_VMBASE 0x50000000 49 #define _MD_DEFAULT_STACK_SIZE 131072L 50 #define _MD_MMAP_FLAGS MAP_PRIVATE 51 52 #undef HAVE_STACK_GROWING_UP 53 #undef HAVE_WEAK_IO_SYMBOLS 54 #undef HAVE_WEAK_MALLOC_SYMBOLS 55 #define HAVE_DLL 56 #define HAVE_BSD_FLOCK 57 58 #define NEED_TIME_R 59 #define USE_DLFCN 60 61 #define _PR_POLL_AVAILABLE 62 #define _PR_USE_POLL 63 #define _PR_STAT_HAS_ONLY_ST_ATIME 64 #define _PR_HAVE_LARGE_OFF_T 65 #define _PR_HAVE_GETIPNODEBYNAME 66 #define _PR_HAVE_GETIPNODEBYADDR 67 #define _PR_HAVE_GETADDRINFO 68 #define _PR_INET6_PROBE 69 #ifdef _PR_INET6 70 #define _PR_HAVE_INET_NTOP 71 #else 72 #define AF_INET6 26 73 #ifndef AI_CANONNAME 74 #define AI_CANONNAME 0x00000002 75 struct addrinfo { 76 int ai_flags; 77 int ai_family; 78 int ai_socktype; 79 int ai_protocol; 80 size_t ai_addrlen; 81 char *ai_canonname; 82 struct sockaddr *ai_addr; 83 struct addrinfo *ai_next; 84 }; 85 #endif 86 #define AI_V4MAPPED 0x00000010 87 #define AI_ALL 0x00000008 88 #define AI_ADDRCONFIG 0x00000020 89 #endif 90 #define _PR_HAVE_POSIX_SEMAPHORES 91 #define PR_HAVE_POSIX_NAMED_SHARED_MEMORY 92 93 #define USE_SETJMP 94 95 #include <setjmp.h> 96 97 /* 98 * A jmp_buf is actually a struct sigcontext. The sc_sp field of 99 * struct sigcontext is the stack pointer. 100 */ 101 #define _MD_GET_SP(_t) (((struct sigcontext *) (_t)->md.context)->sc_sp) 102 #define PR_NUM_GCREGS _JBLEN 103 #define CONTEXT(_th) ((_th)->md.context) 104 105 /* 106 ** Initialize a thread context to run "_main()" when started 107 */ 108 #define _MD_INIT_CONTEXT(_thread, _sp, _main, status) \ 109 { \ 110 *status = PR_TRUE; \ 111 if (setjmp(CONTEXT(_thread))) { \ 112 (*_main)(); \ 113 } \ 114 _MD_GET_SP(_thread) = (long) ((_sp) - 64); \ 115 _MD_GET_SP(_thread) &= ~15; \ 116 } 117 118 #define _MD_SWITCH_CONTEXT(_thread) \ 119 if (!setjmp(CONTEXT(_thread))) { \ 120 (_thread)->md.errcode = errno; \ 121 _PR_Schedule(); \ 122 } 123 124 /* 125 ** Restore a thread context, saved by _MD_SWITCH_CONTEXT 126 */ 127 #define _MD_RESTORE_CONTEXT(_thread) \ 128 { \ 129 errno = (_thread)->md.errcode; \ 130 _MD_SET_CURRENT_THREAD(_thread); \ 131 longjmp(CONTEXT(_thread), 1); \ 132 } 133 134 /* Machine-dependent (MD) data structures */ 135 136 struct _MDThread { 137 jmp_buf context; 138 int id; 139 int errcode; 140 }; 141 142 struct _MDThreadStack { 143 PRInt8 notused; 144 }; 145 146 struct _MDLock { 147 PRInt8 notused; 148 }; 149 150 struct _MDSemaphore { 151 PRInt8 notused; 152 }; 153 154 struct _MDCVar { 155 PRInt8 notused; 156 }; 157 158 struct _MDSegment { 159 PRInt8 notused; 160 }; 161 162 /* 163 * md-specific cpu structure field 164 */ 165 #define _PR_MD_MAX_OSFD FD_SETSIZE 166 167 struct _MDCPU_Unix { 168 PRCList ioQ; 169 PRUint32 ioq_timeout; 170 PRInt32 ioq_max_osfd; 171 PRInt32 ioq_osfd_cnt; 172 #ifndef _PR_USE_POLL 173 fd_set fd_read_set, fd_write_set, fd_exception_set; 174 PRInt16 fd_read_cnt[_PR_MD_MAX_OSFD],fd_write_cnt[_PR_MD_MAX_OSFD], 175 fd_exception_cnt[_PR_MD_MAX_OSFD]; 176 #else 177 struct pollfd *ioq_pollfds; 178 int ioq_pollfds_size; 179 #endif /* _PR_USE_POLL */ 180 }; 181 182 #define _PR_IOQ(_cpu) ((_cpu)->md.md_unix.ioQ) 183 #define _PR_ADD_TO_IOQ(_pq, _cpu) PR_APPEND_LINK(&_pq.links, &_PR_IOQ(_cpu)) 184 #define _PR_FD_READ_SET(_cpu) ((_cpu)->md.md_unix.fd_read_set) 185 #define _PR_FD_READ_CNT(_cpu) ((_cpu)->md.md_unix.fd_read_cnt) 186 #define _PR_FD_WRITE_SET(_cpu) ((_cpu)->md.md_unix.fd_write_set) 187 #define _PR_FD_WRITE_CNT(_cpu) ((_cpu)->md.md_unix.fd_write_cnt) 188 #define _PR_FD_EXCEPTION_SET(_cpu) ((_cpu)->md.md_unix.fd_exception_set) 189 #define _PR_FD_EXCEPTION_CNT(_cpu) ((_cpu)->md.md_unix.fd_exception_cnt) 190 #define _PR_IOQ_TIMEOUT(_cpu) ((_cpu)->md.md_unix.ioq_timeout) 191 #define _PR_IOQ_MAX_OSFD(_cpu) ((_cpu)->md.md_unix.ioq_max_osfd) 192 #define _PR_IOQ_OSFD_CNT(_cpu) ((_cpu)->md.md_unix.ioq_osfd_cnt) 193 #define _PR_IOQ_POLLFDS(_cpu) ((_cpu)->md.md_unix.ioq_pollfds) 194 #define _PR_IOQ_POLLFDS_SIZE(_cpu) ((_cpu)->md.md_unix.ioq_pollfds_size) 195 196 #define _PR_IOQ_MIN_POLLFDS_SIZE(_cpu) 32 197 198 struct _MDCPU { 199 struct _MDCPU_Unix md_unix; 200 }; 201 202 #ifndef _PR_PTHREADS 203 #define _MD_INIT_LOCKS() 204 #endif 205 #define _MD_NEW_LOCK(lock) PR_SUCCESS 206 #define _MD_FREE_LOCK(lock) 207 #define _MD_LOCK(lock) 208 #define _MD_UNLOCK(lock) 209 #define _MD_INIT_IO() 210 #define _MD_IOQ_LOCK() 211 #define _MD_IOQ_UNLOCK() 212 213 /* 214 * The following are copied from _sunos.h, _aix.h. This means 215 * some of them should probably be moved into _unixos.h. But 216 * _irix.h seems to be quite different in regard to these macros. 217 */ 218 #define _MD_GET_INTERVAL _PR_UNIX_GetInterval 219 #define _MD_INTERVAL_PER_SEC _PR_UNIX_TicksPerSecond 220 221 #define _MD_EARLY_INIT _MD_EarlyInit 222 #define _MD_FINAL_INIT _PR_UnixInit 223 #define _MD_INIT_RUNNING_CPU(cpu) _MD_unix_init_running_cpu(cpu) 224 #define _MD_INIT_THREAD _MD_InitializeThread 225 #define _MD_EXIT_THREAD(thread) 226 #define _MD_SUSPEND_THREAD(thread) 227 #define _MD_RESUME_THREAD(thread) 228 #define _MD_CLEAN_THREAD(_thread) 229 230 /* The following defines unwrapped versions of select() and poll(). */ 231 #include <sys/time.h> 232 extern int __select (int, fd_set *, fd_set *, fd_set *, struct timeval *); 233 #define _MD_SELECT __select 234 235 #include <sys/poll.h> 236 #define _MD_POLL __poll 237 extern int __poll(struct pollfd filedes[], unsigned int nfds, int timeout); 238 239 /* 240 * Atomic operations 241 */ 242 #ifdef OSF1_HAVE_MACHINE_BUILTINS_H 243 #include <machine/builtins.h> 244 #define _PR_HAVE_ATOMIC_OPS 245 #define _MD_INIT_ATOMIC() 246 #define _MD_ATOMIC_INCREMENT(val) (__ATOMIC_INCREMENT_LONG(val) + 1) 247 #define _MD_ATOMIC_ADD(ptr, val) (__ATOMIC_ADD_LONG(ptr, val) + val) 248 #define _MD_ATOMIC_DECREMENT(val) (__ATOMIC_DECREMENT_LONG(val) - 1) 249 #define _MD_ATOMIC_SET(val, newval) __ATOMIC_EXCH_LONG(val, newval) 250 #endif /* OSF1_HAVE_MACHINE_BUILTINS_H */ 251 252 #endif /* nspr_osf1_defs_h___ */ 253