-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsingle-pthread.h
More file actions
42 lines (36 loc) · 874 Bytes
/
Copy pathsingle-pthread.h
File metadata and controls
42 lines (36 loc) · 874 Bytes
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
#ifndef SINGLE_PTHREAD_H
#define SINGLE_PTHREAD_H
#include <sys/user.h>
#include <ucontext.h>
#include <unistd.h>
#include <syscall.h>
#include <stdlib.h>
#include <stdint.h>
/**
* signal.h tries to import pthread types, don't let it
*/
#ifdef __USE_POSIX199506 // No pthread_t
#undef __USE_POSIX199506
#endif
#ifdef __USE_UNIX98 // No pthread_t
#undef __USE_UNIX98
#endif
#ifndef __USE_MISC // For sigreturn
#define __USE_MISC
#endif
#include <signal.h>
typedef void *(*pthread_routine_t)(void*);
typedef struct {
pthread_routine_t routine;
void* arg;
void* retval;
ucontext_t ctx;
uint8_t running;
uint8_t done;
char* stackp;
} green_thread;
int pthread_create(pthread_t *restrict thread,
const void *restrict attr,
pthread_routine_t start_routine,
void *restrict arg);
#endif