aboutsummaryrefslogtreecommitdiff
path: root/src/lib9/ffork-pthread.c
blob: ff61ed1041f5f3237faa2d2b6ef6c86f013aa2d5 (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
#define NOPLAN9DEFINES
#include <u.h>
#include <libc.h>
#include <pthread.h>

extern int __isthreaded;
int
ffork(int flags, void(*fn)(void*), void *arg)
{
	pthread_t tid;

	if(flags != (RFMEM|RFNOWAIT)){
		werrstr("ffork unsupported");
		return -1;
	}

	if(pthread_create(&tid, NULL, (void*(*)(void*))fn, arg) < 0)
		return -1;
	return (int)tid;
}

int
getfforkid(void)
{
	return (int)pthread_self();
}