ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/Linux-Clone/Clone.xs
(Generate patch)

Comparing Linux-Clone/Clone.xs (file contents):
Revision 1.1 by root, Mon Nov 28 05:43:03 2011 UTC vs.
Revision 1.2 by root, Wed Aug 24 03:34:24 2016 UTC

6#include <sys/mman.h> 6#include <sys/mman.h>
7 7
8#undef _GNU_SOURCE 8#undef _GNU_SOURCE
9#define _GNU_SOURCE 9#define _GNU_SOURCE
10#include <sched.h> 10#include <sched.h>
11
12/* from schmorp.h */
13static int
14s_fileno (SV *fh, int wr)
15{
16 dTHX;
17 SvGETMAGIC (fh);
18
19 if (SvROK (fh))
20 {
21 fh = SvRV (fh);
22 SvGETMAGIC (fh);
23 }
24
25 if (SvTYPE (fh) == SVt_PVGV)
26 return PerlIO_fileno (wr ? IoOFP (sv_2io (fh)) : IoIFP (sv_2io (fh)));
27
28 if (SvOK (fh) && (SvIV (fh) >= 0) && (SvIV (fh) < 0x7fffffffL))
29 return SvIV (fh);
30
31 return -1;
32}
11 33
12static int 34static int
13clone_cb (void *arg) 35clone_cb (void *arg)
14{ 36{
15 dSP; 37 dSP;
98 const_iv (NEWPID) 120 const_iv (NEWPID)
99# endif 121# endif
100# ifdef CLONE_IO 122# ifdef CLONE_IO
101 const_iv (IO) 123 const_iv (IO)
102# endif 124# endif
125# ifdef CLONE_NEWCGROUP
126 const_iv (NEWCGROUP)
127# endif
103 }; 128 };
104 129
105 for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ > const_iv; civ--) 130 for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ > const_iv; civ--)
106 newCONSTSUB (stash, (char *)civ[-1].name, newSViv (civ[-1].iv)); 131 newCONSTSUB (stash, (char *)civ[-1].name, newSViv (civ[-1].iv));
107 132
108int 133int
109unshare (int flags)
110 CODE:
111 RETVAL = unshare (flags);
112 OUTPUT:
113 RETVAL
114
115int
116clone (SV *sub, IV stacksize, int flags, SV *ptid = 0, SV *tls = &PL_sv_undef) 134clone (SV *sub, IV stacksize, int flags, SV *ptid = 0, SV *tls = &PL_sv_undef)
117 CODE: 135 CODE:
118{ 136{
119 if (!stacksize) 137 if (!stacksize)
120 stacksize = 4 << 20; 138 stacksize = 4 << 20;
121 139
122 pid_t ptid_; 140 pid_t ptid_;
123 char *stack_ptr = mmap (0, stacksize, PROT_EXEC | PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS | MAP_GROWSDOWN | MAP_STACK, -1, 0); 141 char *stack_ptr = mmap (0, stacksize, PROT_EXEC | PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS | MAP_GROWSDOWN | MAP_STACK, -1, 0);
124 142
144 } 162 }
145} 163}
146 OUTPUT: 164 OUTPUT:
147 RETVAL 165 RETVAL
148 166
167int
168unshare (int flags)
169
170int
171setns (SV *fh_or_fd, int nstype = 0)
172 C_ARGS: s_fileno (fh_or_fd, 0), nstype

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines