87
88
89
90
91
92
93
94
95
96
97
98
99
100
|
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
|
+
|
ClientData clientData; /* The one argument to Main() */
int stackSize; /* Size of stack for the new thread */
int flags; /* Flags controlling behaviour of
* the new thread */
{
#ifdef TCL_THREADS
pthread_attr_t attr;
pthread_t theThread;
int result;
pthread_attr_init(&attr);
pthread_attr_setscope(&attr, PTHREAD_SCOPE_SYSTEM);
#ifdef HAVE_PTHREAD_ATTR_SETSTACKSIZE
if (stackSize != TCL_THREAD_STACK_DEFAULT) {
|
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
|
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
|
-
+
-
+
+
|
}
#endif
if (! (flags & TCL_THREAD_JOINABLE)) {
pthread_attr_setdetachstate (&attr, PTHREAD_CREATE_DETACHED);
}
if (pthread_create((pthread_t *)idPtr, &attr,
if (pthread_create(&theThread, &attr,
(void * (*)())proc, (void *)clientData) &&
pthread_create((pthread_t *)idPtr, NULL,
pthread_create(&theThread, NULL,
(void * (*)())proc, (void *)clientData)) {
result = TCL_ERROR;
} else {
*idPtr = (Tcl_ThreadId)theThread;
result = TCL_OK;
}
pthread_attr_destroy(&attr);
return result;
#else
return TCL_ERROR;
#endif /* TCL_THREADS */
|