comparison src/thread/pth/SDL_systhread.c @ 1668:4da1ee79c9af SDL-1.3

more tweaking indent options
author Sam Lantinga <slouken@libsdl.org>
date Mon, 29 May 2006 04:04:35 +0000
parents 782fd950bd46
children
comparison
equal deleted inserted replaced
1667:1fddae038bc8 1668:4da1ee79c9af
39 SIGHUP, SIGINT, SIGQUIT, SIGPIPE, SIGALRM, SIGTERM, SIGCHLD, SIGWINCH, 39 SIGHUP, SIGINT, SIGQUIT, SIGPIPE, SIGALRM, SIGTERM, SIGCHLD, SIGWINCH,
40 SIGVTALRM, SIGPROF, 0 40 SIGVTALRM, SIGPROF, 0
41 }; 41 };
42 42
43 static void * 43 static void *
44 RunThread (void *data) 44 RunThread(void *data)
45 { 45 {
46 SDL_RunThread (data); 46 SDL_RunThread(data);
47 pth_exit ((void *) 0); 47 pth_exit((void *) 0);
48 return ((void *) 0); /* Prevent compiler warning */ 48 return ((void *) 0); /* Prevent compiler warning */
49 } 49 }
50 50
51 int 51 int
52 SDL_SYS_CreateThread (SDL_Thread * thread, void *args) 52 SDL_SYS_CreateThread(SDL_Thread * thread, void *args)
53 { 53 {
54 pth_attr_t type; 54 pth_attr_t type;
55 55
56 /* Create a new attribute */ 56 /* Create a new attribute */
57 type = pth_attr_new (); 57 type = pth_attr_new();
58 if (type == NULL) { 58 if (type == NULL) {
59 SDL_SetError ("Couldn't initialize pth attributes"); 59 SDL_SetError("Couldn't initialize pth attributes");
60 return (-1); 60 return (-1);
61 } 61 }
62 pth_attr_set (type, PTH_ATTR_JOINABLE, TRUE); 62 pth_attr_set(type, PTH_ATTR_JOINABLE, TRUE);
63 63
64 /* Create the thread and go! */ 64 /* Create the thread and go! */
65 thread->handle = pth_spawn (type, RunThread, args); 65 thread->handle = pth_spawn(type, RunThread, args);
66 if (thread->handle == NULL) { 66 if (thread->handle == NULL) {
67 SDL_SetError ("Not enough resources to create thread"); 67 SDL_SetError("Not enough resources to create thread");
68 return (-1); 68 return (-1);
69 } 69 }
70 return (0); 70 return (0);
71 } 71 }
72 72
73 void 73 void
74 SDL_SYS_SetupThread (void) 74 SDL_SYS_SetupThread(void)
75 { 75 {
76 int i; 76 int i;
77 sigset_t mask; 77 sigset_t mask;
78 int oldstate; 78 int oldstate;
79 79
80 /* Mask asynchronous signals for this thread */ 80 /* Mask asynchronous signals for this thread */
81 sigemptyset (&mask); 81 sigemptyset(&mask);
82 for (i = 0; sig_list[i]; ++i) { 82 for (i = 0; sig_list[i]; ++i) {
83 sigaddset (&mask, sig_list[i]); 83 sigaddset(&mask, sig_list[i]);
84 } 84 }
85 pth_sigmask (SIG_BLOCK, &mask, 0); 85 pth_sigmask(SIG_BLOCK, &mask, 0);
86 86
87 /* Allow ourselves to be asynchronously cancelled */ 87 /* Allow ourselves to be asynchronously cancelled */
88 pth_cancel_state (PTH_CANCEL_ASYNCHRONOUS, &oldstate); 88 pth_cancel_state(PTH_CANCEL_ASYNCHRONOUS, &oldstate);
89 } 89 }
90 90
91 /* WARNING: This may not work for systems with 64-bit pid_t */ 91 /* WARNING: This may not work for systems with 64-bit pid_t */
92 Uint32 92 Uint32
93 SDL_ThreadID (void) 93 SDL_ThreadID(void)
94 { 94 {
95 return ((Uint32) pth_self ()); 95 return ((Uint32) pth_self());
96 } 96 }
97 97
98 void 98 void
99 SDL_SYS_WaitThread (SDL_Thread * thread) 99 SDL_SYS_WaitThread(SDL_Thread * thread)
100 { 100 {
101 pth_join (thread->handle, NULL); 101 pth_join(thread->handle, NULL);
102 } 102 }
103 103
104 void 104 void
105 SDL_SYS_KillThread (SDL_Thread * thread) 105 SDL_SYS_KillThread(SDL_Thread * thread)
106 { 106 {
107 pth_cancel (thread->handle); 107 pth_cancel(thread->handle);
108 pth_join (thread->handle, NULL); 108 pth_join(thread->handle, NULL);
109 } 109 }
110 110
111 /* vi: set ts=4 sw=4 expandtab: */ 111 /* vi: set ts=4 sw=4 expandtab: */