source: trunk/sys/dietlibc/fork.c @ 327

Last change on this file since 327 was 1, checked in by alain, 8 years ago

First import

File size: 1.2 KB
RevLine 
[1]1/*
2   This file is part of AlmOS.
3 
4   AlmOS is free software; you can redistribute it and/or modify it
5   under the terms of the GNU General Public License as published by
6   the Free Software Foundation; either version 2 of the License, or
7   (at your option) any later version.
8 
9   AlmOS is distributed in the hope that it will be useful, but
10   WITHOUT ANY WARRANTY; without even the implied warranty of
11   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12   General Public License for more details.
13 
14   You should have received a copy of the GNU General Public License
15   along with AlmOS; if not, write to the Free Software Foundation,
16   Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17 
18   UPMC / LIP6 / SOC (c) 2010
19   Copyright Ghassan Almaless <ghassan.almaless@gmail.com>
20*/
21
22#include <errno.h>
23#include <sys/syscall.h>
24#include <cpu-syscall.h>
25#include <pthread.h>
26#include <unistd.h>
27
28pid_t fork(void)
29{
30  pid_t pid;
31  struct __pthread_tls_s *tls;
32
33  tls = cpu_get_tls();
34
35  pid = (pid_t) cpu_syscall((void*)__pthread_tls_get(tls,__PT_TLS_FORK_FLAGS),
36                            (void*)__pthread_tls_get(tls,__PT_TLS_FORK_CPUID),
37                            NULL,NULL,SYS_FORK);
38
39  if(pid == 0)
40          __pthread_tls_init(tls);
41 
42  return pid;
43}
44
Note: See TracBrowser for help on using the repository browser.