os/libc/pthread.c

17 lines
430 B
C
Raw Normal View History

2020-07-22 07:33:44 -05:00
#include <pthread.h>
#include <stddef.h>
#include <sys/syscalls.h>
#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;
}