summaryrefslogtreecommitdiff
path: root/exit.c
blob: 0778fc22e104ff16fbd157151766386fe0582044 (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
/*
 * 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_exit(void * value)
{
  int t;

  t = _pthread_getthreadindex(pthread_self());

  /* Run all the cleanup handlers */
  _pthread_do_cancellation(t);

  /* CRITICAL SECTION */
  pthread_mutex_lock(&_pthread_count_mutex);

  /* Frees attr and cleanupstack */
  free(_pthread_threads_table[t]->attr);

  _pthread_threads_table[t]->thread = NULL;

  pthread_mutex_unlock(&_pthread_count_mutex);
  /* END CRITICAL SECTION */

  _endthreadex((DWORD) value);
}