os/libc/pthread.c

18 lines
431 B
C
Raw Normal View History

2020-07-22 07:33:44 -05:00
#include <pthread.h>
#include <stddef.h>
#include <sys/syscalls.h>
2020-07-22 19:35:23 -05:00
2020-07-22 07:33:44 -05:00
#define QUAUX(X) #X
#define QU(X) QUAUX(X)
int pthread_create(pthread_t *restrict thread, const pthread_attr_t *restrict attr, void *(*start_routine)(void*), void *restrict arg) {
if (thread==NULL) {
return 1;
}
asm volatile(" \
mov $" QU(SYSCALL_NEW_THREAD) ", %%eax; \
int $80; \
"::"b"(start_routine),"c"(thread),"d"(arg));
return 0;
}