#include "quakedef.h"
#include "thread.h"
#include <pthread.h>
#include <stdint.h>
Go to the source code of this file.
|
int | _Thread_CondBroadcast (void *cond, const char *filename, int fileline) |
|
int | _Thread_CondSignal (void *cond, const char *filename, int fileline) |
|
int | _Thread_CondWait (void *cond, void *mutex, const char *filename, int fileline) |
|
void * | _Thread_CreateBarrier (unsigned int count, const char *filename, int fileline) |
|
void * | _Thread_CreateCond (const char *filename, int fileline) |
|
void * | _Thread_CreateMutex (const char *filename, int fileline) |
|
void * | _Thread_CreateThread (int(*fn)(void *), void *data, const char *filename, int fileline) |
|
void | _Thread_DestroyBarrier (void *barrier, const char *filename, int fileline) |
|
void | _Thread_DestroyCond (void *cond, const char *filename, int fileline) |
|
void | _Thread_DestroyMutex (void *mutex, const char *filename, int fileline) |
|
int | _Thread_LockMutex (void *mutex, const char *filename, int fileline) |
|
int | _Thread_UnlockMutex (void *mutex, const char *filename, int fileline) |
|
void | _Thread_WaitBarrier (void *barrier, const char *filename, int fileline) |
|
int | _Thread_WaitThread (void *thread, int retval, const char *filename, int fileline) |
|
qbool | Thread_HasThreads (void) |
|
int | Thread_Init (void) |
|
void | Thread_Shutdown (void) |
|
◆ __USE_UNIX98
◆ _Thread_CondBroadcast()
int _Thread_CondBroadcast |
( |
void * | cond, |
|
|
const char * | filename, |
|
|
int | fileline ) |
Definition at line 101 of file thread_pthread.c.
102{
103 pthread_cond_t *condp = (pthread_cond_t *) cond;
104#ifdef THREADDEBUG
105 Sys_Printf(
"%p cond broadcast %s:%i\n" , cond, filename, fileline);
106#endif
107 return pthread_cond_broadcast(condp);
108}
void Sys_Printf(const char *fmt,...)
used to report failures inside Con_Printf()
References Sys_Printf().
◆ _Thread_CondSignal()
int _Thread_CondSignal |
( |
void * | cond, |
|
|
const char * | filename, |
|
|
int | fileline ) |
Definition at line 92 of file thread_pthread.c.
93{
94 pthread_cond_t *condp = (pthread_cond_t *) cond;
95#ifdef THREADDEBUG
96 Sys_Printf(
"%p cond signal %s:%i\n" , cond, filename, fileline);
97#endif
98 return pthread_cond_signal(condp);
99}
References Sys_Printf().
◆ _Thread_CondWait()
int _Thread_CondWait |
( |
void * | cond, |
|
|
void * | mutex, |
|
|
const char * | filename, |
|
|
int | fileline ) |
Definition at line 110 of file thread_pthread.c.
111{
112 pthread_cond_t *condp = (pthread_cond_t *) cond;
113 pthread_mutex_t *mutexp = (pthread_mutex_t *) mutex;
114#ifdef THREADDEBUG
115 Sys_Printf(
"%p cond wait %s:%i\n" , cond, filename, fileline);
116#endif
117 return pthread_cond_wait(condp, mutexp);
118}
References Sys_Printf().
◆ _Thread_CreateBarrier()
void * _Thread_CreateBarrier |
( |
unsigned int | count, |
|
|
const char * | filename, |
|
|
int | fileline ) |
◆ _Thread_CreateCond()
void * _Thread_CreateCond |
( |
const char * | filename, |
|
|
int | fileline ) |
Definition at line 72 of file thread_pthread.c.
73{
74 pthread_cond_t *condp = (pthread_cond_t *)
Z_Malloc(
sizeof(pthread_cond_t));
75 pthread_cond_init(condp,
NULL);
76#ifdef THREADDEBUG
77 Sys_Printf(
"%p cond create %s:%i\n" , condp, filename, fileline);
78#endif
79 return condp;
80}
References NULL, Sys_Printf(), and Z_Malloc.
◆ _Thread_CreateMutex()
void * _Thread_CreateMutex |
( |
const char * | filename, |
|
|
int | fileline ) |
Definition at line 24 of file thread_pthread.c.
25{
26#ifdef THREADRECURSIVE
27 pthread_mutexattr_t attr;
28#endif
29 pthread_mutex_t *mutexp = (pthread_mutex_t *)
Z_Malloc(
sizeof(pthread_mutex_t));
30#ifdef THREADDEBUG
31 Sys_Printf(
"%p mutex create %s:%i\n" , mutexp, filename, fileline);
32#endif
33#ifdef THREADRECURSIVE
34 pthread_mutexattr_init(&attr);
35 pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
36 pthread_mutex_init(mutexp, &attr);
37 pthread_mutexattr_destroy(&attr);
38#else
39 pthread_mutex_init(mutexp,
NULL);
40#endif
41 return mutexp;
42}
References NULL, Sys_Printf(), and Z_Malloc.
◆ _Thread_CreateThread()
void * _Thread_CreateThread |
( |
int(* | fn )(void *), |
|
|
void * | data, |
|
|
const char * | filename, |
|
|
int | fileline ) |
Definition at line 120 of file thread_pthread.c.
121{
122 pthread_t *threadp = (pthread_t *)
Z_Malloc(
sizeof(pthread_t));
123#ifdef THREADDEBUG
124 Sys_Printf(
"%p thread create %s:%i\n" , threadp, filename, fileline);
125#endif
126 int r = pthread_create(threadp,
NULL, (
void * (*) (
void *)) fn,
data);
128 {
131 }
132 return threadp;
133}
GLsizeiptr const GLvoid * data
References data, NULL, r, Sys_Printf(), Z_Free, and Z_Malloc.
◆ _Thread_DestroyBarrier()
void _Thread_DestroyBarrier |
( |
void * | barrier, |
|
|
const char * | filename, |
|
|
int | fileline ) |
◆ _Thread_DestroyCond()
void _Thread_DestroyCond |
( |
void * | cond, |
|
|
const char * | filename, |
|
|
int | fileline ) |
Definition at line 82 of file thread_pthread.c.
83{
84 pthread_cond_t *condp = (pthread_cond_t *) cond;
85#ifdef THREADDEBUG
86 Sys_Printf(
"%p cond destroy %s:%i\n" , cond, filename, fileline);
87#endif
88 pthread_cond_destroy(condp);
90}
References Sys_Printf(), and Z_Free.
◆ _Thread_DestroyMutex()
void _Thread_DestroyMutex |
( |
void * | mutex, |
|
|
const char * | filename, |
|
|
int | fileline ) |
Definition at line 44 of file thread_pthread.c.
45{
46 pthread_mutex_t *mutexp = (pthread_mutex_t *) mutex;
47#ifdef THREADDEBUG
48 Sys_Printf(
"%p mutex destroy %s:%i\n", mutex, filename, fileline);
49#endif
50 pthread_mutex_destroy(mutexp);
52}
References Sys_Printf(), and Z_Free.
◆ _Thread_LockMutex()
int _Thread_LockMutex |
( |
void * | mutex, |
|
|
const char * | filename, |
|
|
int | fileline ) |
Definition at line 54 of file thread_pthread.c.
55{
56 pthread_mutex_t *mutexp = (pthread_mutex_t *) mutex;
57#ifdef THREADDEBUG
58 Sys_Printf(
"%p mutex lock %s:%i\n" , mutex, filename, fileline);
59#endif
60 return pthread_mutex_lock(mutexp);
61}
References Sys_Printf().
◆ _Thread_UnlockMutex()
int _Thread_UnlockMutex |
( |
void * | mutex, |
|
|
const char * | filename, |
|
|
int | fileline ) |
Definition at line 63 of file thread_pthread.c.
64{
65 pthread_mutex_t *mutexp = (pthread_mutex_t *) mutex;
66#ifdef THREADDEBUG
67 Sys_Printf(
"%p mutex unlock %s:%i\n" , mutex, filename, fileline);
68#endif
69 return pthread_mutex_unlock(mutexp);
70}
References Sys_Printf().
◆ _Thread_WaitBarrier()
void _Thread_WaitBarrier |
( |
void * | barrier, |
|
|
const char * | filename, |
|
|
int | fileline ) |
◆ _Thread_WaitThread()
int _Thread_WaitThread |
( |
void * | thread, |
|
|
int | retval, |
|
|
const char * | filename, |
|
|
int | fileline ) |
Definition at line 135 of file thread_pthread.c.
136{
137 pthread_t *threadp = (pthread_t *) thread;
138 void *status = (void *) (intptr_t) retval;
139#ifdef THREADDEBUG
140 Sys_Printf(
"%p thread wait %s:%i\n" , thread, filename, fileline);
141#endif
142 pthread_join(*threadp, &status);
144 return (int) (intptr_t) status;
145}
References Sys_Printf(), and Z_Free.
◆ Thread_HasThreads()
◆ Thread_Init()
◆ Thread_Shutdown()