ready for tagging
[util-vserver.git] / lib_internal / sys_unshare.h
1 // $Id$    --*- c -*--
2
3 // Copyright (C) 2007 Daniel Hokka Zakrisson
4 //  
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; version 2 of the License.
8 //  
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 // GNU General Public License for more details.
13 //  
14 // You should have received a copy of the GNU General Public License
15 // along with this program; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17
18
19 #ifndef H_UTIL_VSERVER_SRC_SYS_UNSHARE_H
20 #define H_UTIL_VSERVER_SRC_SYS_UNSHARE_H
21
22 #include <unistd.h>
23 #include "lib/syscall-wrap.h"
24
25 #ifndef __NR_unshare
26 #  if defined(__alpha__)
27 #    define __NR_unshare        465
28 #  elif defined(__arm__)
29 #    define __NR_unshare        337
30 #  elif defined(__avr32__)
31 #    define __NR_unshare        258
32 #  elif defined(__blackfin__)
33 #    define __NR_unshare        310
34 #  elif defined(__frv__)
35 #    define __NR_unshare        310
36 #  elif defined(__h8300__)
37 #    define __NR_unshare        310
38 #  elif defined(__i386__)
39 #    define __NR_unshare        310
40 #  elif defined(__ia64__)
41 #    define __NR_unshare        1296
42 #  elif defined(__m68knommu__)
43 #    define __NR_unshare        303
44 #  elif defined(__m68k__)
45 #    define __NR_unshare        303
46 #  elif defined(__mips__) && (_MIPS_SIM == _MIPS_SIM_ABI32)
47 #    define __NR_unshare        303
48 #  elif defined(__mips__) && (_MIPS_SIM == _MIPS_SIM_ABI64)
49 #    define __NR_unshare        262
50 #  elif defined(__mips__) && (_MIPS_SIM == _MIPS_SIM_NABI32)
51 #    define __NR_unshare        266
52 #  elif defined(__parisc__)
53 #    define __NR_unshare        288
54 #  elif defined(__powerpc__)
55 #    define __NR_unshare        282
56 #  elif defined(__s390__)
57 #    define __NR_unshare        303
58 #  elif defined(__sh64__)
59 #    define __NR_unshare        338
60 #  elif defined(__sh__)
61 #    define __NR_unshare        310
62 #  elif defined(__sparc64__)
63 #    define __NR_unshare        299
64 #  elif defined(__sparc__)
65 #    define __NR_unshare        299
66 #  elif defined(__x86_64__)
67 #    define __NR_unshare        272
68 #  else
69 #    error Sorry, don't know unshare's syscall number for this architecture.
70 #  endif
71 #endif
72
73 #define __NR_sys_unshare        __NR_unshare
74
75 #ifndef ENSC_SYSCALL_TRADITIONAL
76 #  include <errno.h>
77
78 inline static UNUSED ALWAYSINLINE
79 _syscall1(int, sys_unshare, int, flags)
80 #else
81 inline static UNUSED ALWAYSINLINE
82 int sys_unshare(int flags)
83 {
84   return syscall(__NR_sys_clone, flags);
85 }
86 #endif
87
88 #undef __NR_sys_unshare
89
90 #define ENSC_HAVE_SYSUNSHARE            1
91   
92 #endif  //  H_UTIL_VSERVER_SRC_SYS_UNSHARE_H