… | |
… | |
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_MKDEV_H |
|
|
24 | # include <sys/mkdev.h> |
|
|
25 | #elif HAVE_SYS_SYSMACROS_H |
|
|
26 | # include <sys/sysmacros.h> |
|
|
27 | #endif |
21 | |
28 | |
22 | #if _POSIX_MEMLOCK || _POSIX_MEMLOCK_RANGE || _POSIX_MAPPED_FILES |
29 | #if _POSIX_MEMLOCK || _POSIX_MEMLOCK_RANGE || _POSIX_MAPPED_FILES |
23 | # include <sys/mman.h> |
30 | # include <sys/mman.h> |
24 | #endif |
31 | #endif |
25 | |
32 | |
… | |
… | |
106 | #define expect_false(expr) expect ((expr) != 0, 0) |
113 | #define expect_false(expr) expect ((expr) != 0, 0) |
107 | #define expect_true(expr) expect ((expr) != 0, 1) |
114 | #define expect_true(expr) expect ((expr) != 0, 1) |
108 | |
115 | |
109 | /*****************************************************************************/ |
116 | /*****************************************************************************/ |
110 | |
117 | |
111 | #include "libeio/config.h" |
118 | #include "config.h" |
|
|
119 | |
|
|
120 | #if HAVE_ST_XTIMENSEC |
|
|
121 | # define ATIMENSEC PL_statcache.st_atimensec |
|
|
122 | # define MTIMENSEC PL_statcache.st_mtimensec |
|
|
123 | # define CTIMENSEC PL_statcache.st_ctimensec |
|
|
124 | #elif HAVE_ST_XTIMESPEC |
|
|
125 | # define ATIMENSEC PL_statcache.st_atim.tv_nsec |
|
|
126 | # define MTIMENSEC PL_statcache.st_mtim.tv_nsec |
|
|
127 | # define CTIMENSEC PL_statcache.st_ctim.tv_nsec |
|
|
128 | #else |
|
|
129 | # define ATIMENSEC 0 |
|
|
130 | # define MTIMENSEC 0 |
|
|
131 | # define CTIMENSEC 0 |
|
|
132 | #endif |
112 | |
133 | |
113 | #include "schmorp.h" |
134 | #include "schmorp.h" |
114 | |
135 | |
115 | #if HAVE_EVENTFD |
136 | #if HAVE_EVENTFD |
116 | # include <sys/eventfd.h> |
137 | # include <sys/eventfd.h> |
… | |
… | |
163 | # else |
184 | # else |
164 | # define MAP_ANONYMOUS MAP_FIXED /* and hope this fails */ |
185 | # define MAP_ANONYMOUS MAP_FIXED /* and hope this fails */ |
165 | # endif |
186 | # endif |
166 | #endif |
187 | #endif |
167 | |
188 | |
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 |
189 | #ifndef makedev |
173 | # define makedev(maj,min) (((maj) << 8) | (min)) |
190 | # define makedev(maj,min) (((maj) << 8) | (min)) |
174 | #endif |
191 | #endif |
175 | #ifndef major |
192 | #ifndef major |
176 | # define major(dev) ((dev) >> 8) |
193 | # define major(dev) ((dev) >> 8) |
177 | #endif |
194 | #endif |
178 | #ifndef minor |
195 | #ifndef minor |
179 | # define minor(dev) ((dev) & 0xff) |
196 | # define minor(dev) ((dev) & 0xff) |
180 | #endif |
197 | #endif |
181 | |
198 | |
|
|
199 | /* solaris has a non-posix/unix compliant PAGESIZE that breaks compilation */ |
|
|
200 | #ifdef __sun |
|
|
201 | # undef PAGESIZE |
|
|
202 | #endif |
|
|
203 | |
182 | #if PAGESIZE <= 0 |
204 | #if PAGESIZE <= 0 |
183 | # define PAGESIZE sysconf (_SC_PAGESIZE) |
205 | # define PAGESIZE sysconf (_SC_PAGESIZE) |
184 | #endif |
206 | #endif |
185 | |
207 | |
186 | /*****************************************************************************/ |
208 | /*****************************************************************************/ |
187 | |
209 | |
188 | #if !_POSIX_MAPPED_FILES |
210 | #if !_POSIX_MAPPED_FILES |
189 | # define mmap(addr,length,prot,flags,fd,offs) EIO_ENOSYS () |
211 | # define mmap(addr,length,prot,flags,fd,offs) (errno = ENOSYS, (void *)-1) |
190 | # define munmap(addr,length) EIO_ENOSYS () |
212 | # define munmap(addr,length) EIO_ENOSYS () |
191 | #endif |
213 | #endif |
192 | |
214 | |
193 | #if !_POSIX_MEMORY_PROTECTION |
215 | #if !_POSIX_MEMORY_PROTECTION |
194 | # define mprotect(addr,len,prot) EIO_ENOSYS () |
216 | # define mprotect(addr,len,prot) EIO_ENOSYS () |
… | |
… | |
275 | { |
297 | { |
276 | /* todo: iterate over magic and only free ours, but of course */ |
298 | /* todo: iterate over magic and only free ours, but of course */ |
277 | /* the perl5porters will call that (correct) behaviour buggy */ |
299 | /* the perl5porters will call that (correct) behaviour buggy */ |
278 | sv_unmagic (sv, FOREIGN_MAGIC); |
300 | sv_unmagic (sv, FOREIGN_MAGIC); |
279 | } |
301 | } |
|
|
302 | |
|
|
303 | /*****************************************************************************/ |
|
|
304 | |
|
|
305 | /* defines all sorts of constants to 0 unless they are already defined */ |
|
|
306 | /* also provides const_iv_ and const_niv_ macros for them */ |
|
|
307 | #include "def0.h" |
280 | |
308 | |
281 | /*****************************************************************************/ |
309 | /*****************************************************************************/ |
282 | |
310 | |
283 | static void |
311 | static void |
284 | fiemap (eio_req *req) |
312 | fiemap (eio_req *req) |
… | |
… | |
1117 | |
1145 | |
1118 | const_iv (MREMAP_MAYMOVE) |
1146 | const_iv (MREMAP_MAYMOVE) |
1119 | const_iv (MREMAP_FIXED) |
1147 | const_iv (MREMAP_FIXED) |
1120 | |
1148 | |
1121 | const_iv (F_DUPFD_CLOEXEC) |
1149 | const_iv (F_DUPFD_CLOEXEC) |
|
|
1150 | |
|
|
1151 | const_iv (MSG_CMSG_CLOEXEC) |
|
|
1152 | const_iv (SOCK_CLOEXEC) |
1122 | |
1153 | |
1123 | const_iv (F_OFD_GETLK) |
1154 | const_iv (F_OFD_GETLK) |
1124 | const_iv (F_OFD_SETLK) |
1155 | const_iv (F_OFD_SETLK) |
1125 | const_iv (F_OFD_GETLKW) |
1156 | const_iv (F_OFD_GETLKW) |
1126 | |
1157 | |
… | |
… | |
1607 | req_set_fh_or_path (req, ix, ix == EIO_STATVFS ? EIO_FSTATVFS : EIO_FSTAT, fh_or_path); |
1638 | req_set_fh_or_path (req, ix, ix == EIO_STATVFS ? EIO_FSTATVFS : EIO_FSTAT, fh_or_path); |
1608 | |
1639 | |
1609 | REQ_SEND; |
1640 | REQ_SEND; |
1610 | } |
1641 | } |
1611 | |
1642 | |
|
|
1643 | void |
|
|
1644 | st_xtime () |
|
|
1645 | ALIAS: |
|
|
1646 | st_atime = 1 |
|
|
1647 | st_mtime = 2 |
|
|
1648 | st_ctime = 4 |
|
|
1649 | st_xtime = 7 |
|
|
1650 | PPCODE: |
|
|
1651 | EXTEND (SP, 3); |
|
|
1652 | if (ix & 1) PUSHs (newSVnv (PL_statcache.st_atime + 1e-9 * ATIMENSEC)); |
|
|
1653 | if (ix & 2) PUSHs (newSVnv (PL_statcache.st_mtime + 1e-9 * MTIMENSEC)); |
|
|
1654 | if (ix & 4) PUSHs (newSVnv (PL_statcache.st_ctime + 1e-9 * CTIMENSEC)); |
|
|
1655 | |
|
|
1656 | void |
|
|
1657 | st_xtimensec () |
|
|
1658 | ALIAS: |
|
|
1659 | st_atimensec = 1 |
|
|
1660 | st_mtimensec = 2 |
|
|
1661 | st_ctimensec = 4 |
|
|
1662 | st_xtimensec = 7 |
|
|
1663 | PPCODE: |
|
|
1664 | EXTEND (SP, 3); |
|
|
1665 | if (ix & 1) PUSHs (newSViv (ATIMENSEC)); |
|
|
1666 | if (ix & 2) PUSHs (newSViv (MTIMENSEC)); |
|
|
1667 | if (ix & 4) PUSHs (newSViv (CTIMENSEC)); |
|
|
1668 | |
1612 | UV |
1669 | UV |
1613 | major (UV dev) |
1670 | major (UV dev) |
1614 | ALIAS: |
1671 | ALIAS: |
1615 | minor = 1 |
1672 | minor = 1 |
1616 | CODE: |
1673 | CODE: |
… | |
… | |
2071 | munmap (SV *scalar) |
2128 | munmap (SV *scalar) |
2072 | CODE: |
2129 | CODE: |
2073 | sv_clear_foreign (scalar); |
2130 | sv_clear_foreign (scalar); |
2074 | |
2131 | |
2075 | SV * |
2132 | SV * |
2076 | mremap (SV *scalar, STRLEN new_length, int flags = 0, IV new_address = 0) |
2133 | mremap (SV *scalar, STRLEN new_length, int flags = MREMAP_MAYMOVE, IV new_address = 0) |
2077 | CODE: |
2134 | CODE: |
2078 | { |
2135 | { |
2079 | MAGIC *mg = mg_findext (scalar, FOREIGN_MAGIC, &mmap_vtbl); |
2136 | MAGIC *mg = mg_findext (scalar, FOREIGN_MAGIC, &mmap_vtbl); |
2080 | void *new; |
2137 | void *new; |
2081 | |
2138 | |