summaryrefslogtreecommitdiff
path: root/tests/self2.c
blob: 51cc129b36a0dd76e4b7a75085d370244ac034ac (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
#include <pthread.h>
/* Hack. Peer into implementation details. */
#include <implement.h>
#include <assert.h>
#include <stdio.h>

void *
entry(void * arg)
{
  /* Like systems such as HP-UX, we can't print the value of the thread ID
     because it's not an integral type. Instead, we'll poke our noses into
     the pthread_t structure and dump a useful internal value. This is
     ordinarily bad, m'kay? */

  pthread_t t = pthread_self();
  printf("my thread is %lx\n", t->win32handle); 
  return arg;
}

int
main()
{
  int rc;
  pthread_t t;

  if (pthread_create(&t, NULL, entry, NULL) != 0)
    {
      return 1;
    }

  Sleep(2000);

  /* Success. */
  return 0;
}