Changeset 102215 in vbox for trunk/src/libs/xpcom18a4/nsprpub
- Timestamp:
- Nov 21, 2023 3:00:17 PM (14 months ago)
- Location:
- trunk/src/libs/xpcom18a4/nsprpub/pr
- Files:
-
- 3 deleted
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/libs/xpcom18a4/nsprpub/pr/include/md/_darwin.h
r101969 r102215 39 39 #define nspr_darwin_defs_h___ 40 40 41 #include "prthread.h"42 43 41 #include <sys/syscall.h> 44 42 … … 70 68 71 69 #undef HAVE_STACK_GROWING_UP 72 #define HAVE_DLL73 #define USE_MACH_DYLD74 70 #define _PR_HAVE_SOCKADDR_LEN 75 71 #define _PR_STAT_HAS_ST_ATIMESPEC 76 72 #define _PR_HAVE_LARGE_OFF_T 77 73 #define PR_HAVE_SYSV_NAMED_SHARED_MEMORY 78 79 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060 /* Mac OS X 10.6 has poll(). */80 # if 0 /* ... but we don't use it because it performs worse on Mt. Lion - WEIRD! */81 # define _PR_POLL_AVAILABLE 182 # define _PR_USE_POLL 183 # endif84 #endif85 86 #define _PR_INET687 /*88 * I'd prefer to use getipnodebyname and getipnodebyaddr but the89 * getipnodebyname(3) man page on Mac OS X 10.2 says they are not90 * thread-safe. AI_V4MAPPED|AI_ADDRCONFIG doesn't work either.91 */92 #define _PR_HAVE_GETHOSTBYNAME293 #define _PR_HAVE_GETADDRINFO94 /*95 * On Mac OS X 10.2, gethostbyaddr fails with h_errno=NO_RECOVERY96 * if you pass an IPv4-mapped IPv6 address to it.97 */98 #define _PR_GHBA_DISALLOW_V4MAPPED99 #ifdef XP_MACOSX100 #if !defined(MAC_OS_X_VERSION_10_3) || \101 MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_3102 /*103 * socket(AF_INET6) fails with EPROTONOSUPPORT on Mac OS X 10.1.104 * IPv6 under OS X 10.2 and below is not complete (see bug 222031).105 */106 #define _PR_INET6_PROBE107 #endif /* DT < 10.3 */108 #if defined(MAC_OS_X_VERSION_10_2) && \109 MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_2110 /* Mac OS X 10.2 has inet_ntop and inet_pton. */111 #define _PR_HAVE_INET_NTOP112 #endif /* DT >= 10.2 */113 #endif /* XP_MACOSX */114 #define _PR_IPV6_V6ONLY_PROBE115 /* The IPV6_V6ONLY socket option is not defined on Mac OS X 10.1. */116 #ifndef IPV6_V6ONLY117 #define IPV6_V6ONLY 27118 #endif119 120 #define USE_SETJMP121 122 #if !defined(_PR_PTHREADS)123 124 #include <setjmp.h>125 126 #define PR_CONTEXT_TYPE jmp_buf127 128 #define CONTEXT(_th) ((_th)->md.context)129 #define _MD_GET_SP(_th) (((struct sigcontext *) (_th)->md.context)->sc_onstack)130 #define PR_NUM_GCREGS _JBLEN131 132 /*133 ** Initialize a thread context to run "_main()" when started134 */135 #define _MD_INIT_CONTEXT(_thread, _sp, _main, status) \136 { \137 *status = PR_TRUE; \138 if (setjmp(CONTEXT(_thread))) { \139 _main(); \140 } \141 _MD_GET_SP(_thread) = (unsigned char*) ((_sp) - 64); \142 }143 144 #define _MD_SWITCH_CONTEXT(_thread) \145 if (!setjmp(CONTEXT(_thread))) { \146 (_thread)->md.errcode = errno; \147 _PR_Schedule(); \148 }149 150 /*151 ** Restore a thread context, saved by _MD_SWITCH_CONTEXT152 */153 #define _MD_RESTORE_CONTEXT(_thread) \154 { \155 errno = (_thread)->md.errcode; \156 _MD_SET_CURRENT_THREAD(_thread); \157 longjmp(CONTEXT(_thread), 1); \158 }159 160 /* Machine-dependent (MD) data structures */161 162 struct _MDThread {163 PR_CONTEXT_TYPE context;164 int id;165 int errcode;166 };167 168 struct _MDThreadStack {169 PRInt8 notused;170 };171 172 struct _MDLock {173 PRInt8 notused;174 };175 176 struct _MDSemaphore {177 PRInt8 notused;178 };179 180 struct _MDCVar {181 PRInt8 notused;182 };183 184 struct _MDSegment {185 PRInt8 notused;186 };187 188 /*189 * md-specific cpu structure field190 */191 #define _PR_MD_MAX_OSFD FD_SETSIZE192 193 struct _MDCPU_Unix {194 PRCList ioQ;195 PRUint32 ioq_timeout;196 PRInt32 ioq_max_osfd;197 PRInt32 ioq_osfd_cnt;198 #ifndef _PR_USE_POLL199 fd_set fd_read_set, fd_write_set, fd_exception_set;200 PRInt16 fd_read_cnt[_PR_MD_MAX_OSFD],fd_write_cnt[_PR_MD_MAX_OSFD],201 fd_exception_cnt[_PR_MD_MAX_OSFD];202 #else203 struct pollfd *ioq_pollfds;204 int ioq_pollfds_size;205 #endif /* _PR_USE_POLL */206 };207 208 #define _PR_IOQ(_cpu) ((_cpu)->md.md_unix.ioQ)209 #define _PR_ADD_TO_IOQ(_pq, _cpu) PR_APPEND_LINK(&_pq.links, &_PR_IOQ(_cpu))210 #define _PR_FD_READ_SET(_cpu) ((_cpu)->md.md_unix.fd_read_set)211 #define _PR_FD_READ_CNT(_cpu) ((_cpu)->md.md_unix.fd_read_cnt)212 #define _PR_FD_WRITE_SET(_cpu) ((_cpu)->md.md_unix.fd_write_set)213 #define _PR_FD_WRITE_CNT(_cpu) ((_cpu)->md.md_unix.fd_write_cnt)214 #define _PR_FD_EXCEPTION_SET(_cpu) ((_cpu)->md.md_unix.fd_exception_set)215 #define _PR_FD_EXCEPTION_CNT(_cpu) ((_cpu)->md.md_unix.fd_exception_cnt)216 #define _PR_IOQ_TIMEOUT(_cpu) ((_cpu)->md.md_unix.ioq_timeout)217 #define _PR_IOQ_MAX_OSFD(_cpu) ((_cpu)->md.md_unix.ioq_max_osfd)218 #define _PR_IOQ_OSFD_CNT(_cpu) ((_cpu)->md.md_unix.ioq_osfd_cnt)219 #define _PR_IOQ_POLLFDS(_cpu) ((_cpu)->md.md_unix.ioq_pollfds)220 #define _PR_IOQ_POLLFDS_SIZE(_cpu) ((_cpu)->md.md_unix.ioq_pollfds_size)221 222 #define _PR_IOQ_MIN_POLLFDS_SIZE(_cpu) 32223 224 struct _MDCPU {225 struct _MDCPU_Unix md_unix;226 };227 228 #define _MD_INIT_LOCKS()229 #define _MD_NEW_LOCK(lock) PR_SUCCESS230 #define _MD_FREE_LOCK(lock)231 #define _MD_LOCK(lock)232 #define _MD_UNLOCK(lock)233 #define _MD_INIT_IO()234 #define _MD_IOQ_LOCK()235 #define _MD_IOQ_UNLOCK()236 237 extern PRStatus _MD_InitializeThread(PRThread *thread);238 239 #define _MD_INIT_RUNNING_CPU(cpu) _MD_unix_init_running_cpu(cpu)240 #define _MD_INIT_THREAD _MD_InitializeThread241 #define _MD_EXIT_THREAD(thread)242 #define _MD_SUSPEND_THREAD(thread) _MD_suspend_thread243 #define _MD_RESUME_THREAD(thread) _MD_resume_thread244 #define _MD_CLEAN_THREAD(_thread)245 246 extern PRStatus _MD_CREATE_THREAD(247 PRThread *thread,248 void (*start) (void *),249 PRThreadPriority priority,250 PRThreadScope scope,251 PRThreadState state,252 PRUint32 stackSize);253 extern void _MD_SET_PRIORITY(struct _MDThread *thread, PRUintn newPri);254 extern PRStatus _MD_WAIT(PRThread *, PRIntervalTime timeout);255 extern PRStatus _MD_WAKEUP_WAITER(PRThread *);256 extern void _MD_YIELD(void);257 258 #endif /* ! _PR_PTHREADS */259 74 260 75 #define _MD_EARLY_INIT _MD_EarlyInit … … 267 82 extern PRIntervalTime _PR_UNIX_TicksPerSecond(void); 268 83 269 /*270 * We wrapped the select() call. _MD_SELECT refers to the built-in,271 * unwrapped version.272 */273 #define _MD_SELECT(nfds,r,w,e,tv) syscall(SYS_select,nfds,r,w,e,tv)274 275 /* For writev() */276 #include <sys/uio.h>277 278 84 #endif /* nspr_darwin_defs_h___ */ -
trunk/src/libs/xpcom18a4/nsprpub/pr/include/md/_linux.h
r101969 r102215 38 38 #ifndef nspr_linux_defs_h___ 39 39 #define nspr_linux_defs_h___ 40 41 #include "prthread.h"42 40 43 41 /* … … 83 81 #undef HAVE_STACK_GROWING_UP 84 82 85 /*86 * Elf linux supports dl* functions87 */88 #define HAVE_DLL89 #define USE_DLFCN90 91 #define USE_SETJMP92 #if defined(__GLIBC__) && __GLIBC__ >= 293 #define _PR_POLL_AVAILABLE94 #endif95 #undef _PR_USE_POLL96 #define _PR_STAT_HAS_ONLY_ST_ATIME97 #if defined(__alpha) || defined(__ia64__)98 #define _PR_HAVE_LARGE_OFF_T99 #elif (__GLIBC__ > 2) || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1)100 #define _PR_HAVE_OFF64_T101 #else102 #define _PR_NO_LARGE_FILES103 #endif104 #if (__GLIBC__ > 2) || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1)105 #define _PR_INET6106 #define _PR_HAVE_INET_NTOP107 #define _PR_HAVE_GETHOSTBYNAME2108 #define _PR_HAVE_GETADDRINFO109 #define _PR_INET6_PROBE110 #endif111 #define _PR_HAVE_SYSV_SEMAPHORES112 #define PR_HAVE_SYSV_NAMED_SHARED_MEMORY113 #if (__GLIBC__ >= 2) && defined(_PR_PTHREADS)114 #define _PR_HAVE_GETHOST_R115 #define _PR_HAVE_GETHOST_R_INT116 #endif117 118 #ifdef _PR_PTHREADS119 120 83 extern void _MD_CleanupBeforeExit(void); 121 84 #define _MD_CLEANUP_BEFORE_EXIT _MD_CleanupBeforeExit 122 123 #else /* ! _PR_PTHREADS */124 125 #include <setjmp.h>126 127 #define PR_CONTEXT_TYPE sigjmp_buf128 129 #define CONTEXT(_th) ((_th)->md.context)130 131 #ifdef __powerpc__132 /*133 * PowerPC based MkLinux134 *135 * On the PowerPC, the new style jmp_buf isn't used until glibc136 * 2.1.137 */138 #if (__GLIBC__ > 2) || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1)139 #define _MD_GET_SP(_t) (_t)->md.context[0].__jmpbuf[JB_GPR1]140 #else141 #define _MD_GET_SP(_t) (_t)->md.context[0].__jmpbuf[0].__misc[0]142 #endif /* glibc 2.1 or later */143 #define _MD_SET_FP(_t, val)144 #define _MD_GET_SP_PTR(_t) &(_MD_GET_SP(_t))145 #define _MD_GET_FP_PTR(_t) ((void *) 0)146 /* aix = 64, macos = 70 */147 #define PR_NUM_GCREGS 64148 149 #elif defined(__alpha)150 /* Alpha based Linux */151 152 #if defined(__GLIBC__) && __GLIBC__ >= 2153 #define _MD_GET_SP(_t) (_t)->md.context[0].__jmpbuf[JB_SP]154 #define _MD_SET_FP(_t, val)155 #define _MD_GET_SP_PTR(_t) &(_MD_GET_SP(_t))156 #define _MD_GET_FP_PTR(_t) ((void *) 0)157 #define _MD_SP_TYPE long int158 #else159 #define _MD_GET_SP(_t) (_t)->md.context[0].__jmpbuf[0].__sp160 #define _MD_SET_FP(_t, val)161 #define _MD_GET_SP_PTR(_t) &(_MD_GET_SP(_t))162 #define _MD_GET_FP_PTR(_t) ((void *) 0)163 #define _MD_SP_TYPE __ptr_t164 #endif /* defined(__GLIBC__) && __GLIBC__ >= 2 */165 166 /* XXX not sure if this is correct, or maybe it should be 17? */167 #define PR_NUM_GCREGS 9168 169 #elif defined(__ia64__)170 171 #define _MD_GET_SP(_t) ((long *)((_t)->md.context[0].__jmpbuf)[0])172 #define _MD_SET_FP(_t, val)173 #define _MD_GET_SP_PTR(_t) &(_MD_GET_SP(_t))174 #define _MD_GET_FP_PTR(_t) ((void *) 0)175 #define _MD_SP_TYPE long int176 177 #define PR_NUM_GCREGS _JBLEN178 179 #elif defined(__mc68000__)180 /* m68k based Linux */181 182 /*183 * On the m68k, glibc still uses the old style sigjmp_buf, even184 * in glibc 2.0.7.185 */186 #if defined(__GLIBC__) && __GLIBC__ >= 2187 #define _MD_GET_SP(_t) (_t)->md.context[0].__jmpbuf[0].__sp188 #define _MD_SET_FP(_t, val)189 #define _MD_GET_SP_PTR(_t) &(_MD_GET_SP(_t))190 #define _MD_GET_FP_PTR(_t) ((void *) 0)191 #define _MD_SP_TYPE int192 #else193 #define _MD_GET_SP(_t) (_t)->md.context[0].__jmpbuf[0].__sp194 #define _MD_SET_FP(_t, val)195 #define _MD_GET_SP_PTR(_t) &(_MD_GET_SP(_t))196 #define _MD_GET_FP_PTR(_t) ((void *) 0)197 #define _MD_SP_TYPE __ptr_t198 #endif /* defined(__GLIBC__) && __GLIBC__ >= 2 */199 200 /* XXX not sure if this is correct, or maybe it should be 17? */201 #define PR_NUM_GCREGS 9202 203 #elif defined(__sparc__)204 /* Sparc */205 #if defined(__GLIBC__) && __GLIBC__ >= 2206 /*207 * You need glibc2-2.0.7-25 or later. The libraries that came with208 * Red Hat 5.1 are not new enough, but they are in 5.2.209 */210 #define _MD_GET_SP(_t) (_t)->md.context[0].__jmpbuf[JB_SP]211 #define _MD_SET_FP(_t, val) ((_t)->md.context[0].__jmpbuf[JB_FP] = val)212 #define _MD_GET_SP_PTR(_t) &(_MD_GET_SP(_t))213 #define _MD_GET_FP_PTR(_t) (&(_t)->md.context[0].__jmpbuf[JB_FP])214 #define _MD_SP_TYPE int215 #else216 #define _MD_GET_SP(_t) (_t)->md.context[0].__jmpbuf[0].__fp217 #define _MD_SET_FP(_t, val)218 #define _MD_GET_SP_PTR(_t) &(_MD_GET_SP(_t))219 #define _MD_GET_FP_PTR(_t) ((void *) 0)220 #define _MD_SP_TYPE __ptr_t221 #endif /* defined(__GLIBC__) && __GLIBC__ >= 2 */222 223 #elif defined(__i386__)224 /* Intel based Linux */225 #if defined(__GLIBC__) && __GLIBC__ >= 2226 #define _MD_GET_SP(_t) (_t)->md.context[0].__jmpbuf[JB_SP]227 #define _MD_SET_FP(_t, val) ((_t)->md.context[0].__jmpbuf[JB_BP] = val)228 #define _MD_GET_SP_PTR(_t) &(_MD_GET_SP(_t))229 #define _MD_GET_FP_PTR(_t) (&(_t)->md.context[0].__jmpbuf[JB_BP])230 #define _MD_SP_TYPE int231 #else232 #define _MD_GET_SP(_t) (_t)->md.context[0].__jmpbuf[0].__sp233 #define _MD_SET_FP(_t, val) ((_t)->md.context[0].__jmpbuf[0].__bp = val)234 #define _MD_GET_SP_PTR(_t) &(_MD_GET_SP(_t))235 #define _MD_GET_FP_PTR(_t) &((_t)->md.context[0].__jmpbuf[0].__bp)236 #define _MD_SP_TYPE __ptr_t237 #endif /* defined(__GLIBC__) && __GLIBC__ >= 2 */238 #define PR_NUM_GCREGS 6239 240 #elif defined(__mips__)241 /* Linux/MIPS */242 #if defined(__GLIBC__) && __GLIBC__ >= 2243 #define _MD_GET_SP(_t) (_t)->md.context[0].__jmpbuf[0].__sp244 #define _MD_SET_FP(_t, val) ((_t)->md.context[0].__jmpbuf[0].__fp = (val))245 #define _MD_GET_SP_PTR(_t) &(_MD_GET_SP(_t))246 #define _MD_GET_FP_PTR(_t) (&(_t)->md.context[0].__jmpbuf[0].__fp)247 #define _MD_SP_TYPE __ptr_t248 #else249 #error "Linux/MIPS pre-glibc2 not supported yet"250 #endif /* defined(__GLIBC__) && __GLIBC__ >= 2 */251 252 #elif defined(__arm__)253 /* ARM/Linux */254 #if defined(__GLIBC__) && __GLIBC__ >= 2255 #define _MD_GET_SP(_t) (_t)->md.context[0].__jmpbuf[20]256 #define _MD_SET_FP(_t, val) ((_t)->md.context[0].__jmpbuf[19] = (val))257 #define _MD_GET_SP_PTR(_t) &(_MD_GET_SP(_t))258 #define _MD_GET_FP_PTR(_t) (&(_t)->md.context[0].__jmpbuf[19])259 #define _MD_SP_TYPE __ptr_t260 #else261 #error "ARM/Linux pre-glibc2 not supported yet"262 #endif /* defined(__GLIBC__) && __GLIBC__ >= 2 */263 264 #else265 266 #error "Unknown CPU architecture"267 268 #endif /*__powerpc__*/269 270 /*271 ** Initialize a thread context to run "_main()" when started272 */273 #ifdef __powerpc__274 275 #define _MD_INIT_CONTEXT(_thread, _sp, _main, status) \276 { \277 *status = PR_TRUE; \278 if (sigsetjmp(CONTEXT(_thread), 1)) { \279 _main(); \280 } \281 _MD_GET_SP(_thread) = (unsigned char*) ((_sp) - 128); \282 _thread->md.sp = _MD_GET_SP_PTR(_thread); \283 _thread->md.fp = _MD_GET_FP_PTR(_thread); \284 _MD_SET_FP(_thread, 0); \285 }286 287 #elif defined(__mips__)288 289 #define _MD_INIT_CONTEXT(_thread, _sp, _main, status) \290 { \291 *status = PR_TRUE; \292 (void) sigsetjmp(CONTEXT(_thread), 1); \293 _thread->md.context[0].__jmpbuf[0].__pc = (__ptr_t) _main; \294 _MD_GET_SP(_thread) = (_MD_SP_TYPE) ((_sp) - 64); \295 _thread->md.sp = _MD_GET_SP_PTR(_thread); \296 _thread->md.fp = _MD_GET_FP_PTR(_thread); \297 _MD_SET_FP(_thread, 0); \298 }299 300 #else301 302 #define _MD_INIT_CONTEXT(_thread, _sp, _main, status) \303 { \304 *status = PR_TRUE; \305 if (sigsetjmp(CONTEXT(_thread), 1)) { \306 _main(); \307 } \308 _MD_GET_SP(_thread) = (_MD_SP_TYPE) ((_sp) - 64); \309 _thread->md.sp = _MD_GET_SP_PTR(_thread); \310 _thread->md.fp = _MD_GET_FP_PTR(_thread); \311 _MD_SET_FP(_thread, 0); \312 }313 314 #endif /*__powerpc__*/315 316 #define _MD_SWITCH_CONTEXT(_thread) \317 if (!sigsetjmp(CONTEXT(_thread), 1)) { \318 (_thread)->md.errcode = errno; \319 _PR_Schedule(); \320 }321 322 /*323 ** Restore a thread context, saved by _MD_SWITCH_CONTEXT324 */325 #define _MD_RESTORE_CONTEXT(_thread) \326 { \327 errno = (_thread)->md.errcode; \328 _MD_SET_CURRENT_THREAD(_thread); \329 siglongjmp(CONTEXT(_thread), 1); \330 }331 332 /* Machine-dependent (MD) data structures */333 334 struct _MDThread {335 PR_CONTEXT_TYPE context;336 void *sp;337 void *fp;338 int id;339 int errcode;340 };341 342 struct _MDThreadStack {343 PRInt8 notused;344 };345 346 struct _MDLock {347 PRInt8 notused;348 };349 350 struct _MDSemaphore {351 PRInt8 notused;352 };353 354 struct _MDCVar {355 PRInt8 notused;356 };357 358 struct _MDSegment {359 PRInt8 notused;360 };361 362 /*363 * md-specific cpu structure field364 */365 #include <sys/time.h> /* for FD_SETSIZE */366 #define _PR_MD_MAX_OSFD FD_SETSIZE367 368 struct _MDCPU_Unix {369 PRCList ioQ;370 PRUint32 ioq_timeout;371 PRInt32 ioq_max_osfd;372 PRInt32 ioq_osfd_cnt;373 #ifndef _PR_USE_POLL374 fd_set fd_read_set, fd_write_set, fd_exception_set;375 PRInt16 fd_read_cnt[_PR_MD_MAX_OSFD],fd_write_cnt[_PR_MD_MAX_OSFD],376 fd_exception_cnt[_PR_MD_MAX_OSFD];377 #else378 struct pollfd *ioq_pollfds;379 int ioq_pollfds_size;380 #endif /* _PR_USE_POLL */381 };382 383 #define _PR_IOQ(_cpu) ((_cpu)->md.md_unix.ioQ)384 #define _PR_ADD_TO_IOQ(_pq, _cpu) PR_APPEND_LINK(&_pq.links, &_PR_IOQ(_cpu))385 #define _PR_FD_READ_SET(_cpu) ((_cpu)->md.md_unix.fd_read_set)386 #define _PR_FD_READ_CNT(_cpu) ((_cpu)->md.md_unix.fd_read_cnt)387 #define _PR_FD_WRITE_SET(_cpu) ((_cpu)->md.md_unix.fd_write_set)388 #define _PR_FD_WRITE_CNT(_cpu) ((_cpu)->md.md_unix.fd_write_cnt)389 #define _PR_FD_EXCEPTION_SET(_cpu) ((_cpu)->md.md_unix.fd_exception_set)390 #define _PR_FD_EXCEPTION_CNT(_cpu) ((_cpu)->md.md_unix.fd_exception_cnt)391 #define _PR_IOQ_TIMEOUT(_cpu) ((_cpu)->md.md_unix.ioq_timeout)392 #define _PR_IOQ_MAX_OSFD(_cpu) ((_cpu)->md.md_unix.ioq_max_osfd)393 #define _PR_IOQ_OSFD_CNT(_cpu) ((_cpu)->md.md_unix.ioq_osfd_cnt)394 #define _PR_IOQ_POLLFDS(_cpu) ((_cpu)->md.md_unix.ioq_pollfds)395 #define _PR_IOQ_POLLFDS_SIZE(_cpu) ((_cpu)->md.md_unix.ioq_pollfds_size)396 397 #define _PR_IOQ_MIN_POLLFDS_SIZE(_cpu) 32398 399 struct _MDCPU {400 struct _MDCPU_Unix md_unix;401 };402 403 #define _MD_INIT_LOCKS()404 #define _MD_NEW_LOCK(lock) PR_SUCCESS405 #define _MD_FREE_LOCK(lock)406 #define _MD_LOCK(lock)407 #define _MD_UNLOCK(lock)408 #define _MD_INIT_IO()409 #define _MD_IOQ_LOCK()410 #define _MD_IOQ_UNLOCK()411 412 extern PRStatus _MD_InitializeThread(PRThread *thread);413 414 #define _MD_INIT_RUNNING_CPU(cpu) _MD_unix_init_running_cpu(cpu)415 #define _MD_INIT_THREAD _MD_InitializeThread416 #define _MD_EXIT_THREAD(thread)417 #define _MD_SUSPEND_THREAD(thread) _MD_suspend_thread418 #define _MD_RESUME_THREAD(thread) _MD_resume_thread419 #define _MD_CLEAN_THREAD(_thread)420 421 extern PRStatus _MD_CREATE_THREAD(422 PRThread *thread,423 void (*start) (void *),424 PRThreadPriority priority,425 PRThreadScope scope,426 PRThreadState state,427 PRUint32 stackSize);428 extern void _MD_SET_PRIORITY(struct _MDThread *thread, PRUintn newPri);429 extern PRStatus _MD_WAIT(PRThread *, PRIntervalTime timeout);430 extern PRStatus _MD_WAKEUP_WAITER(PRThread *);431 extern void _MD_YIELD(void);432 433 #endif /* ! _PR_PTHREADS */434 85 435 86 extern void _MD_EarlyInit(void); … … 442 93 #define _MD_INTERVAL_PER_SEC _PR_UNIX_TicksPerSecond 443 94 444 /*445 * We wrapped the select() call. _MD_SELECT refers to the built-in,446 * unwrapped version.447 */448 #define _MD_SELECT __select449 450 #ifdef _PR_POLL_AVAILABLE451 #include <sys/poll.h>452 extern int __syscall_poll(struct pollfd *ufds, unsigned long int nfds,453 int timeout);454 #define _MD_POLL __syscall_poll455 #endif456 457 /* For writev() */458 #include <sys/uio.h>459 460 extern void _MD_linux_map_sendfile_error(int err);461 462 95 #endif /* nspr_linux_defs_h___ */ 463 96 -
trunk/src/libs/xpcom18a4/nsprpub/pr/include/md/_pth.h
r5589 r102215 47 47 #define _PR_MD_ENABLE_CLOCK_INTERRUPTS() 48 48 49 /* In good standards fashion, the DCE threads (based on posix-4) are not50 * quite the same as newer posix implementations. These are mostly name51 * changes and small differences, so macros usually do the trick52 */53 #ifdef _PR_DCETHREADS54 #define _PT_PTHREAD_MUTEXATTR_INIT pthread_mutexattr_create55 #define _PT_PTHREAD_MUTEXATTR_DESTROY pthread_mutexattr_delete56 #define _PT_PTHREAD_MUTEX_INIT(m, a) pthread_mutex_init(&(m), a)57 #define _PT_PTHREAD_MUTEX_IS_LOCKED(m) (0 == pthread_mutex_trylock(&(m)))58 #define _PT_PTHREAD_CONDATTR_INIT pthread_condattr_create59 #define _PT_PTHREAD_COND_INIT(m, a) pthread_cond_init(&(m), a)60 #define _PT_PTHREAD_CONDATTR_DESTROY pthread_condattr_delete61 62 /* Notes about differences between DCE threads and pthreads 10:63 * 1. pthread_mutex_trylock returns 1 when it locks the mutex64 * 0 when it does not. The latest pthreads has a set of errno-like65 * return values.66 * 2. return values from pthread_cond_timedwait are different.67 *68 *69 *70 */71 #elif defined(BSDI)72 /*73 * Mutex and condition attributes are not supported. The attr74 * argument to pthread_mutex_init() and pthread_cond_init() must75 * be passed as NULL.76 *77 * The memset calls in _PT_PTHREAD_MUTEX_INIT and _PT_PTHREAD_COND_INIT78 * are to work around BSDI's using a single bit to indicate a mutex79 * or condition variable is initialized. This entire BSDI section80 * will go away when BSDI releases updated threads libraries for81 * BSD/OS 3.1 and 4.0.82 */83 #define _PT_PTHREAD_MUTEXATTR_INIT(x) 084 #define _PT_PTHREAD_MUTEXATTR_DESTROY(x) /* */85 #define _PT_PTHREAD_MUTEX_INIT(m, a) (memset(&(m), 0, sizeof(m)), \86 pthread_mutex_init(&(m), NULL))87 #define _PT_PTHREAD_MUTEX_IS_LOCKED(m) (EBUSY == pthread_mutex_trylock(&(m)))88 #define _PT_PTHREAD_CONDATTR_INIT(x) 089 #define _PT_PTHREAD_CONDATTR_DESTROY(x) /* */90 #define _PT_PTHREAD_COND_INIT(m, a) (memset(&(m), 0, sizeof(m)), \91 pthread_cond_init(&(m), NULL))92 #else93 49 #define _PT_PTHREAD_MUTEXATTR_INIT pthread_mutexattr_init 94 50 #define _PT_PTHREAD_MUTEXATTR_DESTROY pthread_mutexattr_destroy … … 102 58 #define _PT_PTHREAD_CONDATTR_DESTROY pthread_condattr_destroy 103 59 #define _PT_PTHREAD_COND_INIT(m, a) pthread_cond_init(&(m), &(a)) 104 #endif105 60 106 61 /* The pthreads standard does not specify an invalid value for the … … 133 88 * recursion ensues. 134 89 */ 135 #if defined(_PR_DCETHREADS) 136 #define _PT_PTHREAD_INVALIDATE_THR_HANDLE(t) \ 137 memset(&(t), 0, sizeof(pthread_t)) 138 #define _PT_PTHREAD_THR_HANDLE_IS_INVALID(t) \ 139 (!memcmp(&(t), &pt_zero_tid, sizeof(pthread_t))) 140 #define _PT_PTHREAD_COPY_THR_HANDLE(st, dt) (dt) = (st) 141 #elif defined(IRIX) || defined(OSF1) || defined(AIX) || defined(SOLARIS) \ 90 #if defined(IRIX) || defined(OSF1) || defined(AIX) || defined(SOLARIS) \ 142 91 || defined(HPUX) || defined(LINUX) || defined(FREEBSD) \ 143 92 || defined(NETBSD) || defined(OPENBSD) || defined(BSDI) \ … … 151 100 #endif 152 101 153 #if defined(_PR_DCETHREADS) 154 #define _PT_PTHREAD_ATTR_INIT pthread_attr_create 155 #define _PT_PTHREAD_ATTR_DESTROY pthread_attr_delete 156 #define _PT_PTHREAD_CREATE(t, a, f, r) pthread_create(t, a, f, r) 157 #define _PT_PTHREAD_KEY_CREATE pthread_keycreate 158 #define _PT_PTHREAD_ATTR_SETSCHEDPOLICY pthread_attr_setsched 159 #define _PT_PTHREAD_ATTR_GETSTACKSIZE(a, s) \ 160 (*(s) = pthread_attr_getstacksize(*(a)), 0) 161 #define _PT_PTHREAD_GETSPECIFIC(k, r) \ 162 pthread_getspecific((k), (pthread_addr_t *) &(r)) 163 #elif defined(_PR_PTHREADS) 102 #if defined(_PR_PTHREADS) 164 103 #define _PT_PTHREAD_ATTR_INIT pthread_attr_init 165 104 #define _PT_PTHREAD_ATTR_DESTROY pthread_attr_destroy … … 173 112 #endif 174 113 175 #if defined(_PR_DCETHREADS)176 #define _PT_PTHREAD_EXPLICIT_SCHED _PT_PTHREAD_DEFAULT_SCHED177 #endif178 179 /*180 * pthread_mutex_trylock returns different values in DCE threads and181 * pthreads.182 */183 #if defined(_PR_DCETHREADS)184 #define PT_TRYLOCK_SUCCESS 1185 #define PT_TRYLOCK_BUSY 0186 #else187 114 #define PT_TRYLOCK_SUCCESS 0 188 115 #define PT_TRYLOCK_BUSY EBUSY 189 #endif190 116 191 117 /* … … 206 132 #endif 207 133 208 #if defined(OSF1) || defined(VMS) 209 #define PT_PRIO_MIN PRI_OTHER_MIN 210 #define PT_PRIO_MAX PRI_OTHER_MAX 211 #elif defined(IRIX) 212 #include <sys/sched.h> 213 #define PT_PRIO_MIN PX_PRIO_MIN 214 #define PT_PRIO_MAX PX_PRIO_MAX 215 #elif defined(AIX) 216 #include <sys/priv.h> 217 #include <sys/sched.h> 218 #ifndef PTHREAD_CREATE_JOINABLE 219 #define PTHREAD_CREATE_JOINABLE PTHREAD_CREATE_UNDETACHED 220 #endif 221 #define PT_PRIO_MIN DEFAULT_PRIO 222 #define PT_PRIO_MAX DEFAULT_PRIO 223 #elif defined(HPUX) 224 225 #if defined(_PR_DCETHREADS) 226 #define PT_PRIO_MIN PRI_OTHER_MIN 227 #define PT_PRIO_MAX PRI_OTHER_MAX 228 #else /* defined(_PR_DCETHREADS) */ 229 #include <sys/sched.h> 134 #if defined(LINUX) || defined(FREEBSD) 230 135 #define PT_PRIO_MIN sched_get_priority_min(SCHED_OTHER) 231 136 #define PT_PRIO_MAX sched_get_priority_max(SCHED_OTHER) 232 #endif /* defined(_PR_DCETHREADS) */233 234 #elif defined(LINUX) || defined(FREEBSD)235 #define PT_PRIO_MIN sched_get_priority_min(SCHED_OTHER)236 #define PT_PRIO_MAX sched_get_priority_max(SCHED_OTHER)237 #elif defined(NTO)238 /*239 * Neutrino has functions that return the priority range but240 * they return invalid numbers, so I just hard coded these here241 * for now. [email protected]242 */243 #define PT_PRIO_MIN 0244 #define PT_PRIO_MAX 30245 137 #elif defined(SOLARIS) 246 138 /* … … 268 160 * implementation. 269 161 */ 270 #if defined(_PR_DCETHREADS) 271 #define _PT_PTHREAD_YIELD() pthread_yield() 272 #elif defined(OSF1) || defined(VMS) 273 /* 274 * sched_yield can't be called from a signal handler. Must use 275 * the _np version. 276 */ 277 #define _PT_PTHREAD_YIELD() pthread_yield_np() 278 #elif defined(AIX) 279 extern int (*_PT_aix_yield_fcn)(); 280 #define _PT_PTHREAD_YIELD() (*_PT_aix_yield_fcn)() 281 #elif defined(IRIX) 282 #include <time.h> 283 #define _PT_PTHREAD_YIELD() \ 284 PR_BEGIN_MACRO \ 285 struct timespec onemillisec = {0}; \ 286 onemillisec.tv_nsec = 1000000L; \ 287 nanosleep(&onemillisec,NULL); \ 288 PR_END_MACRO 289 #elif defined(HPUX) || defined(LINUX) || defined(SOLARIS) \ 162 #if defined(HPUX) || defined(LINUX) || defined(SOLARIS) \ 290 163 || defined(FREEBSD) || defined(NETBSD) || defined(OPENBSD) \ 291 164 || defined(BSDI) || defined(NTO) || defined(DARWIN) \ -
trunk/src/libs/xpcom18a4/nsprpub/pr/include/nspr.h
r102211 r102215 48 48 #include "prmon.h" 49 49 #include "prprf.h" 50 #include "prthread.h"51 50 #include "prtime.h" 52 51 #include "prtypes.h" -
trunk/src/libs/xpcom18a4/nsprpub/pr/include/private/primpl.h
r102213 r102215 52 52 #include "prpriv.h" 53 53 54 typedef struct PRSegment PRSegment;55 56 54 #include "md/prosdep.h" 57 58 #ifdef _PR_HAVE_POSIX_SEMAPHORES59 #include <semaphore.h>60 #elif defined(_PR_HAVE_SYSV_SEMAPHORES)61 #include <sys/sem.h>62 #endif63 64 /*************************************************************************65 ***** A Word about Model Dependent Function Naming Convention ***********66 *************************************************************************/67 68 /*69 NSPR 2.0 must implement its function across a range of platforms70 including: MAC, Windows/16, Windows/95, Windows/NT, and several71 variants of Unix. Each implementation shares common code as well72 as having platform dependent portions. This standard describes how73 the model dependent portions are to be implemented.74 75 In header file pr/include/primpl.h, each publicly declared76 platform dependent function is declared as:77 78 NSPR_API void _PR_MD_FUNCTION( long arg1, long arg2 );79 #define _PR_MD_FUNCTION _MD_FUNCTION80 81 In header file pr/include/md/<platform>/_<platform>.h,82 each #define'd macro is redefined as one of:83 84 #define _MD_FUNCTION <blanks>85 #define _MD_FUNCTION <expanded macro>86 #define _MD_FUNCTION <osFunction>87 #define _MD_FUNCTION <_MD_Function>88 89 Where:90 91 <blanks> is no definition at all. In this case, the function is not implemented92 and is never called for this platform.93 For example:94 #define _MD_INIT_CPUS()95 96 <expanded macro> is a C language macro expansion.97 For example:98 #define _MD_CLEAN_THREAD(_thread) \99 PR_BEGIN_MACRO \100 PR_DestroyCondVar(_thread->md.asyncIOCVar); \101 PR_DestroyLock(_thread->md.asyncIOLock); \102 PR_END_MACRO103 104 <osFunction> is some function implemented by the host operating system.105 For example:106 #define _MD_EXIT exit107 108 <_MD_function> is the name of a function implemented for this platform in109 pr/src/md/<platform>/<soruce>.c file.110 For example:111 #define _MD_GETFILEINFO _MD_GetFileInfo112 113 In <source>.c, the implementation is:114 PR_IMPLEMENT(PRInt32) _MD_GetFileInfo(const char *fn, PRFileInfo *info);115 */116 55 117 56 PR_BEGIN_EXTERN_C … … 119 58 typedef struct _MDLock _MDLock; 120 59 typedef struct _MDCVar _MDCVar; 121 typedef struct _MDSegment _MDSegment;122 typedef struct _MDThread _MDThread;123 typedef struct _MDThreadStack _MDThreadStack;124 typedef struct _MDSemaphore _MDSemaphore;125 typedef struct _MDDir _MDDir;126 typedef struct _MDFileDesc _MDFileDesc;127 typedef struct _MDProcess _MDProcess;128 typedef struct _MDFileMap _MDFileMap;129 60 130 61 /* … … 147 78 }; 148 79 149 /*150 * bits defined for pthreads 'state' field151 */152 #define PT_THREAD_DETACHED 0x01 /* thread can't be joined */153 #define PT_THREAD_GLOBAL 0x02 /* a global thread (unlikely) */154 #define PT_THREAD_SYSTEM 0x04 /* system (not user) thread */155 #define PT_THREAD_PRIMORD 0x08 /* this is the primordial thread */156 #define PT_THREAD_ABORTED 0x10 /* thread has been interrupted */157 #define PT_THREAD_GCABLE 0x20 /* thread is garbage collectible */158 #define PT_THREAD_SUSPENDED 0x40 /* thread has been suspended */159 #define PT_THREAD_FOREIGN 0x80 /* thread is not one of ours */160 #define PT_THREAD_BOUND 0x100 /* a bound-global thread */161 162 #define _PT_THREAD_INTERRUPTED(thr) \163 (!(thr->interrupt_blocked) && (thr->state & PT_THREAD_ABORTED))164 #define _PT_THREAD_BLOCK_INTERRUPT(thr) \165 (thr->interrupt_blocked = 1)166 #define _PT_THREAD_UNBLOCK_INTERRUPT(thr) \167 (thr->interrupt_blocked = 0)168 169 #define _PT_IS_GCABLE_THREAD(thr) ((thr)->state & PT_THREAD_GCABLE)170 171 /*172 ** Possible values for thread's suspend field173 ** Note that the first two can be the same as they are really mutually exclusive,174 ** i.e. both cannot be happening at the same time. We have two symbolic names175 ** just as a mnemonic.176 **/177 #define PT_THREAD_RESUMED 0x80 /* thread has been resumed */178 #define PT_THREAD_SETGCABLE 0x100 /* set the GCAble flag */179 180 80 /************************************************************************/ 181 81 /************************************************************************* … … 184 84 *************************************************************************/ 185 85 /************************************************************************/ 186 187 extern void _PR_InitThreads(188 PRThreadType type, PRThreadPriority priority, PRUintn maxPTDs);189 86 190 87 struct PRLock { … … 215 112 /************************************************************************/ 216 113 217 struct PRSemaphore {218 PRCondVar *cvar; /* associated lock and condition variable queue */219 PRUintn count; /* the value of the counting semaphore */220 PRUint32 waiters; /* threads waiting on the semaphore */221 };222 223 NSPR_API(void) _PR_InitSem(void);224 225 /*************************************************************************/226 227 struct PRSem {228 #ifdef _PR_HAVE_POSIX_SEMAPHORES229 sem_t *sem;230 #elif defined(_PR_HAVE_SYSV_SEMAPHORES)231 int semid;232 #elif defined(WIN32)233 HANDLE sem;234 #else235 PRInt8 notused;236 #endif237 };238 239 /************************************************************************/240 241 typedef void (PR_CALLBACK *_PRStartFn)(void *);242 243 struct PRThread {244 PRUint32 state; /* thread's creation state */245 PRThreadPriority priority; /* apparent priority, loosly defined */246 247 void *arg; /* argument to the client's entry point */248 _PRStartFn startFunc; /* the root of the client's thread */249 250 void *environment; /* pointer to execution environment */251 252 /*253 ** Per thread private data254 */255 PRUint32 tpdLength; /* thread's current vector length */256 void **privateData; /* private data vector or NULL */257 258 pthread_t id; /* pthread identifier for the thread */259 PRBool okToDelete; /* ok to delete the PRThread struct? */260 void *sp; /* recorded sp for garbage collection */261 PRThread *next, *prev; /* simple linked list of all threads */262 PRUint32 suspend; /* used to store suspend and resume flags */263 #ifdef PT_NO_SIGTIMEDWAIT264 pthread_mutex_t suspendResumeMutex;265 pthread_cond_t suspendResumeCV;266 #endif267 PRUint32 interrupt_blocked; /* interrupt blocked */268 struct pollfd *syspoll_list; /* Unix polling list used by PR_Poll */269 PRUint32 syspoll_count; /* number of elements in syspoll_list */270 };271 272 struct PRProcess {273 _MDProcess md;274 };275 276 /************************************************************************/277 278 extern void _PR_InitSegs(void);279 extern void _PR_InitStacks(void);280 extern void _PR_InitMem(void);281 extern void _PR_InitIO(void);282 extern void _PR_InitLog(void);283 extern void _PR_InitNet(void);284 114 extern void _PR_InitClock(void); 285 extern void _PR_InitCPUs(void);286 extern void _PR_InitMW(void);287 extern void _PR_NotifyCondVar(PRCondVar *cvar, PRThread *me);288 extern void _PR_CleanupThread(PRThread *thread);289 extern void _PR_CleanupMW(void);290 extern void _PR_CleanupIO(void);291 extern void _PR_CleanupNet(void);292 extern void _PR_CleanupLayerCache(void);293 extern void _PR_CleanupStacks(void);294 #ifdef WINNT295 extern void _PR_CleanupCPUs(void);296 #endif297 extern void _PR_CleanupThreads(void);298 extern void _PR_CleanupTPD(void);299 extern void _PR_Cleanup(void);300 extern void _PR_LogCleanup(void);301 extern void _PR_InitLayerCache(void);302 115 303 116 extern PRBool _pr_initialized; 304 117 extern void _PR_ImplicitInitialization(void); 305 306 /************************************************************************/307 308 struct PRSegment {309 void *vaddr;310 PRUint32 size;311 PRUintn flags;312 };313 314 /* PRSegment.flags */315 #define _PR_SEG_VM 0x1316 317 /************************************************************************/318 319 extern PRInt32 _pr_pageSize;320 extern PRInt32 _pr_pageShift;321 118 322 119 /************************************************************************* … … 334 131 #define _PR_MD_FINAL_INIT _MD_FINAL_INIT 335 132 336 /* Process control */337 338 #ifdef _MD_CREATE_PROCESS_DETACHED339 # define _PR_MD_CREATE_PROCESS_DETACHED _MD_CREATE_PROCESS_DETACHED340 #endif341 342 133 /* Current Time */ 343 134 NSPR_API(PRTime) _PR_MD_NOW(void); 344 135 #define _PR_MD_NOW _MD_NOW 345 346 /* Environment related */347 extern char* _PR_MD_GET_ENV(const char *name);348 #define _PR_MD_GET_ENV _MD_GET_ENV349 350 extern PRIntn _PR_MD_PUT_ENV(const char *name);351 #define _PR_MD_PUT_ENV _MD_PUT_ENV352 353 /* Atomic operations */354 355 extern void _PR_MD_INIT_ATOMIC(void);356 #define _PR_MD_INIT_ATOMIC _MD_INIT_ATOMIC357 358 extern PRInt32 _PR_MD_ATOMIC_INCREMENT(PRInt32 *);359 #define _PR_MD_ATOMIC_INCREMENT _MD_ATOMIC_INCREMENT360 361 extern PRInt32 _PR_MD_ATOMIC_ADD(PRInt32 *, PRInt32);362 #define _PR_MD_ATOMIC_ADD _MD_ATOMIC_ADD363 364 extern PRInt32 _PR_MD_ATOMIC_DECREMENT(PRInt32 *);365 #define _PR_MD_ATOMIC_DECREMENT _MD_ATOMIC_DECREMENT366 367 extern PRInt32 _PR_MD_ATOMIC_SET(PRInt32 *, PRInt32);368 #define _PR_MD_ATOMIC_SET _MD_ATOMIC_SET369 136 370 137 /* Time intervals */ … … 376 143 #define _PR_MD_INTERVAL_PER_SEC _MD_INTERVAL_PER_SEC 377 144 378 /* Affinity masks */379 380 extern PRInt32 _PR_MD_SETTHREADAFFINITYMASK(PRThread *thread, PRUint32 mask );381 #define _PR_MD_SETTHREADAFFINITYMASK _MD_SETTHREADAFFINITYMASK382 383 extern PRInt32 _PR_MD_GETTHREADAFFINITYMASK(PRThread *thread, PRUint32 *mask);384 #define _PR_MD_GETTHREADAFFINITYMASK _MD_GETTHREADAFFINITYMASK385 386 /* File locking */387 388 extern PRStatus _PR_MD_LOCKFILE(PRInt32 osfd);389 #define _PR_MD_LOCKFILE _MD_LOCKFILE390 391 extern PRStatus _PR_MD_TLOCKFILE(PRInt32 osfd);392 #define _PR_MD_TLOCKFILE _MD_TLOCKFILE393 394 extern PRStatus _PR_MD_UNLOCKFILE(PRInt32 osfd);395 #define _PR_MD_UNLOCKFILE _MD_UNLOCKFILE396 397 /* Socket call error code */398 399 NSPR_API(PRInt32) _PR_MD_GET_SOCKET_ERROR(void);400 #define _PR_MD_GET_SOCKET_ERROR _MD_GET_SOCKET_ERROR401 402 /* Get name of current host */403 extern PRStatus _PR_MD_GETHOSTNAME(char *name, PRUint32 namelen);404 #define _PR_MD_GETHOSTNAME _MD_GETHOSTNAME405 406 145 PR_END_EXTERN_C 407 146 -
trunk/src/libs/xpcom18a4/nsprpub/pr/src/misc/prinit.c
r102211 r102215 70 70 _PR_InitClock(); 71 71 72 _PR_InitThreads(PR_USER_THREAD, PR_PRIORITY_NORMAL, 0);73 74 72 _PR_MD_FINAL_INIT(); 75 73 }
Note:
See TracChangeset
for help on using the changeset viewer.