#include "../../SDL_internal.h"
#include <pthread.h>
#include <signal.h>
#include "SDL_platform.h"
#include "SDL_thread.h"
#include "../SDL_thread_c.h"
#include "../SDL_systhread.h"
#include "SDL_assert.h"
Go to the source code of this file.
◆ RunThread()
◆ SDL_SYS_CreateThread()
Definition at line 86 of file SDL_systhread.c.
References SDL_Thread::handle, RunThread(), SDL_SetError, SDL_TRUE, and SDL_Thread::stacksize.
91 #if defined(__MACOSX__) || defined(__IPHONEOS__) || defined(__LINUX__) 92 if (!checked_setname) {
93 void *fn = dlsym(RTLD_DEFAULT,
"pthread_setname_np");
94 #if defined(__MACOSX__) || defined(__IPHONEOS__) 95 ppthread_setname_np = (int(*)(
const char*)) fn;
96 #elif defined(__LINUX__) 97 ppthread_setname_np = (int(*)(pthread_t,
const char*)) fn;
104 if (pthread_attr_init(&type) != 0) {
105 return SDL_SetError(
"Couldn't initialize pthread attributes");
107 pthread_attr_setdetachstate(&type, PTHREAD_CREATE_JOINABLE);
111 pthread_attr_setstacksize(&type, (
size_t) thread->
stacksize);
116 return SDL_SetError(
"Not enough resources to create thread");
static void * RunThread(void *data)
GLuint GLuint GLsizei GLenum type
◆ SDL_SYS_DetachThread()
◆ SDL_SYS_SetThreadPriority()
Definition at line 184 of file SDL_systhread.c.
References SDL_SetError, SDL_THREAD_PRIORITY_HIGH, and SDL_THREAD_PRIORITY_LOW.
199 if (setpriority(PRIO_PROCESS, syscall(SYS_gettid), value) < 0) {
211 struct sched_param sched;
213 pthread_t thread = pthread_self();
215 if (pthread_getschedparam(thread, &policy, &sched) != 0) {
219 sched.sched_priority = sched_get_priority_min(policy);
221 sched.sched_priority = sched_get_priority_max(policy);
223 int min_priority = sched_get_priority_min(policy);
224 int max_priority = sched_get_priority_max(policy);
225 sched.sched_priority = (min_priority + (max_priority - min_priority) / 2);
227 if (pthread_setschedparam(thread, policy, &sched) != 0) {
GLsizei const GLfloat * value
◆ SDL_SYS_SetupThread()
void SDL_SYS_SetupThread |
( |
const char * |
name | ) |
|
Definition at line 123 of file SDL_systhread.c.
References i, NULL, SDL_assert, SDL_snprintf, and sig_list.
125 #if !defined(__NACL__) 131 #if defined(__MACOSX__) || defined(__IPHONEOS__) || defined(__LINUX__) 133 if (ppthread_setname_np !=
NULL) {
134 #if defined(__MACOSX__) || defined(__IPHONEOS__) 135 ppthread_setname_np(
name);
136 #elif defined(__LINUX__) 137 ppthread_setname_np(pthread_self(),
name);
140 #elif HAVE_PTHREAD_SETNAME_NP 141 #if defined(__NETBSD__) 142 pthread_setname_np(pthread_self(),
"%s",
name);
144 pthread_setname_np(pthread_self(),
name);
146 #elif HAVE_PTHREAD_SET_NAME_NP 147 pthread_set_name_np(pthread_self(),
name);
148 #elif defined(__HAIKU__) 150 char namebuf[B_OS_NAME_LENGTH];
152 namebuf[
sizeof (namebuf) - 1] =
'\0';
153 rename_thread(find_thread(
NULL), namebuf);
158 #if !defined(__NACL__) 164 pthread_sigmask(SIG_BLOCK, &mask, 0);
168 #ifdef PTHREAD_CANCEL_ASYNCHRONOUS 172 pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, &oldstate);
GLuint const GLchar * name
static const int sig_list[]
return Display return Display Bool Bool int int int return Display XEvent Bool(*) XPointer return Display return Display Drawable _Xconst char unsigned int unsigned int return Display Pixmap Pixmap XColor XColor unsigned int unsigned int return Display _Xconst char char int char return Display Visual unsigned int int int char unsigned int unsigned int in i)
#define SDL_assert(condition)
◆ SDL_SYS_WaitThread()
◆ SDL_ThreadID()
Get the thread identifier for the current thread.
Definition at line 178 of file SDL_systhread.c.
unsigned long SDL_threadID
◆ sig_list
Initial value:= {
SIGHUP, SIGINT, SIGQUIT, SIGPIPE, SIGALRM, SIGTERM, SIGCHLD, SIGWINCH,
SIGVTALRM, SIGPROF, 0
}
Definition at line 62 of file SDL_systhread.c.
Referenced by SDL_SYS_SetupThread().