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/. */ 5 6 #ifndef nspr_dgux_defs_h___ 7 #define nspr_dgux_defs_h___ 8 9 /* 10 * Internal configuration macros 11 */ 12 13 #define PR_LINKER_ARCH "dgux" 14 #define _PR_SI_SYSNAME "DGUX" 15 #define _PR_SI_ARCHITECTURE "x86" 16 #define PR_DLL_SUFFIX ".so" 17 18 #define _PR_VMBASE 0x30000000 19 #define _PR_STACK_VMBASE 0x50000000 20 #define _MD_DEFAULT_STACK_SIZE 65536L 21 #define _MD_MMAP_FLAGS MAP_PRIVATE 22 23 #ifndef HAVE_WEAK_IO_SYMBOLS 24 #define HAVE_WEAK_IO_SYMBOLS 25 #endif 26 27 #undef HAVE_STACK_GROWING_UP 28 #define HAVE_NETCONFIG 29 #define HAVE_DLL 30 #define USE_DLFCN 31 #define NEED_STRFTIME_LOCK 32 #define NEED_TIME_R 33 #define _PR_NEED_STRCASECMP 34 #define _PR_POLL_AVAILABLE 35 #define _PR_USE_POLL 36 #define _PR_NO_LARGE_FILES 37 #define _PR_STAT_HAS_ONLY_ST_ATIME 38 39 #define USE_SETJMP 40 41 #include <setjmp.h> 42 43 #define _SETJMP setjmp 44 #define _LONGJMP longjmp 45 #define _PR_CONTEXT_TYPE jmp_buf 46 #define _MD_GET_SP(_t) (_t)->md.context[4] 47 #define _PR_NUM_GCREGS _JBLEN 48 49 #define CONTEXT(_th) ((_th)->md.context) 50 51 /* 52 ** Initialize the thread context preparing it to execute _main. 53 */ 54 #define _MD_INIT_CONTEXT(_thread, _sp, _main, status) \ 55 { \ 56 *status = PR_TRUE; \ 57 if(_SETJMP(CONTEXT(_thread))) (*_main)(); \ 58 _MD_GET_SP(_thread) = (int) ((_sp) - 128); \ 59 } 60 61 #define _MD_SWITCH_CONTEXT(_thread) \ 62 if (!_SETJMP(CONTEXT(_thread))) { \ 63 (_thread)->md.errcode = errno; \ 64 _PR_Schedule(); \ 65 } 66 67 /* 68 ** Restore a thread context, saved by _MD_SWITCH_CONTEXT 69 */ 70 #define _MD_RESTORE_CONTEXT(_thread) \ 71 { \ 72 errno = (_thread)->md.errcode; \ 73 _MD_SET_CURRENT_THREAD(_thread); \ 74 _LONGJMP(CONTEXT(_thread), 1); \ 75 } 76 77 /* Machine-dependent (MD) data structures. 78 * Don't use SVR4 native threads (yet). 79 */ 80 81 struct _MDThread { 82 _PR_CONTEXT_TYPE context; 83 int id; 84 int errcode; 85 }; 86 87 struct _MDThreadStack { 88 PRInt8 notused; 89 }; 90 91 struct _MDLock { 92 PRInt8 notused; 93 }; 94 95 struct _MDSemaphore { 96 PRInt8 notused; 97 }; 98 99 struct _MDCVar { 100 PRInt8 notused; 101 }; 102 103 struct _MDSegment { 104 PRInt8 notused; 105 }; 106 107 /* 108 * md-specific cpu structure field 109 */ 110 #define _PR_MD_MAX_OSFD FD_SETSIZE 111 112 struct _MDCPU_Unix { 113 PRCList ioQ; 114 PRUint32 ioq_timeout; 115 PRInt32 ioq_max_osfd; 116 PRInt32 ioq_osfd_cnt; 117 #ifndef _PR_USE_POLL 118 fd_set fd_read_set, fd_write_set, fd_exception_set; 119 PRInt16 fd_read_cnt[_PR_MD_MAX_OSFD],fd_write_cnt[_PR_MD_MAX_OSFD], 120 fd_exception_cnt[_PR_MD_MAX_OSFD]; 121 #else 122 struct pollfd *ioq_pollfds; 123 int ioq_pollfds_size; 124 #endif /* _PR_USE_POLL */ 125 }; 126 127 #define _PR_IOQ(_cpu) ((_cpu)->md.md_unix.ioQ) 128 #define _PR_ADD_TO_IOQ(_pq, _cpu) PR_APPEND_LINK(&_pq.links, &_PR_IOQ(_cpu)) 129 #define _PR_FD_READ_SET(_cpu) ((_cpu)->md.md_unix.fd_read_set) 130 #define _PR_FD_READ_CNT(_cpu) ((_cpu)->md.md_unix.fd_read_cnt) 131 #define _PR_FD_WRITE_SET(_cpu) ((_cpu)->md.md_unix.fd_write_set) 132 #define _PR_FD_WRITE_CNT(_cpu) ((_cpu)->md.md_unix.fd_write_cnt) 133 #define _PR_FD_EXCEPTION_SET(_cpu) ((_cpu)->md.md_unix.fd_exception_set) 134 #define _PR_FD_EXCEPTION_CNT(_cpu) ((_cpu)->md.md_unix.fd_exception_cnt) 135 #define _PR_IOQ_TIMEOUT(_cpu) ((_cpu)->md.md_unix.ioq_timeout) 136 #define _PR_IOQ_MAX_OSFD(_cpu) ((_cpu)->md.md_unix.ioq_max_osfd) 137 #define _PR_IOQ_OSFD_CNT(_cpu) ((_cpu)->md.md_unix.ioq_osfd_cnt) 138 #define _PR_IOQ_POLLFDS(_cpu) ((_cpu)->md.md_unix.ioq_pollfds) 139 #define _PR_IOQ_POLLFDS_SIZE(_cpu) ((_cpu)->md.md_unix.ioq_pollfds_size) 140 141 #define _PR_IOQ_MIN_POLLFDS_SIZE(_cpu) 32 142 143 struct _MDCPU { 144 struct _MDCPU_Unix md_unix; 145 }; 146 147 #define _MD_INIT_LOCKS() 148 #define _MD_NEW_LOCK(lock) PR_SUCCESS 149 #define _MD_FREE_LOCK(lock) 150 #define _MD_LOCK(lock) 151 #define _MD_UNLOCK(lock) 152 #define _MD_INIT_IO() 153 #define _MD_IOQ_LOCK() 154 #define _MD_IOQ_UNLOCK() 155 156 /* 157 * The following are copied from _sunos.h, _aix.h. This means 158 * some of them should probably be moved into _unixos.h. But 159 * _irix.h seems to be quite different in regard to these macros. 160 */ 161 #define _MD_INTERVAL_USE_GTOD 162 163 #define _MD_EARLY_INIT _MD_EarlyInit 164 #define _MD_FINAL_INIT _PR_UnixInit 165 #define _MD_INIT_RUNNING_CPU(cpu) _MD_unix_init_running_cpu(cpu) 166 #define _MD_INIT_THREAD _MD_InitializeThread 167 #define _MD_EXIT_THREAD(thread) 168 #define _MD_SUSPEND_THREAD(thread) 169 #define _MD_RESUME_THREAD(thread) 170 #define _MD_CLEAN_THREAD(_thread) 171 172 /* 173 * We wrapped the select() call. _MD_SELECT refers to the built-in, 174 * unwrapped version. 175 */ 176 #include <unistd.h> 177 #include <sys/types.h> 178 #include <sys/time.h> 179 extern int _select(int nfds, fd_set *readfds, fd_set *writefds, 180 fd_set *execptfds, struct timeval *timeout); 181 #define _MD_SELECT _select 182 183 #define _MD_POLL _poll 184 #include <poll.h> 185 #include <stropts.h> 186 extern int _poll(struct pollfd *fds, unsigned long nfds, int timeout); 187 188 #endif /* nspr_dgux_defs_h___ */ 189