… | |
… | |
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> |
|
|
22 | |
|
|
23 | #if HAVE_SYS_SYSMACROS_H |
|
|
24 | # include <sys/sysmacros.h> |
|
|
25 | #endif |
21 | |
26 | |
22 | #if _POSIX_MEMLOCK || _POSIX_MEMLOCK_RANGE || _POSIX_MAPPED_FILES |
27 | #if _POSIX_MEMLOCK || _POSIX_MEMLOCK_RANGE || _POSIX_MAPPED_FILES |
23 | # include <sys/mman.h> |
28 | # include <sys/mman.h> |
24 | #endif |
29 | #endif |
25 | |
30 | |
… | |
… | |
106 | #define expect_false(expr) expect ((expr) != 0, 0) |
111 | #define expect_false(expr) expect ((expr) != 0, 0) |
107 | #define expect_true(expr) expect ((expr) != 0, 1) |
112 | #define expect_true(expr) expect ((expr) != 0, 1) |
108 | |
113 | |
109 | /*****************************************************************************/ |
114 | /*****************************************************************************/ |
110 | |
115 | |
111 | #include "libeio/config.h" |
116 | #include "config.h" |
|
|
117 | |
|
|
118 | #if HAVE_ST_XTIMENSEC |
|
|
119 | # define ATIMENSEC PL_statcache.st_atimensec |
|
|
120 | # define MTIMENSEC PL_statcache.st_mtimensec |
|
|
121 | # define CTIMENSEC PL_statcache.st_ctimensec |
|
|
122 | #elif HAVE_ST_XTIMESPEC |
|
|
123 | # define ATIMENSEC PL_statcache.st_atim.tv_nsec |
|
|
124 | # define MTIMENSEC PL_statcache.st_mtim.tv_nsec |
|
|
125 | # define CTIMENSEC PL_statcache.st_ctim.tv_nsec |
|
|
126 | #else |
|
|
127 | # define ATIMENSEC 0 |
|
|
128 | # define MTIMENSEC 0 |
|
|
129 | # define CTIMENSEC 0 |
|
|
130 | #endif |
112 | |
131 | |
113 | #include "schmorp.h" |
132 | #include "schmorp.h" |
114 | |
133 | |
115 | #if HAVE_EVENTFD |
134 | #if HAVE_EVENTFD |
116 | # include <sys/eventfd.h> |
135 | # include <sys/eventfd.h> |
… | |
… | |
163 | # else |
182 | # else |
164 | # define MAP_ANONYMOUS MAP_FIXED /* and hope this fails */ |
183 | # define MAP_ANONYMOUS MAP_FIXED /* and hope this fails */ |
165 | # endif |
184 | # endif |
166 | #endif |
185 | #endif |
167 | |
186 | |
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 |
187 | #ifndef makedev |
173 | # define makedev(maj,min) (((maj) << 8) | (min)) |
188 | # define makedev(maj,min) (((maj) << 8) | (min)) |
174 | #endif |
189 | #endif |
175 | #ifndef major |
190 | #ifndef major |
176 | # define major(dev) ((dev) >> 8) |
191 | # define major(dev) ((dev) >> 8) |
… | |
… | |
184 | #endif |
199 | #endif |
185 | |
200 | |
186 | /*****************************************************************************/ |
201 | /*****************************************************************************/ |
187 | |
202 | |
188 | #if !_POSIX_MAPPED_FILES |
203 | #if !_POSIX_MAPPED_FILES |
189 | # define mmap(addr,length,prot,flags,fd,offs) EIO_ENOSYS () |
204 | # define mmap(addr,length,prot,flags,fd,offs) (errno = ENOSYS, (void *)-1) |
190 | # define munmap(addr,length) EIO_ENOSYS () |
205 | # define munmap(addr,length) EIO_ENOSYS () |
191 | #endif |
206 | #endif |
192 | |
207 | |
193 | #if !_POSIX_MEMORY_PROTECTION |
208 | #if !_POSIX_MEMORY_PROTECTION |
194 | # define mprotect(addr,len,prot) EIO_ENOSYS () |
209 | # define mprotect(addr,len,prot) EIO_ENOSYS () |
… | |
… | |
275 | { |
290 | { |
276 | /* todo: iterate over magic and only free ours, but of course */ |
291 | /* todo: iterate over magic and only free ours, but of course */ |
277 | /* the perl5porters will call that (correct) behaviour buggy */ |
292 | /* the perl5porters will call that (correct) behaviour buggy */ |
278 | sv_unmagic (sv, FOREIGN_MAGIC); |
293 | sv_unmagic (sv, FOREIGN_MAGIC); |
279 | } |
294 | } |
|
|
295 | |
|
|
296 | /*****************************************************************************/ |
|
|
297 | |
|
|
298 | /* defines all sorts of constants to 0 unless they are already defined */ |
|
|
299 | /* also provides const_iv_ and const_niv_ macros for them */ |
|
|
300 | #include "def0.h" |
280 | |
301 | |
281 | /*****************************************************************************/ |
302 | /*****************************************************************************/ |
282 | |
303 | |
283 | static void |
304 | static void |
284 | fiemap (eio_req *req) |
305 | fiemap (eio_req *req) |
… | |
… | |
1117 | |
1138 | |
1118 | const_iv (MREMAP_MAYMOVE) |
1139 | const_iv (MREMAP_MAYMOVE) |
1119 | const_iv (MREMAP_FIXED) |
1140 | const_iv (MREMAP_FIXED) |
1120 | |
1141 | |
1121 | const_iv (F_DUPFD_CLOEXEC) |
1142 | const_iv (F_DUPFD_CLOEXEC) |
|
|
1143 | |
|
|
1144 | const_iv (MSG_CMSG_CLOEXEC) |
|
|
1145 | const_iv (SOCK_CLOEXEC) |
1122 | |
1146 | |
1123 | const_iv (F_OFD_GETLK) |
1147 | const_iv (F_OFD_GETLK) |
1124 | const_iv (F_OFD_SETLK) |
1148 | const_iv (F_OFD_SETLK) |
1125 | const_iv (F_OFD_GETLKW) |
1149 | const_iv (F_OFD_GETLKW) |
1126 | |
1150 | |
… | |
… | |
1607 | req_set_fh_or_path (req, ix, ix == EIO_STATVFS ? EIO_FSTATVFS : EIO_FSTAT, fh_or_path); |
1631 | req_set_fh_or_path (req, ix, ix == EIO_STATVFS ? EIO_FSTATVFS : EIO_FSTAT, fh_or_path); |
1608 | |
1632 | |
1609 | REQ_SEND; |
1633 | REQ_SEND; |
1610 | } |
1634 | } |
1611 | |
1635 | |
|
|
1636 | void |
|
|
1637 | st_xtime () |
|
|
1638 | ALIAS: |
|
|
1639 | st_atime = 1 |
|
|
1640 | st_mtime = 2 |
|
|
1641 | st_ctime = 4 |
|
|
1642 | st_xtime = 7 |
|
|
1643 | PPCODE: |
|
|
1644 | EXTEND (SP, 3); |
|
|
1645 | if (ix & 1) PUSHs (newSVnv (PL_statcache.st_atime + 1e-9 * ATIMENSEC)); |
|
|
1646 | if (ix & 2) PUSHs (newSVnv (PL_statcache.st_mtime + 1e-9 * MTIMENSEC)); |
|
|
1647 | if (ix & 4) PUSHs (newSVnv (PL_statcache.st_ctime + 1e-9 * CTIMENSEC)); |
|
|
1648 | |
|
|
1649 | void |
|
|
1650 | st_xtimensec () |
|
|
1651 | ALIAS: |
|
|
1652 | st_atimensec = 1 |
|
|
1653 | st_mtimensec = 2 |
|
|
1654 | st_ctimensec = 4 |
|
|
1655 | st_xtimensec = 7 |
|
|
1656 | PPCODE: |
|
|
1657 | EXTEND (SP, 3); |
|
|
1658 | if (ix & 1) PUSHs (newSViv (ATIMENSEC)); |
|
|
1659 | if (ix & 2) PUSHs (newSViv (MTIMENSEC)); |
|
|
1660 | if (ix & 4) PUSHs (newSViv (CTIMENSEC)); |
|
|
1661 | |
1612 | UV |
1662 | UV |
1613 | major (UV dev) |
1663 | major (UV dev) |
1614 | ALIAS: |
1664 | ALIAS: |
1615 | minor = 1 |
1665 | minor = 1 |
1616 | CODE: |
1666 | CODE: |
… | |
… | |
2071 | munmap (SV *scalar) |
2121 | munmap (SV *scalar) |
2072 | CODE: |
2122 | CODE: |
2073 | sv_clear_foreign (scalar); |
2123 | sv_clear_foreign (scalar); |
2074 | |
2124 | |
2075 | SV * |
2125 | SV * |
2076 | mremap (SV *scalar, STRLEN new_length, int flags = 0, IV new_address = 0) |
2126 | mremap (SV *scalar, STRLEN new_length, int flags = MREMAP_MAYMOVE, IV new_address = 0) |
2077 | CODE: |
2127 | CODE: |
2078 | { |
2128 | { |
2079 | MAGIC *mg = mg_findext (scalar, FOREIGN_MAGIC, &mmap_vtbl); |
2129 | MAGIC *mg = mg_findext (scalar, FOREIGN_MAGIC, &mmap_vtbl); |
2080 | void *new; |
2130 | void *new; |
2081 | |
2131 | |