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_scoos5_defs_h___ 7 #define nspr_scoos5_defs_h___ 8 9 /* 10 * Internal configuration macros 11 */ 12 13 #define PR_LINKER_ARCH "scoos5" 14 #define PR_DLL_SUFFIX ".so" 15 16 #define _PR_SI_SYSNAME "SCO" 17 #define _PR_SI_ARCHITECTURE "x86" 18 #define _PR_STACK_VMBASE 0x50000000 19 20 #define _MD_DEFAULT_STACK_SIZE 65536L 21 #define _MD_MMAP_FLAGS MAP_PRIVATE 22 23 #undef HAVE_STACK_GROWING_UP 24 #define HAVE_DLL 25 #define USE_DLFCN 26 27 #if !defined (HAVE_STRERROR) 28 #define HAVE_STRERROR 29 #endif 30 31 #ifndef HAVE_WEAK_IO_SYMBOLS 32 #define HAVE_WEAK_IO_SYMBOLS 33 #endif 34 35 #define _PR_POLL_AVAILABLE 36 #define _PR_USE_POLL 37 #define _PR_NO_LARGE_FILES 38 #define _PR_STAT_HAS_ONLY_ST_ATIME 39 40 #define NEED_STRFTIME_LOCK 41 #define NEED_TIME_R 42 #define _PR_RECV_BROKEN /* recv doesn't work on Unix Domain Sockets */ 43 44 #define USE_SETJMP 45 46 #ifdef _PR_LOCAL_THREADS_ONLY 47 #include <setjmp.h> 48 49 #define _MD_GET_SP(_t) (_t)->md.jb[4] 50 #define PR_NUM_GCREGS _SIGJBLEN 51 #define PR_CONTEXT_TYPE sigjmp_buf 52 53 #define CONTEXT(_th) ((_th)->md.jb) 54 55 #define _MD_INIT_CONTEXT(_thread, _sp, _main, status) \ 56 { \ 57 *status = PR_TRUE; \ 58 if (sigsetjmp(CONTEXT(_thread),1)) { \ 59 (*_main)(); \ 60 } \ 61 _MD_GET_SP(_thread) = (int) ((_sp) - 64); \ 62 } 63 64 #define _MD_SWITCH_CONTEXT(_thread) \ 65 if (!sigsetjmp(CONTEXT(_thread), 1)) { \ 66 (_thread)->md.errcode = errno; \ 67 _PR_Schedule(); \ 68 } 69 70 /* 71 ** Restore a thread context, saved by _MD_SWITCH_CONTEXT 72 */ 73 #define _MD_RESTORE_CONTEXT(_thread) \ 74 { \ 75 errno = (_thread)->osErrorCode; \ 76 _MD_SET_CURRENT_THREAD(_thread); \ 77 siglongjmp(CONTEXT(_thread), 1); \ 78 } 79 80 #endif /* _PR_LOCAL_THREADS_ONLY */ 81 82 struct _MDThread { 83 jmp_buf jb; 84 int id; 85 int errcode; 86 }; 87 88 struct _MDThreadStack { 89 PRInt8 notused; 90 }; 91 92 struct _MDLock { 93 PRInt8 notused; 94 }; 95 96 struct _MDSemaphore { 97 PRInt8 notused; 98 }; 99 100 struct _MDCVar { 101 PRInt8 notused; 102 }; 103 104 struct _MDSegment { 105 PRInt8 notused; 106 }; 107 108 /* 109 * md-specific cpu structure field 110 */ 111 #define _PR_MD_MAX_OSFD FD_SETSIZE 112 113 struct _MDCPU_Unix { 114 PRCList ioQ; 115 PRUint32 ioq_timeout; 116 PRInt32 ioq_max_osfd; 117 PRInt32 ioq_osfd_cnt; 118 #ifndef _PR_USE_POLL 119 fd_set fd_read_set, fd_write_set, fd_exception_set; 120 PRInt16 fd_read_cnt[_PR_MD_MAX_OSFD],fd_write_cnt[_PR_MD_MAX_OSFD], 121 fd_exception_cnt[_PR_MD_MAX_OSFD]; 122 #else 123 struct pollfd *ioq_pollfds; 124 int ioq_pollfds_size; 125 #endif /* _PR_USE_POLL */ 126 }; 127 128 #define _PR_IOQ(_cpu) ((_cpu)->md.md_unix.ioQ) 129 #define _PR_ADD_TO_IOQ(_pq, _cpu) PR_APPEND_LINK(&_pq.links, &_PR_IOQ(_cpu)) 130 #define _PR_FD_READ_SET(_cpu) ((_cpu)->md.md_unix.fd_read_set) 131 #define _PR_FD_READ_CNT(_cpu) ((_cpu)->md.md_unix.fd_read_cnt) 132 #define _PR_FD_WRITE_SET(_cpu) ((_cpu)->md.md_unix.fd_write_set) 133 #define _PR_FD_WRITE_CNT(_cpu) ((_cpu)->md.md_unix.fd_write_cnt) 134 #define _PR_FD_EXCEPTION_SET(_cpu) ((_cpu)->md.md_unix.fd_exception_set) 135 #define _PR_FD_EXCEPTION_CNT(_cpu) ((_cpu)->md.md_unix.fd_exception_cnt) 136 #define _PR_IOQ_TIMEOUT(_cpu) ((_cpu)->md.md_unix.ioq_timeout) 137 #define _PR_IOQ_MAX_OSFD(_cpu) ((_cpu)->md.md_unix.ioq_max_osfd) 138 #define _PR_IOQ_OSFD_CNT(_cpu) ((_cpu)->md.md_unix.ioq_osfd_cnt) 139 #define _PR_IOQ_POLLFDS(_cpu) ((_cpu)->md.md_unix.ioq_pollfds) 140 #define _PR_IOQ_POLLFDS_SIZE(_cpu) ((_cpu)->md.md_unix.ioq_pollfds_size) 141 142 #define _PR_IOQ_MIN_POLLFDS_SIZE(_cpu) 32 143 144 struct _MDCPU { 145 struct _MDCPU_Unix md_unix; 146 }; 147 148 #define _MD_INIT_LOCKS() 149 #define _MD_NEW_LOCK(lock) PR_SUCCESS 150 #define _MD_FREE_LOCK(lock) 151 #define _MD_LOCK(lock) 152 #define _MD_UNLOCK(lock) 153 #define _MD_INIT_IO() 154 #define _MD_IOQ_LOCK() 155 #define _MD_IOQ_UNLOCK() 156 157 #define _MD_EARLY_INIT _MD_EarlyInit 158 #define _MD_FINAL_INIT _PR_UnixInit 159 #define _MD_INIT_RUNNING_CPU(cpu) _MD_unix_init_running_cpu(cpu) 160 #define _MD_INIT_THREAD _MD_InitializeThread 161 #define _MD_EXIT_THREAD(thread) 162 #define _MD_SUSPEND_THREAD(thread) 163 #define _MD_RESUME_THREAD(thread) 164 #define _MD_CLEAN_THREAD(_thread) 165 166 #define _MD_INTERVAL_USE_GTOD 167 168 #define _MD_SELECT _select 169 #define _MD_POLL _poll 170 171 #endif /* nspr_scoos5_defs_h___ */ 172