blob: 1e07ccd5d73f3d24d3acdbf6765d0be011030b33 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
/*
* exit.c
*
* Description:
* This translation unit implements routines associated with exiting from
* a thread.
*/
#include <windows.h>
#include <process.h>
#include "pthread.h"
#include "implement.h"
void
_pthread_vacuum(void)
{
/* This function can be called from pthread_exit(), or from
_pthread_start_call() in which case cleanupstack should be
empty but destructorstack still needs to be run. */
_pthread_threads_thread_t * this;
this = *_PTHREAD_THIS;
/* Run all the handlers. */
_pthread_handler_pop_all(&(this->cleanupstack), _PTHREAD_HANDLER_EXECUTE);
_pthread_handler_pop_all(&(this->destructorstack), _PTHREAD_HANDLER_EXECUTE);
/* Pop any atfork handlers to free storage. */
_pthread_handler_pop_all(&(this->forkprepare), _PTHREAD_HANDLER_NOEXECUTE);
_pthread_handler_pop_all(&(this->forkparent), _PTHREAD_HANDLER_NOEXECUTE);
_pthread_handler_pop_all(&(this->forkchild), _PTHREAD_HANDLER_NOEXECUTE);
_pthread_delete_thread_entry(NULL);
}
void
pthread_exit(void * value)
{
_pthread_threads_thread_t * this;
this = _PTHREAD_THIS;
if (this->joinvalueptr != NULL)
{
*(this->joinvalueptr) = value;
}
/* FIXME: More to do here. IE, if pthread_detach() was called
and value != NULL, do we free(value)? */
longjmp(this->call.env, 1);
}
|