summaryrefslogtreecommitdiffstats
path: root/nsprpub/pr/include/md/_nspr_pthread.h
diff options
context:
space:
mode:
Diffstat (limited to 'nsprpub/pr/include/md/_nspr_pthread.h')
-rw-r--r--nsprpub/pr/include/md/_nspr_pthread.h170
1 files changed, 85 insertions, 85 deletions
diff --git a/nsprpub/pr/include/md/_nspr_pthread.h b/nsprpub/pr/include/md/_nspr_pthread.h
index 7af442cc8..01796e772 100644
--- a/nsprpub/pr/include/md/_nspr_pthread.h
+++ b/nsprpub/pr/include/md/_nspr_pthread.h
@@ -11,79 +11,79 @@
#if defined(PTHREADS_USER)
/*
-** Thread Local Storage
+** Thread Local Storage
*/
extern pthread_key_t current_thread_key;
extern pthread_key_t current_cpu_key;
extern pthread_key_t last_thread_key;
extern pthread_key_t intsoff_key;
-#define _MD_CURRENT_THREAD() \
- ((struct PRThread *) pthread_getspecific(current_thread_key))
-#define _MD_CURRENT_CPU() \
- ((struct _PRCPU *) pthread_getspecific(current_cpu_key))
-#define _MD_LAST_THREAD() \
- ((struct PRThread *) pthread_getspecific(last_thread_key))
-
-#define _MD_SET_CURRENT_THREAD(newval) \
- pthread_setspecific(current_thread_key, (void *)newval)
+#define _MD_CURRENT_THREAD() \
+ ((struct PRThread *) pthread_getspecific(current_thread_key))
+#define _MD_CURRENT_CPU() \
+ ((struct _PRCPU *) pthread_getspecific(current_cpu_key))
+#define _MD_LAST_THREAD() \
+ ((struct PRThread *) pthread_getspecific(last_thread_key))
-#define _MD_SET_CURRENT_CPU(newval) \
- pthread_setspecific(current_cpu_key, (void *)newval)
+#define _MD_SET_CURRENT_THREAD(newval) \
+ pthread_setspecific(current_thread_key, (void *)newval)
-#define _MD_SET_LAST_THREAD(newval) \
- pthread_setspecific(last_thread_key, (void *)newval)
+#define _MD_SET_CURRENT_CPU(newval) \
+ pthread_setspecific(current_cpu_key, (void *)newval)
+
+#define _MD_SET_LAST_THREAD(newval) \
+ pthread_setspecific(last_thread_key, (void *)newval)
#define _MD_SET_INTSOFF(_val)
-#define _MD_GET_INTSOFF() 1
-
+#define _MD_GET_INTSOFF() 1
+
/*
** Initialize the thread context preparing it to execute _main.
*/
-#define _MD_INIT_CONTEXT(_thread, _sp, _main, status) \
- PR_BEGIN_MACRO \
- *status = PR_TRUE; \
- if (SAVE_CONTEXT(_thread)) { \
- (*_main)(); \
- } \
- _MD_SET_THR_SP(_thread, _sp); \
- _thread->no_sched = 0; \
+#define _MD_INIT_CONTEXT(_thread, _sp, _main, status) \
+ PR_BEGIN_MACRO \
+ *status = PR_TRUE; \
+ if (SAVE_CONTEXT(_thread)) { \
+ (*_main)(); \
+ } \
+ _MD_SET_THR_SP(_thread, _sp); \
+ _thread->no_sched = 0; \
PR_END_MACRO
-#define _MD_SWITCH_CONTEXT(_thread) \
- PR_BEGIN_MACRO \
- PR_ASSERT(_thread->no_sched); \
- if (!SAVE_CONTEXT(_thread)) { \
- (_thread)->md.errcode = errno; \
- _MD_SET_LAST_THREAD(_thread); \
- _PR_Schedule(); \
- } else { \
- (_MD_LAST_THREAD())->no_sched = 0; \
- } \
+#define _MD_SWITCH_CONTEXT(_thread) \
+ PR_BEGIN_MACRO \
+ PR_ASSERT(_thread->no_sched); \
+ if (!SAVE_CONTEXT(_thread)) { \
+ (_thread)->md.errcode = errno; \
+ _MD_SET_LAST_THREAD(_thread); \
+ _PR_Schedule(); \
+ } else { \
+ (_MD_LAST_THREAD())->no_sched = 0; \
+ } \
PR_END_MACRO
/*
** Restore a thread context, saved by _MD_SWITCH_CONTEXT
*/
-#define _MD_RESTORE_CONTEXT(_thread) \
- PR_BEGIN_MACRO \
- errno = (_thread)->md.errcode; \
- _MD_SET_CURRENT_THREAD(_thread); \
- _thread->no_sched = 1; \
- GOTO_CONTEXT(_thread); \
+#define _MD_RESTORE_CONTEXT(_thread) \
+ PR_BEGIN_MACRO \
+ errno = (_thread)->md.errcode; \
+ _MD_SET_CURRENT_THREAD(_thread); \
+ _thread->no_sched = 1; \
+ GOTO_CONTEXT(_thread); \
PR_END_MACRO
/* Machine-dependent (MD) data structures */
struct _MDThread {
- jmp_buf jb;
- int id;
- int errcode;
- pthread_t pthread;
- pthread_mutex_t pthread_mutex;
- pthread_cond_t pthread_cond;
- int wait;
+ jmp_buf jb;
+ int id;
+ int errcode;
+ pthread_t pthread;
+ pthread_mutex_t pthread_mutex;
+ pthread_cond_t pthread_cond;
+ int wait;
};
struct _MDThreadStack {
@@ -91,7 +91,7 @@ struct _MDThreadStack {
};
struct _MDLock {
- pthread_mutex_t mutex;
+ pthread_mutex_t mutex;
};
struct _MDSemaphore {
@@ -99,7 +99,7 @@ struct _MDSemaphore {
};
struct _MDCVar {
- pthread_mutex_t mutex;
+ pthread_mutex_t mutex;
};
struct _MDSegment {
@@ -119,33 +119,33 @@ struct _MDCPU_Unix {
#ifndef _PR_USE_POLL
fd_set fd_read_set, fd_write_set, fd_exception_set;
PRInt16 fd_read_cnt[_PR_MD_MAX_OSFD],fd_write_cnt[_PR_MD_MAX_OSFD],
- fd_exception_cnt[_PR_MD_MAX_OSFD];
+ fd_exception_cnt[_PR_MD_MAX_OSFD];
#else
- struct pollfd *ioq_pollfds;
- int ioq_pollfds_size;
-#endif /* _PR_USE_POLL */
+ struct pollfd *ioq_pollfds;
+ int ioq_pollfds_size;
+#endif /* _PR_USE_POLL */
};
-#define _PR_IOQ(_cpu) ((_cpu)->md.md_unix.ioQ)
+#define _PR_IOQ(_cpu) ((_cpu)->md.md_unix.ioQ)
#define _PR_ADD_TO_IOQ(_pq, _cpu) PR_APPEND_LINK(&_pq.links, &_PR_IOQ(_cpu))
-#define _PR_FD_READ_SET(_cpu) ((_cpu)->md.md_unix.fd_read_set)
-#define _PR_FD_READ_CNT(_cpu) ((_cpu)->md.md_unix.fd_read_cnt)
-#define _PR_FD_WRITE_SET(_cpu) ((_cpu)->md.md_unix.fd_write_set)
-#define _PR_FD_WRITE_CNT(_cpu) ((_cpu)->md.md_unix.fd_write_cnt)
-#define _PR_FD_EXCEPTION_SET(_cpu) ((_cpu)->md.md_unix.fd_exception_set)
-#define _PR_FD_EXCEPTION_CNT(_cpu) ((_cpu)->md.md_unix.fd_exception_cnt)
-#define _PR_IOQ_TIMEOUT(_cpu) ((_cpu)->md.md_unix.ioq_timeout)
-#define _PR_IOQ_MAX_OSFD(_cpu) ((_cpu)->md.md_unix.ioq_max_osfd)
-#define _PR_IOQ_OSFD_CNT(_cpu) ((_cpu)->md.md_unix.ioq_osfd_cnt)
-#define _PR_IOQ_POLLFDS(_cpu) ((_cpu)->md.md_unix.ioq_pollfds)
-#define _PR_IOQ_POLLFDS_SIZE(_cpu) ((_cpu)->md.md_unix.ioq_pollfds_size)
-
-#define _PR_IOQ_MIN_POLLFDS_SIZE(_cpu) 32
+#define _PR_FD_READ_SET(_cpu) ((_cpu)->md.md_unix.fd_read_set)
+#define _PR_FD_READ_CNT(_cpu) ((_cpu)->md.md_unix.fd_read_cnt)
+#define _PR_FD_WRITE_SET(_cpu) ((_cpu)->md.md_unix.fd_write_set)
+#define _PR_FD_WRITE_CNT(_cpu) ((_cpu)->md.md_unix.fd_write_cnt)
+#define _PR_FD_EXCEPTION_SET(_cpu) ((_cpu)->md.md_unix.fd_exception_set)
+#define _PR_FD_EXCEPTION_CNT(_cpu) ((_cpu)->md.md_unix.fd_exception_cnt)
+#define _PR_IOQ_TIMEOUT(_cpu) ((_cpu)->md.md_unix.ioq_timeout)
+#define _PR_IOQ_MAX_OSFD(_cpu) ((_cpu)->md.md_unix.ioq_max_osfd)
+#define _PR_IOQ_OSFD_CNT(_cpu) ((_cpu)->md.md_unix.ioq_osfd_cnt)
+#define _PR_IOQ_POLLFDS(_cpu) ((_cpu)->md.md_unix.ioq_pollfds)
+#define _PR_IOQ_POLLFDS_SIZE(_cpu) ((_cpu)->md.md_unix.ioq_pollfds_size)
+
+#define _PR_IOQ_MIN_POLLFDS_SIZE(_cpu) 32
struct _MDCPU {
- jmp_buf jb;
- pthread_t pthread;
- struct _MDCPU_Unix md_unix;
+ jmp_buf jb;
+ pthread_t pthread;
+ struct _MDCPU_Unix md_unix;
};
/*
@@ -162,15 +162,15 @@ extern pthread_mutex_t _pr_heapLock;
#define _PR_UNLOCK(lock) pthread_mutex_unlock(lock)
-#define _PR_LOCK_HEAP() { \
- if (_pr_primordialCPU) { \
- _PR_LOCK(_pr_heapLock); \
- }
+#define _PR_LOCK_HEAP() { \
+ if (_pr_primordialCPU) { \
+ _PR_LOCK(_pr_heapLock); \
+ }
-#define _PR_UNLOCK_HEAP() if (_pr_primordialCPU) { \
- _PR_UNLOCK(_pr_heapLock); \
- } \
- }
+#define _PR_UNLOCK_HEAP() if (_pr_primordialCPU) { \
+ _PR_UNLOCK(_pr_heapLock); \
+ } \
+ }
NSPR_API(PRStatus) _MD_NEW_LOCK(struct _MDLock *md);
NSPR_API(void) _MD_FREE_LOCK(struct _MDLock *lockp);
@@ -219,12 +219,12 @@ NSPR_API(void) _MD_CleanThread(struct PRThread *thread);
#define _MD_CLEAN_THREAD _MD_CleanThread
NSPR_API(PRStatus) _MD_CreateThread(
- struct PRThread *thread,
- void (*start) (void *),
- PRThreadPriority priority,
- PRThreadScope scope,
- PRThreadState state,
- PRUint32 stackSize);
+ struct PRThread *thread,
+ void (*start) (void *),
+ PRThreadPriority priority,
+ PRThreadScope scope,
+ PRThreadState state,
+ PRUint32 stackSize);
#define _MD_CREATE_THREAD _MD_CreateThread
extern void _MD_CleanupBeforeExit(void);
@@ -243,7 +243,7 @@ NSPR_API(PRStatus) _MD_WakeupWaiter(struct PRThread *);
#define _MD_WAKEUP_WAITER _MD_WakeupWaiter
NSPR_API(void) _MD_SetPriority(struct _MDThread *thread,
- PRThreadPriority newPri);
+ PRThreadPriority newPri);
#define _MD_SET_PRIORITY _MD_SetPriority
#endif /* PTHREADS_USER */