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.285 by root, Tue Dec 29 15:16:28 2020 UTC vs.
Revision 1.295 by root, Mon Sep 5 00:03:32 2022 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
224# undef PAGESIZE 225# undef PAGESIZE
225#endif 226#endif
226 227
227#if PAGESIZE <= 0 228#if PAGESIZE <= 0
228# define PAGESIZE sysconf (_SC_PAGESIZE) 229# define PAGESIZE sysconf (_SC_PAGESIZE)
230#endif
231
232/* solaris perl seems to declare a wrong syscall function that clashes with system includes */
233#ifdef __sun
234# undef HAVE_SYSCALL
229#endif 235#endif
230 236
231#if HAVE_SYSCALL 237#if HAVE_SYSCALL
232#include <sys/syscall.h> 238#include <sys/syscall.h>
233#else 239#else
1087 return ts->tv_sec + ts->tv_nsec * 1e-9; 1093 return ts->tv_sec + ts->tv_nsec * 1e-9;
1088} 1094}
1089 1095
1090/*****************************************************************************/ 1096/*****************************************************************************/
1091 1097
1098/* extract a ref-to-array of strings into a temporary c style string vector */
1099static char **
1100extract_stringvec (SV *sv, const char *croakmsg)
1101{
1102 if (!SvROK (sv) || SvTYPE (SvRV (sv)) != SVt_PVAV)
1103 croak (croakmsg);
1104
1105 AV *av = (AV *)SvRV (sv);
1106 int i, nelem = av_len (av) + 1;
1107 char **vecp = (char **)SvPVX (sv_2mortal (newSV (sizeof (char *) * (nelem + 1))));
1108
1109 for (i = 0; i < nelem; ++i)
1110 {
1111 SV **e = av_fetch (av, i, 0);
1112
1113 if (e && *e)
1114 vecp[i] = SvPVbyte_nolen (*e);
1115 else
1116 vecp[i] = "";
1117 }
1118
1119 vecp[nelem] = 0;
1120
1121 return vecp;
1122}
1123
1124/*****************************************************************************/
1125
1092XS(boot_IO__AIO) ecb_cold; 1126XS(boot_IO__AIO) ecb_cold;
1093 1127
1094MODULE = IO::AIO PACKAGE = IO::AIO 1128MODULE = IO::AIO PACKAGE = IO::AIO
1095 1129
1096PROTOTYPES: ENABLE 1130PROTOTYPES: ENABLE
1197 const_iv (MAP_NONBLOCK) 1231 const_iv (MAP_NONBLOCK)
1198 const_iv (MAP_GROWSDOWN) 1232 const_iv (MAP_GROWSDOWN)
1199 const_iv (MAP_32BIT) 1233 const_iv (MAP_32BIT)
1200 const_iv (MAP_HUGETLB) 1234 const_iv (MAP_HUGETLB)
1201 const_iv (MAP_STACK) 1235 const_iv (MAP_STACK)
1236 const_iv (MAP_FIXED_NOREPLACE)
1237 const_iv (MAP_SHARED_VALIDATE)
1238 const_iv (MAP_SYNC)
1239 const_iv (MAP_UNINITIALIZED)
1202 1240
1203 const_iv (MREMAP_MAYMOVE) 1241 const_iv (MREMAP_MAYMOVE)
1204 const_iv (MREMAP_FIXED) 1242 const_iv (MREMAP_FIXED)
1205 1243
1206 const_iv (MSG_CMSG_CLOEXEC) 1244 const_iv (MSG_CMSG_CLOEXEC)
1301 const_iv (EFD_SEMAPHORE) 1339 const_iv (EFD_SEMAPHORE)
1302 1340
1303 const_iv (MFD_CLOEXEC) 1341 const_iv (MFD_CLOEXEC)
1304 const_iv (MFD_ALLOW_SEALING) 1342 const_iv (MFD_ALLOW_SEALING)
1305 const_iv (MFD_HUGETLB) 1343 const_iv (MFD_HUGETLB)
1344 const_iv (MFD_HUGETLB_2MB)
1345 const_iv (MFD_HUGETLB_1GB)
1306 1346
1307 const_iv (CLOCK_REALTIME) 1347 const_iv (CLOCK_REALTIME)
1308 const_iv (CLOCK_MONOTONIC) 1348 const_iv (CLOCK_MONOTONIC)
1309 const_iv (CLOCK_BOOTTIME) 1349 const_iv (CLOCK_BOOTTIME)
1310 const_iv (CLOCK_REALTIME_ALARM) 1350 const_iv (CLOCK_REALTIME_ALARM)
1350 const_iv (AT_STATX_DONT_SYNC) 1390 const_iv (AT_STATX_DONT_SYNC)
1351 const_iv (AT_RECURSIVE) 1391 const_iv (AT_RECURSIVE)
1352 1392
1353 const_iv (OPEN_TREE_CLONE) 1393 const_iv (OPEN_TREE_CLONE)
1354 1394
1395 const_iv (FSOPEN_CLOEXEC)
1396
1397 const_iv (FSPICK_CLOEXEC)
1398 const_iv (FSPICK_SYMLINK_NOFOLLOW)
1399 const_iv (FSPICK_NO_AUTOMOUNT)
1400 const_iv (FSPICK_EMPTY_PATH)
1401
1355 const_iv (MOVE_MOUNT_F_SYMLINKS) 1402 const_iv (MOVE_MOUNT_F_SYMLINKS)
1356 const_iv (MOVE_MOUNT_F_AUTOMOUNTS) 1403 const_iv (MOVE_MOUNT_F_AUTOMOUNTS)
1357 const_iv (MOVE_MOUNT_F_EMPTY_PATH) 1404 const_iv (MOVE_MOUNT_F_EMPTY_PATH)
1358 const_iv (MOVE_MOUNT_T_SYMLINKS) 1405 const_iv (MOVE_MOUNT_T_SYMLINKS)
1359 const_iv (MOVE_MOUNT_T_AUTOMOUNTS) 1406 const_iv (MOVE_MOUNT_T_AUTOMOUNTS)
1360 const_iv (MOVE_MOUNT_T_EMPTY_PATH) 1407 const_iv (MOVE_MOUNT_T_EMPTY_PATH)
1408
1409 /* waitid */
1410 const_iv (P_PID)
1411 const_iv (P_PIDFD)
1412 const_iv (P_PGID)
1413 const_iv (P_ALL)
1414
1415 const_iv (FSCONFIG_SET_FLAG)
1416 const_iv (FSCONFIG_SET_STRING)
1417 const_iv (FSCONFIG_SET_BINARY)
1418 const_iv (FSCONFIG_SET_PATH)
1419 const_iv (FSCONFIG_SET_PATH_EMPTY)
1420 const_iv (FSCONFIG_SET_FD)
1421 const_iv (FSCONFIG_CMD_CREATE)
1422 const_iv (FSCONFIG_CMD_RECONFIGURE)
1423
1424 const_iv (MOUNT_ATTR_RDONLY)
1425 const_iv (MOUNT_ATTR_NOSUID)
1426 const_iv (MOUNT_ATTR_NODEV)
1427 const_iv (MOUNT_ATTR_NOEXEC)
1428 const_iv (MOUNT_ATTR__ATIME)
1429 const_iv (MOUNT_ATTR_RELATIME)
1430 const_iv (MOUNT_ATTR_NOATIME)
1431 const_iv (MOUNT_ATTR_STRICTATIME)
1432 const_iv (MOUNT_ATTR_NODIRATIME)
1361 1433
1362 /* these are libeio constants, and are independent of gendef0 */ 1434 /* these are libeio constants, and are independent of gendef0 */
1363 const_eio (SEEK_SET) 1435 const_eio (SEEK_SET)
1364 const_eio (SEEK_CUR) 1436 const_eio (SEEK_CUR)
1365 const_eio (SEEK_END) 1437 const_eio (SEEK_END)
2640int 2712int
2641pidfd_send_signal (SV *pidfh, int sig, SV *siginfo = &PL_sv_undef, unsigned int flags = 0) 2713pidfd_send_signal (SV *pidfh, int sig, SV *siginfo = &PL_sv_undef, unsigned int flags = 0)
2642 PPCODE: 2714 PPCODE:
2643{ 2715{
2644 int res; 2716 int res;
2717#if HAVE_SIGINFO_T
2645 siginfo_t si = { 0 }; 2718 siginfo_t si = { 0 };
2646 2719
2647 if (SvOK (siginfo)) 2720 if (SvOK (siginfo))
2648 { 2721 {
2649 HV *hv; 2722 HV *hv;
2650 SV **svp; 2723 SV **svp;
2651 2724
2652 if (!SvROK (siginfo) || SvTYPE (SvRV (siginfo)) != SVt_PVHV) 2725 if (!SvROK (siginfo) || SvTYPE (SvRV (siginfo)) != SVt_PVHV)
2653 croak ("siginfo argument must be a hashref code, pid, uid and value_int or value_ptr members, caught"); 2726 croak ("siginfo argument must be a hashref with 'code', 'pid', 'uid' and 'value_int' or 'value_ptr' members, caught");
2654 2727
2655 hv = (HV *)SvRV (siginfo); 2728 hv = (HV *)SvRV (siginfo);
2656 2729
2657 if ((svp = hv_fetchs (hv, "code" , 0))) si.si_code = SvIV (*svp); 2730 if ((svp = hv_fetchs (hv, "code" , 0))) si.si_code = SvIV (*svp);
2658 if ((svp = hv_fetchs (hv, "pid" , 0))) si.si_pid = SvIV (*svp); 2731 if ((svp = hv_fetchs (hv, "pid" , 0))) si.si_pid = SvIV (*svp);
2661 if ((svp = hv_fetchs (hv, "value_ptr", 0))) si.si_value.sival_ptr = (void *)SvIV (*svp); 2734 if ((svp = hv_fetchs (hv, "value_ptr", 0))) si.si_value.sival_ptr = (void *)SvIV (*svp);
2662 } 2735 }
2663 2736
2664 /*GENDEF0_SYSCALL(pidfd_send_signal,424)*/ 2737 /*GENDEF0_SYSCALL(pidfd_send_signal,424)*/
2665 res = syscall (SYS_pidfd_send_signal, s_fileno_croak (pidfh, 0), sig, SvOK (siginfo) ? &si : 0, flags); 2738 res = syscall (SYS_pidfd_send_signal, s_fileno_croak (pidfh, 0), sig, SvOK (siginfo) ? &si : 0, flags);
2739#else
2740 res = (errno = ENOSYS, -1);
2741#endif
2666 2742
2667 XPUSHs (sv_2mortal (newSViv (res))); 2743 XPUSHs (sv_2mortal (newSViv (res)));
2668} 2744}
2669 2745
2670void 2746void
2760 fd = (errno = ENOSYS, -1); 2836 fd = (errno = ENOSYS, -1);
2761#endif 2837#endif
2762 2838
2763 XPUSHs (newmortalFH (fd, O_RDWR)); 2839 XPUSHs (newmortalFH (fd, O_RDWR));
2764} 2840}
2841
2842int
2843fexecve (SV *fh, SV *args, SV *envs = &PL_sv_undef)
2844 CODE:
2845{
2846 int fd = PerlIO_fileno (IoIFP (sv_2io (fh)));
2847 char **envp, **argv;
2848 argv = extract_stringvec (args, "IO::AIO::fexecve: args must be an array of strings");
2849 if (!SvOK (envs))
2850 {
2851 extern char **environ;
2852 envp = environ;
2853 }
2854 else
2855 envp = extract_stringvec (envs, "IO::AIO::fexecve: envs must be an array of strings");
2856#if _POSIX_VERSION >= 200809L
2857 RETVAL = fexecve (fd, argv, envp);
2858#else
2859 RETVAL = (errno = ENOSYS, -1);
2860#endif
2861}
2862 OUTPUT: RETVAL
2765 2863
2766UV 2864UV
2767get_fdlimit () 2865get_fdlimit ()
2768 CODE: 2866 CODE:
2769#if HAVE_RLIMITS 2867#if HAVE_RLIMITS

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines