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.280 by root, Tue Sep 10 02:16:41 2019 UTC vs.
Revision 1.287 by root, Tue Dec 29 15:28:02 2020 UTC

84 84
85#else 85#else
86 86
87 #include <sys/time.h> 87 #include <sys/time.h>
88 #include <sys/select.h> 88 #include <sys/select.h>
89 #include <sys/wait.h>
89 #include <unistd.h> 90 #include <unistd.h>
90 #include <utime.h> 91 #include <utime.h>
91 #include <signal.h> 92 #include <signal.h>
92 93
93 #define EIO_STRUCT_STAT Stat_t 94 #define EIO_STRUCT_STAT Stat_t
226 227
227#if PAGESIZE <= 0 228#if PAGESIZE <= 0
228# define PAGESIZE sysconf (_SC_PAGESIZE) 229# define PAGESIZE sysconf (_SC_PAGESIZE)
229#endif 230#endif
230 231
232#if HAVE_SYSCALL
233#include <sys/syscall.h>
234#else
235# define syscall(nr,...) (errno = ENOSYS, -1)
236#endif
237
231/*****************************************************************************/ 238/*****************************************************************************/
232 239
233#if !_POSIX_MAPPED_FILES 240#if !_POSIX_MAPPED_FILES
234# define mmap(addr,length,prot,flags,fd,offs) (errno = ENOSYS, (void *)-1) 241# define mmap(addr,length,prot,flags,fd,offs) (errno = ENOSYS, (void *)-1)
235# define munmap(addr,length) EIO_ENOSYS () 242# define munmap(addr,length) EIO_ENOSYS ()
344 int count = req->int3; 351 int count = req->int3;
345 352
346 req->flags |= EIO_FLAG_PTR1_FREE; 353 req->flags |= EIO_FLAG_PTR1_FREE;
347 354
348 /* heuristic: start with 512 bytes (8 extents), and if that isn't enough, */ 355 /* heuristic: start with 512 bytes (8 extents), and if that isn't enough, */
349 /* increase in 3.5kb steps */ 356 /* increase in fixed steps */
350 if (count < 0) 357 if (count < 0)
351 count = 8; 358 count = 8;
352 359
353 fiemap = malloc (sizeof (*fiemap) + sizeof (struct fiemap_extent) * count); 360 fiemap = malloc (sizeof (*fiemap) + sizeof (struct fiemap_extent) * count);
354 errno = ENOMEM; 361 errno = ENOMEM;
407 414
408 for (count = 0; count < incmap->fm_mapped_extents; ++count) 415 for (count = 0; count < incmap->fm_mapped_extents; ++count)
409 { 416 {
410 struct fiemap_extent *e = incmap->fm_extents + count; 417 struct fiemap_extent *e = incmap->fm_extents + count;
411 418
419 fiemap->fm_extents [fiemap->fm_mapped_extents++] = *e;
420
412 if (e->fe_logical + e->fe_length >= end_offset) 421 if (e->fe_logical >= end_offset)
413 goto done; 422 goto done;
414
415 fiemap->fm_extents [fiemap->fm_mapped_extents++] = *e;
416 423
417 if (e->fe_flags & FIEMAP_EXTENT_LAST) 424 if (e->fe_flags & FIEMAP_EXTENT_LAST)
418 goto done; 425 goto done;
419 426
420 } 427 }
1329 const_iv (STATX_ATTR_APPEND) 1336 const_iv (STATX_ATTR_APPEND)
1330 const_iv (STATX_ATTR_NODUMP) 1337 const_iv (STATX_ATTR_NODUMP)
1331 const_iv (STATX_ATTR_ENCRYPTED) 1338 const_iv (STATX_ATTR_ENCRYPTED)
1332 const_iv (STATX_ATTR_AUTOMOUNT) 1339 const_iv (STATX_ATTR_AUTOMOUNT)
1333 1340
1341 const_iv (AT_FDCWD)
1342 const_iv (AT_SYMLINK_NOFOLLOW)
1343 const_iv (AT_EACCESS)
1344 const_iv (AT_REMOVEDIR)
1345 const_iv (AT_SYMLINK_FOLLOW)
1346 const_iv (AT_NO_AUTOMOUNT)
1347 const_iv (AT_EMPTY_PATH)
1348 const_iv (AT_STATX_SYNC_TYPE)
1349 const_iv (AT_STATX_AS_STAT)
1350 const_iv (AT_STATX_FORCE_SYNC)
1351 const_iv (AT_STATX_DONT_SYNC)
1352 const_iv (AT_RECURSIVE)
1353
1354 const_iv (OPEN_TREE_CLONE)
1355
1356 const_iv (FSOPEN_CLOEXEC)
1357
1358 const_iv (FSPICK_CLOEXEC)
1359 const_iv (FSPICK_SYMLINK_NOFOLLOW)
1360 const_iv (FSPICK_NO_AUTOMOUNT)
1361 const_iv (FSPICK_EMPTY_PATH)
1362
1363 const_iv (MOVE_MOUNT_F_SYMLINKS)
1364 const_iv (MOVE_MOUNT_F_AUTOMOUNTS)
1365 const_iv (MOVE_MOUNT_F_EMPTY_PATH)
1366 const_iv (MOVE_MOUNT_T_SYMLINKS)
1367 const_iv (MOVE_MOUNT_T_AUTOMOUNTS)
1368 const_iv (MOVE_MOUNT_T_EMPTY_PATH)
1369
1370 /* waitid */
1371 const_iv (P_PID)
1372 const_iv (P_PIDFD)
1373 const_iv (P_PGID)
1374 const_iv (P_ALL)
1375
1334 /* these are libeio constants, and are independent of gendef0 */ 1376 /* these are libeio constants, and are independent of gendef0 */
1335 const_eio (SEEK_SET) 1377 const_eio (SEEK_SET)
1336 const_eio (SEEK_CUR) 1378 const_eio (SEEK_CUR)
1337 const_eio (SEEK_END) 1379 const_eio (SEEK_END)
1338 1380
2599 PUSHs (newmortalFH (fd[1], O_WRONLY)); 2641 PUSHs (newmortalFH (fd[1], O_WRONLY));
2600 } 2642 }
2601} 2643}
2602 2644
2603void 2645void
2646pidfd_open (int pid, unsigned int flags = 0)
2647 PPCODE:
2648{
2649 /*GENDEF0_SYSCALL(pidfd_open,434)*/
2650 int fd = syscall (SYS_pidfd_open, pid, flags);
2651 XPUSHs (newmortalFH (fd, O_RDWR));
2652}
2653
2654int
2655pidfd_send_signal (SV *pidfh, int sig, SV *siginfo = &PL_sv_undef, unsigned int flags = 0)
2656 PPCODE:
2657{
2658 int res;
2659 siginfo_t si = { 0 };
2660
2661 if (SvOK (siginfo))
2662 {
2663 HV *hv;
2664 SV **svp;
2665
2666 if (!SvROK (siginfo) || SvTYPE (SvRV (siginfo)) != SVt_PVHV)
2667 croak ("siginfo argument must be a hashref code, pid, uid and value_int or value_ptr members, caught");
2668
2669 hv = (HV *)SvRV (siginfo);
2670
2671 if ((svp = hv_fetchs (hv, "code" , 0))) si.si_code = SvIV (*svp);
2672 if ((svp = hv_fetchs (hv, "pid" , 0))) si.si_pid = SvIV (*svp);
2673 if ((svp = hv_fetchs (hv, "uid" , 0))) si.si_uid = SvIV (*svp);
2674 if ((svp = hv_fetchs (hv, "value_int", 0))) si.si_value.sival_int = SvIV (*svp);
2675 if ((svp = hv_fetchs (hv, "value_ptr", 0))) si.si_value.sival_ptr = (void *)SvIV (*svp);
2676 }
2677
2678 /*GENDEF0_SYSCALL(pidfd_send_signal,424)*/
2679 res = syscall (SYS_pidfd_send_signal, s_fileno_croak (pidfh, 0), sig, SvOK (siginfo) ? &si : 0, flags);
2680
2681 XPUSHs (sv_2mortal (newSViv (res)));
2682}
2683
2684void
2685pidfd_getfd (SV *pidfh, int targetfd, unsigned int flags = 0)
2686 PPCODE:
2687{
2688 /*GENDEF0_SYSCALL(pidfd_getfd,438)*/
2689 int fd = syscall (SYS_pidfd_getfd, s_fileno_croak (pidfh, 0), targetfd, flags);
2690 XPUSHs (newmortalFH (fd, O_RDWR));
2691}
2692
2693void
2604eventfd (unsigned int initval = 0, int flags = 0) 2694eventfd (unsigned int initval = 0, int flags = 0)
2605 PPCODE: 2695 PPCODE:
2606{ 2696{
2607 int fd; 2697 int fd;
2608#if HAVE_EVENTFD 2698#if HAVE_EVENTFD
2727 if (0 == setrlimit (RLIMIT_NOFILE, &rl)) 2817 if (0 == setrlimit (RLIMIT_NOFILE, &rl))
2728 XSRETURN_YES; 2818 XSRETURN_YES;
2729 2819
2730 if (errno == EPERM) 2820 if (errno == EPERM)
2731 { 2821 {
2732 /* setlimit failed with EPERM - maybe we can't raise the hardlimit, or maybe */ 2822 /* setrlimit failed with EPERM - maybe we can't raise the hardlimit, or maybe */
2733 /* our limit overflows a system-wide limit */ 2823 /* our limit overflows a system-wide limit */
2734 /* try an adaptive algorithm, but do not lower the hardlimit */ 2824 /* try an adaptive algorithm, but do not lower the hardlimit */
2735 rl.rlim_max = 0; 2825 rl.rlim_max = 0;
2736 for (bit = 0x40000000U; bit; bit >>= 1) 2826 for (bit = 0x40000000U; bit; bit >>= 1)
2737 { 2827 {
2738 rl.rlim_max |= bit; 2828 rl.rlim_max |= bit;
2739 rl.rlim_cur = rl.rlim_max; 2829 rl.rlim_cur = rl.rlim_max;
2740 2830
2741 /* nevr decrease the hard limit */ 2831 /* never decrease the hard limit */
2742 if (rl.rlim_max < orig_rlim_max) 2832 if (rl.rlim_max < orig_rlim_max)
2743 break; 2833 break;
2744 2834
2745 if (0 != setrlimit (RLIMIT_NOFILE, &rl)) 2835 if (0 != setrlimit (RLIMIT_NOFILE, &rl))
2746 rl.rlim_max &= ~bit; /* too high, remove bit again */ 2836 rl.rlim_max &= ~bit; /* too high, remove bit again */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines