#include "../../SDL_internal.h"
#include <pthread.h>
#include <signal.h>
#include "SDL_platform.h"
#include "SDL_thread.h"
#include "SDL_hints.h"
#include "../SDL_thread_c.h"
#include "../SDL_systhread.h"
#include "SDL_assert.h"
Go to the source code of this file.
Definition at line 87 of file SDL_systhread.c.
References SDL_Thread::handle, RunThread(), SDL_atoi, SDL_GetHint, SDL_HINT_THREAD_STACK_SIZE, SDL_SetError, and SDL_TRUE.
93 #if defined(__MACOSX__) || defined(__IPHONEOS__) || defined(__LINUX__) 94 if (!checked_setname) {
95 void *fn = dlsym(RTLD_DEFAULT,
"pthread_setname_np");
96 #if defined(__MACOSX__) || defined(__IPHONEOS__) 97 ppthread_setname_np = (int(*)(
const char*)) fn;
98 #elif defined(__LINUX__) 99 ppthread_setname_np = (int(*)(pthread_t,
const char*)) fn;
106 if (pthread_attr_init(&type) != 0) {
107 return SDL_SetError(
"Couldn't initialize pthread attributes");
109 pthread_attr_setdetachstate(&type, PTHREAD_CREATE_JOINABLE);
112 if (hint && hint[0] >=
'0' && hint[0] <=
'9') {
115 pthread_attr_setstacksize(&type, stacksize);
121 return SDL_SetError(
"Not enough resources to create thread");
#define SDL_HINT_THREAD_STACK_SIZE
A string specifying SDL's threads stack size in bytes or "0" for the backend's default size...
static void * RunThread(void *data)
GLuint GLuint GLsizei GLenum type
Definition at line 189 of file SDL_systhread.c.
References SDL_SetError, SDL_THREAD_PRIORITY_HIGH, and SDL_THREAD_PRIORITY_LOW.
204 if (setpriority(PRIO_PROCESS, syscall(SYS_gettid), value) < 0) {
212 struct sched_param sched;
214 pthread_t thread = pthread_self();
216 if (pthread_getschedparam(thread, &policy, &sched) < 0) {
220 sched.sched_priority = sched_get_priority_min(policy);
222 sched.sched_priority = sched_get_priority_max(policy);
224 int min_priority = sched_get_priority_min(policy);
225 int max_priority = sched_get_priority_max(policy);
226 sched.sched_priority = (min_priority + (max_priority - min_priority) / 2);
228 if (pthread_setschedparam(thread, policy, &sched) < 0) {
GLsizei const GLfloat * value
void SDL_SYS_SetupThread |
( |
const char * |
name | ) |
|
Definition at line 128 of file SDL_systhread.c.
References i, NULL, SDL_assert, SDL_snprintf, and sig_list.
130 #if !defined(__ANDROID__) && !defined(__NACL__) 136 #if defined(__MACOSX__) || defined(__IPHONEOS__) || defined(__LINUX__) 138 if (ppthread_setname_np !=
NULL) {
139 #if defined(__MACOSX__) || defined(__IPHONEOS__) 140 ppthread_setname_np(
name);
141 #elif defined(__LINUX__) 142 ppthread_setname_np(pthread_self(),
name);
145 #elif HAVE_PTHREAD_SETNAME_NP 146 #if defined(__NETBSD__) 147 pthread_setname_np(pthread_self(),
"%s",
name);
149 pthread_setname_np(pthread_self(),
name);
151 #elif HAVE_PTHREAD_SET_NAME_NP 152 pthread_set_name_np(pthread_self(),
name);
153 #elif defined(__HAIKU__) 155 char namebuf[B_OS_NAME_LENGTH];
157 namebuf[
sizeof (namebuf) - 1] =
'\0';
158 rename_thread(find_thread(
NULL), namebuf);
163 #if !defined(__ANDROID__) && !defined(__NACL__) 169 pthread_sigmask(SIG_BLOCK, &mask, 0);
173 #ifdef PTHREAD_CANCEL_ASYNCHRONOUS 177 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)
Get the thread identifier for the current thread.
Definition at line 183 of file SDL_systhread.c.
unsigned long SDL_threadID
Initial value:= {
SIGHUP, SIGINT, SIGQUIT, SIGPIPE, SIGALRM, SIGTERM, SIGCHLD, SIGWINCH,
SIGVTALRM, SIGPROF, 0
}
Definition at line 63 of file SDL_systhread.c.
Referenced by SDL_SYS_SetupThread().