… | |
… | |
3 | #include <errno.h> |
3 | #include <errno.h> |
4 | |
4 | |
5 | #include "EXTERN.h" |
5 | #include "EXTERN.h" |
6 | #include "perl.h" |
6 | #include "perl.h" |
7 | #include "XSUB.h" |
7 | #include "XSUB.h" |
|
|
8 | |
|
|
9 | #if !defined mg_findext |
|
|
10 | # define mg_findext(sv,type,vtbl) mg_find (sv, type) |
|
|
11 | #endif |
8 | |
12 | |
9 | #include <stddef.h> |
13 | #include <stddef.h> |
10 | #include <stdlib.h> |
14 | #include <stdlib.h> |
11 | #include <errno.h> |
15 | #include <errno.h> |
12 | #include <sys/types.h> |
16 | #include <sys/types.h> |
|
|
17 | #include <sys/socket.h> |
13 | #include <sys/stat.h> |
18 | #include <sys/stat.h> |
14 | #include <limits.h> |
19 | #include <limits.h> |
15 | #include <fcntl.h> |
20 | #include <fcntl.h> |
16 | #include <sched.h> |
21 | #include <sched.h> |
17 | |
22 | |
… | |
… | |
102 | #define expect_false(expr) expect ((expr) != 0, 0) |
107 | #define expect_false(expr) expect ((expr) != 0, 0) |
103 | #define expect_true(expr) expect ((expr) != 0, 1) |
108 | #define expect_true(expr) expect ((expr) != 0, 1) |
104 | |
109 | |
105 | /*****************************************************************************/ |
110 | /*****************************************************************************/ |
106 | |
111 | |
107 | #include "libeio/config.h" |
112 | #include "config.h" |
|
|
113 | |
|
|
114 | #if HAVE_ST_XTIMENSEC |
|
|
115 | # define ATIMENSEC PL_statcache.st_atimensec |
|
|
116 | # define MTIMENSEC PL_statcache.st_mtimensec |
|
|
117 | # define CTIMENSEC PL_statcache.st_ctimensec |
|
|
118 | #elif HAVE_ST_XTIMESPEC |
|
|
119 | # define ATIMENSEC PL_statcache.st_atim.tv_nsec |
|
|
120 | # define MTIMENSEC PL_statcache.st_mtim.tv_nsec |
|
|
121 | # define CTIMENSEC PL_statcache.st_ctim.tv_nsec |
|
|
122 | #else |
|
|
123 | # define ATIMENSEC 0 |
|
|
124 | # define MTIMENSEC 0 |
|
|
125 | # define CTIMENSEC 0 |
|
|
126 | #endif |
108 | |
127 | |
109 | #include "schmorp.h" |
128 | #include "schmorp.h" |
110 | |
129 | |
111 | #if HAVE_EVENTFD |
130 | #if HAVE_EVENTFD |
112 | # include <sys/eventfd.h> |
131 | # include <sys/eventfd.h> |
… | |
… | |
159 | # else |
178 | # else |
160 | # define MAP_ANONYMOUS MAP_FIXED /* and hope this fails */ |
179 | # define MAP_ANONYMOUS MAP_FIXED /* and hope this fails */ |
161 | # endif |
180 | # endif |
162 | #endif |
181 | #endif |
163 | |
182 | |
164 | /* defines all sorts of constants to 0 unless they are already defined */ |
|
|
165 | /* also provides const_iv_ and const_niv_ macros for them */ |
|
|
166 | #include "def0.h" |
|
|
167 | |
|
|
168 | #ifndef makedev |
183 | #ifndef makedev |
169 | # define makedev(maj,min) (((maj) << 8) | (min)) |
184 | # define makedev(maj,min) (((maj) << 8) | (min)) |
170 | #endif |
185 | #endif |
171 | #ifndef major |
186 | #ifndef major |
172 | # define major(dev) ((dev) >> 8) |
187 | # define major(dev) ((dev) >> 8) |
… | |
… | |
180 | #endif |
195 | #endif |
181 | |
196 | |
182 | /*****************************************************************************/ |
197 | /*****************************************************************************/ |
183 | |
198 | |
184 | #if !_POSIX_MAPPED_FILES |
199 | #if !_POSIX_MAPPED_FILES |
185 | # define mmap(addr,length,prot,flags,fd,offs) EIO_ENOSYS () |
200 | # define mmap(addr,length,prot,flags,fd,offs) (errno = ENOSYS, (void *)-1) |
186 | # define munmap(addr,length) EIO_ENOSYS () |
201 | # define munmap(addr,length) EIO_ENOSYS () |
187 | #endif |
202 | #endif |
188 | |
203 | |
189 | #if !_POSIX_MEMORY_PROTECTION |
204 | #if !_POSIX_MEMORY_PROTECTION |
190 | # define mprotect(addr,len,prot) EIO_ENOSYS () |
205 | # define mprotect(addr,len,prot) EIO_ENOSYS () |
… | |
… | |
271 | { |
286 | { |
272 | /* todo: iterate over magic and only free ours, but of course */ |
287 | /* todo: iterate over magic and only free ours, but of course */ |
273 | /* the perl5porters will call that (correct) behaviour buggy */ |
288 | /* the perl5porters will call that (correct) behaviour buggy */ |
274 | sv_unmagic (sv, FOREIGN_MAGIC); |
289 | sv_unmagic (sv, FOREIGN_MAGIC); |
275 | } |
290 | } |
|
|
291 | |
|
|
292 | /*****************************************************************************/ |
|
|
293 | |
|
|
294 | /* defines all sorts of constants to 0 unless they are already defined */ |
|
|
295 | /* also provides const_iv_ and const_niv_ macros for them */ |
|
|
296 | #include "def0.h" |
276 | |
297 | |
277 | /*****************************************************************************/ |
298 | /*****************************************************************************/ |
278 | |
299 | |
279 | static void |
300 | static void |
280 | fiemap (eio_req *req) |
301 | fiemap (eio_req *req) |
… | |
… | |
1038 | const_niv (MADV_RANDOM , POSIX_MADV_RANDOM) |
1059 | const_niv (MADV_RANDOM , POSIX_MADV_RANDOM) |
1039 | const_niv (MADV_WILLNEED , POSIX_MADV_WILLNEED) |
1060 | const_niv (MADV_WILLNEED , POSIX_MADV_WILLNEED) |
1040 | const_niv (MADV_DONTNEED , POSIX_MADV_DONTNEED) |
1061 | const_niv (MADV_DONTNEED , POSIX_MADV_DONTNEED) |
1041 | |
1062 | |
1042 | /* the second block will be 0 when missing */ |
1063 | /* the second block will be 0 when missing */ |
|
|
1064 | const_iv (O_ACCMODE) |
|
|
1065 | |
1043 | const_iv (O_RDONLY) |
1066 | const_iv (O_RDONLY) |
1044 | const_iv (O_WRONLY) |
1067 | const_iv (O_WRONLY) |
1045 | const_iv (O_RDWR) |
1068 | const_iv (O_RDWR) |
1046 | const_iv (O_CREAT) |
1069 | const_iv (O_CREAT) |
1047 | const_iv (O_TRUNC) |
1070 | const_iv (O_TRUNC) |
… | |
… | |
1111 | |
1134 | |
1112 | const_iv (MREMAP_MAYMOVE) |
1135 | const_iv (MREMAP_MAYMOVE) |
1113 | const_iv (MREMAP_FIXED) |
1136 | const_iv (MREMAP_FIXED) |
1114 | |
1137 | |
1115 | const_iv (F_DUPFD_CLOEXEC) |
1138 | const_iv (F_DUPFD_CLOEXEC) |
|
|
1139 | |
|
|
1140 | const_iv (MSG_CMSG_CLOEXEC) |
|
|
1141 | const_iv (SOCK_CLOEXEC) |
1116 | |
1142 | |
1117 | const_iv (F_OFD_GETLK) |
1143 | const_iv (F_OFD_GETLK) |
1118 | const_iv (F_OFD_SETLK) |
1144 | const_iv (F_OFD_SETLK) |
1119 | const_iv (F_OFD_GETLKW) |
1145 | const_iv (F_OFD_GETLKW) |
1120 | |
1146 | |
… | |
… | |
1601 | req_set_fh_or_path (req, ix, ix == EIO_STATVFS ? EIO_FSTATVFS : EIO_FSTAT, fh_or_path); |
1627 | req_set_fh_or_path (req, ix, ix == EIO_STATVFS ? EIO_FSTATVFS : EIO_FSTAT, fh_or_path); |
1602 | |
1628 | |
1603 | REQ_SEND; |
1629 | REQ_SEND; |
1604 | } |
1630 | } |
1605 | |
1631 | |
|
|
1632 | void |
|
|
1633 | st_xtime () |
|
|
1634 | ALIAS: |
|
|
1635 | st_atime = 1 |
|
|
1636 | st_mtime = 2 |
|
|
1637 | st_ctime = 4 |
|
|
1638 | st_xtime = 7 |
|
|
1639 | PPCODE: |
|
|
1640 | EXTEND (SP, 3); |
|
|
1641 | if (ix & 1) PUSHs (newSVnv (PL_statcache.st_atime + 1e-9 * ATIMENSEC)); |
|
|
1642 | if (ix & 2) PUSHs (newSVnv (PL_statcache.st_mtime + 1e-9 * MTIMENSEC)); |
|
|
1643 | if (ix & 4) PUSHs (newSVnv (PL_statcache.st_ctime + 1e-9 * CTIMENSEC)); |
|
|
1644 | |
|
|
1645 | void |
|
|
1646 | st_xtimensec () |
|
|
1647 | ALIAS: |
|
|
1648 | st_atimensec = 1 |
|
|
1649 | st_mtimensec = 2 |
|
|
1650 | st_ctimensec = 4 |
|
|
1651 | st_xtimensec = 7 |
|
|
1652 | PPCODE: |
|
|
1653 | EXTEND (SP, 3); |
|
|
1654 | if (ix & 1) PUSHs (newSViv (ATIMENSEC)); |
|
|
1655 | if (ix & 2) PUSHs (newSViv (MTIMENSEC)); |
|
|
1656 | if (ix & 4) PUSHs (newSViv (CTIMENSEC)); |
|
|
1657 | |
1606 | UV |
1658 | UV |
1607 | major (UV dev) |
1659 | major (UV dev) |
1608 | ALIAS: |
1660 | ALIAS: |
1609 | minor = 1 |
1661 | minor = 1 |
1610 | CODE: |
1662 | CODE: |
… | |
… | |
2065 | munmap (SV *scalar) |
2117 | munmap (SV *scalar) |
2066 | CODE: |
2118 | CODE: |
2067 | sv_clear_foreign (scalar); |
2119 | sv_clear_foreign (scalar); |
2068 | |
2120 | |
2069 | SV * |
2121 | SV * |
2070 | mremap (SV *scalar, STRLEN new_length, int flags = 0, IV new_address = 0) |
2122 | mremap (SV *scalar, STRLEN new_length, int flags = MREMAP_MAYMOVE, IV new_address = 0) |
2071 | CODE: |
2123 | CODE: |
2072 | { |
2124 | { |
2073 | MAGIC *mg = mg_findext (scalar, FOREIGN_MAGIC, &mmap_vtbl); |
2125 | MAGIC *mg = mg_findext (scalar, FOREIGN_MAGIC, &mmap_vtbl); |
2074 | void *new; |
2126 | void *new; |
2075 | |
2127 | |