… | |
… | |
12 | |
12 | |
13 | #include <stddef.h> |
13 | #include <stddef.h> |
14 | #include <stdlib.h> |
14 | #include <stdlib.h> |
15 | #include <errno.h> |
15 | #include <errno.h> |
16 | #include <sys/types.h> |
16 | #include <sys/types.h> |
|
|
17 | #include <sys/socket.h> |
17 | #include <sys/stat.h> |
18 | #include <sys/stat.h> |
18 | #include <limits.h> |
19 | #include <limits.h> |
19 | #include <fcntl.h> |
20 | #include <fcntl.h> |
20 | #include <sched.h> |
21 | #include <sched.h> |
21 | |
22 | |
… | |
… | |
106 | #define expect_false(expr) expect ((expr) != 0, 0) |
107 | #define expect_false(expr) expect ((expr) != 0, 0) |
107 | #define expect_true(expr) expect ((expr) != 0, 1) |
108 | #define expect_true(expr) expect ((expr) != 0, 1) |
108 | |
109 | |
109 | /*****************************************************************************/ |
110 | /*****************************************************************************/ |
110 | |
111 | |
111 | #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 |
112 | |
127 | |
113 | #include "schmorp.h" |
128 | #include "schmorp.h" |
114 | |
129 | |
115 | #if HAVE_EVENTFD |
130 | #if HAVE_EVENTFD |
116 | # include <sys/eventfd.h> |
131 | # include <sys/eventfd.h> |
… | |
… | |
163 | # else |
178 | # else |
164 | # define MAP_ANONYMOUS MAP_FIXED /* and hope this fails */ |
179 | # define MAP_ANONYMOUS MAP_FIXED /* and hope this fails */ |
165 | # endif |
180 | # endif |
166 | #endif |
181 | #endif |
167 | |
182 | |
168 | /* defines all sorts of constants to 0 unless they are already defined */ |
|
|
169 | /* also provides const_iv_ and const_niv_ macros for them */ |
|
|
170 | #include "def0.h" |
|
|
171 | |
|
|
172 | #ifndef makedev |
183 | #ifndef makedev |
173 | # define makedev(maj,min) (((maj) << 8) | (min)) |
184 | # define makedev(maj,min) (((maj) << 8) | (min)) |
174 | #endif |
185 | #endif |
175 | #ifndef major |
186 | #ifndef major |
176 | # define major(dev) ((dev) >> 8) |
187 | # define major(dev) ((dev) >> 8) |
… | |
… | |
184 | #endif |
195 | #endif |
185 | |
196 | |
186 | /*****************************************************************************/ |
197 | /*****************************************************************************/ |
187 | |
198 | |
188 | #if !_POSIX_MAPPED_FILES |
199 | #if !_POSIX_MAPPED_FILES |
189 | # define mmap(addr,length,prot,flags,fd,offs) EIO_ENOSYS () |
200 | # define mmap(addr,length,prot,flags,fd,offs) (errno = ENOSYS, (void *)-1) |
190 | # define munmap(addr,length) EIO_ENOSYS () |
201 | # define munmap(addr,length) EIO_ENOSYS () |
191 | #endif |
202 | #endif |
192 | |
203 | |
193 | #if !_POSIX_MEMORY_PROTECTION |
204 | #if !_POSIX_MEMORY_PROTECTION |
194 | # define mprotect(addr,len,prot) EIO_ENOSYS () |
205 | # define mprotect(addr,len,prot) EIO_ENOSYS () |
… | |
… | |
275 | { |
286 | { |
276 | /* todo: iterate over magic and only free ours, but of course */ |
287 | /* todo: iterate over magic and only free ours, but of course */ |
277 | /* the perl5porters will call that (correct) behaviour buggy */ |
288 | /* the perl5porters will call that (correct) behaviour buggy */ |
278 | sv_unmagic (sv, FOREIGN_MAGIC); |
289 | sv_unmagic (sv, FOREIGN_MAGIC); |
279 | } |
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" |
280 | |
297 | |
281 | /*****************************************************************************/ |
298 | /*****************************************************************************/ |
282 | |
299 | |
283 | static void |
300 | static void |
284 | fiemap (eio_req *req) |
301 | fiemap (eio_req *req) |
… | |
… | |
1117 | |
1134 | |
1118 | const_iv (MREMAP_MAYMOVE) |
1135 | const_iv (MREMAP_MAYMOVE) |
1119 | const_iv (MREMAP_FIXED) |
1136 | const_iv (MREMAP_FIXED) |
1120 | |
1137 | |
1121 | const_iv (F_DUPFD_CLOEXEC) |
1138 | const_iv (F_DUPFD_CLOEXEC) |
|
|
1139 | |
|
|
1140 | const_iv (MSG_CMSG_CLOEXEC) |
|
|
1141 | const_iv (SOCK_CLOEXEC) |
1122 | |
1142 | |
1123 | const_iv (F_OFD_GETLK) |
1143 | const_iv (F_OFD_GETLK) |
1124 | const_iv (F_OFD_SETLK) |
1144 | const_iv (F_OFD_SETLK) |
1125 | const_iv (F_OFD_GETLKW) |
1145 | const_iv (F_OFD_GETLKW) |
1126 | |
1146 | |
… | |
… | |
1607 | 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); |
1608 | |
1628 | |
1609 | REQ_SEND; |
1629 | REQ_SEND; |
1610 | } |
1630 | } |
1611 | |
1631 | |
|
|
1632 | void |
|
|
1633 | stat_xtime () |
|
|
1634 | ALIAS: |
|
|
1635 | stat_atime = 1 |
|
|
1636 | stat_mtime = 2 |
|
|
1637 | stat_ctime = 4 |
|
|
1638 | stat_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 | stat_xtimensec () |
|
|
1647 | ALIAS: |
|
|
1648 | stat_atimensec = 1 |
|
|
1649 | stat_mtimensec = 2 |
|
|
1650 | stat_ctimensec = 4 |
|
|
1651 | stat_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 | |
1612 | UV |
1658 | UV |
1613 | major (UV dev) |
1659 | major (UV dev) |
1614 | ALIAS: |
1660 | ALIAS: |
1615 | minor = 1 |
1661 | minor = 1 |
1616 | CODE: |
1662 | CODE: |
… | |
… | |
2071 | munmap (SV *scalar) |
2117 | munmap (SV *scalar) |
2072 | CODE: |
2118 | CODE: |
2073 | sv_clear_foreign (scalar); |
2119 | sv_clear_foreign (scalar); |
2074 | |
2120 | |
2075 | SV * |
2121 | SV * |
2076 | 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) |
2077 | CODE: |
2123 | CODE: |
2078 | { |
2124 | { |
2079 | MAGIC *mg = mg_findext (scalar, FOREIGN_MAGIC, &mmap_vtbl); |
2125 | MAGIC *mg = mg_findext (scalar, FOREIGN_MAGIC, &mmap_vtbl); |
2080 | void *new; |
2126 | void *new; |
2081 | |
2127 | |