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

Comparing IO-AIO/AIO.xs (file contents):
Revision 1.253 by root, Tue Feb 20 04:32:59 2018 UTC vs.
Revision 1.254 by root, Tue Feb 20 05:23:47 2018 UTC

110 110
111#if HAVE_EVENTFD 111#if HAVE_EVENTFD
112# include <sys/eventfd.h> 112# include <sys/eventfd.h>
113#endif 113#endif
114 114
115#if HAVE_TIMERFD
116# include <sys/timerfd.h>
117#endif
118
115#if HAVE_RLIMITS 119#if HAVE_RLIMITS
116 #include <sys/time.h> 120 #include <sys/time.h>
117 #include <sys/resource.h> 121 #include <sys/resource.h>
118#endif 122#endif
119 123
972 req->type = type_path; 976 req->type = type_path;
973 req_set_path1 (req, fh_or_path); 977 req_set_path1 (req, fh_or_path);
974 break; 978 break;
975 } 979 }
976} 980}
981
982/*****************************************************************************/
983
984static void
985ts_set (struct timespec *ts, NV value)
986{
987 ts->tv_sec = value;
988 ts->tv_nsec = (value - ts->tv_sec) * 1e9;
989}
990
991static NV
992ts_get (const struct timespec *ts)
993{
994 return ts->tv_sec + ts->tv_nsec * 1e-9;
995}
996
997/*****************************************************************************/
977 998
978XS(boot_IO__AIO) ecb_cold; 999XS(boot_IO__AIO) ecb_cold;
979 1000
980MODULE = IO::AIO PACKAGE = IO::AIO 1001MODULE = IO::AIO PACKAGE = IO::AIO
981 1002
1169 1190
1170 const_iv (EFD_CLOEXEC) 1191 const_iv (EFD_CLOEXEC)
1171 const_iv (EFD_NONBLOCK) 1192 const_iv (EFD_NONBLOCK)
1172 const_iv (EFD_SEMAPHORE) 1193 const_iv (EFD_SEMAPHORE)
1173 1194
1195 const_iv (CLOCK_REALTIME)
1196 const_iv (CLOCK_MONOTONIC)
1197 const_iv (CLOCK_BOOTTIME)
1198 const_iv (CLOCK_REALTIME_ALARM)
1199 const_iv (CLOCK_BOOTTIME_ALARM)
1200
1201 const_iv (TFD_NONBLOCK)
1202 const_iv (TFD_CLOEXEC)
1203
1204 const_iv (TFD_TIMER_ABSTIME)
1205 const_iv (TFD_TIMER_CANCEL_ON_SET)
1206
1174 /* these are libeio constants, and are independent of gendef0 */ 1207 /* these are libeio constants, and are independent of gendef0 */
1175 const_eio (SEEK_SET) 1208 const_eio (SEEK_SET)
1176 const_eio (SEEK_CUR) 1209 const_eio (SEEK_CUR)
1177 const_eio (SEEK_END) 1210 const_eio (SEEK_END)
1178 1211
2178#endif 2211#endif
2179 2212
2180 XPUSHs (newmortalFH (fd, O_RDWR)); 2213 XPUSHs (newmortalFH (fd, O_RDWR));
2181} 2214}
2182 2215
2216void
2217timerfd_create (int clockid, int flags = 0)
2218 PPCODE:
2219{
2220 int fd;
2221#if HAVE_TIMERFD
2222 fd = timerfd_create (clockid, flags);
2223#else
2224 fd = (errno = ENOSYS, -1);
2225#endif
2226
2227 XPUSHs (newmortalFH (fd, O_RDWR));
2228}
2229
2230void
2231timerfd_settime (SV *fh, int flags, NV interval, NV value)
2232 PPCODE:
2233{
2234 int fd = s_fileno_croak (fh, 0);
2235 int res;
2236 struct itimerspec its, ots;
2237
2238 ts_set (&its.it_interval, interval);
2239 ts_set (&its.it_value , value);
2240#if HAVE_TIMERFD
2241 res = timerfd_settime (fd, flags, &its, &ots);
2242#else
2243 res = (errno = ENOSYS, -1);
2244#endif
2245
2246 if (!res)
2247 {
2248 EXTEND (SP, 2);
2249 PUSHs (newSVnv (ts_get (&ots.it_interval)));
2250 PUSHs (newSVnv (ts_get (&ots.it_value)));
2251 }
2252}
2253
2254void
2255timerfd_gettime (SV *fh)
2256 PPCODE:
2257{
2258 int fd = s_fileno_croak (fh, 0);
2259 int res;
2260 struct itimerspec ots;
2261#if HAVE_TIMERFD
2262 res = timerfd_gettime (fd, &ots);
2263#else
2264 res = (errno = ENOSYS, -1);
2265#endif
2266
2267 if (!res)
2268 {
2269 EXTEND (SP, 2);
2270 PUSHs (newSVnv (ts_get (&ots.it_interval)));
2271 PUSHs (newSVnv (ts_get (&ots.it_value)));
2272 }
2273}
2274
2183UV 2275UV
2184get_fdlimit () 2276get_fdlimit ()
2185 CODE: 2277 CODE:
2186#if HAVE_RLIMITS 2278#if HAVE_RLIMITS
2187 struct rlimit rl; 2279 struct rlimit rl;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines