* Christmas edition *; fixed irc /os command; small cleanup in fd.c; improvements...
[ZeXOS.git] / libpthread / create.c
blobbd5d47e517ae9ffe026e4a482858cf7a62140b4a
1 /*
2 * ZeX/OS
3 * Copyright (C) 2008 Tomas 'ZeXx86' Jedrzejek (zexx86@gmail.com)
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 #include <pthread.h>
23 int pthread_create (pthread_t *thread, const pthread_attr_t *attr, void *(*start_routine) (void *), void *arg)
25 unsigned *memptr = (unsigned *) 0x9050;
26 *memptr = (unsigned) arg;
28 asm volatile (
29 "movl $50, %%eax;"
30 "movl %0, %%ebx;"
31 "int $0x80;" :: "b" (start_routine) : "%eax", "memory");
33 unsigned *ret = memptr;
35 if (!ret)
36 return -1;
38 thread->start_routine = start_routine;
39 thread->arg = arg;
40 thread->attr = (pthread_attr_t *) attr;
42 if (*ret == 1)
43 return 0;
45 return -1;