aboutsummaryrefslogtreecommitdiff
path: root/sysdeps/unix/sysv/linux/tst-ppoll.c
diff options
context:
space:
mode:
authorAdhemerval Zanella <adhemerval.zanella@linaro.org>2021-06-15 15:41:00 -0300
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>2021-06-22 12:09:52 -0300
commitecf2661281c71a9752c7238ab93bc12b16cfff23 (patch)
tree4adb5c607a25b04e7e3aff43e1eba5f26823140f /sysdeps/unix/sysv/linux/tst-ppoll.c
parent92f7b465101c23e45f66c6ad25ba243df49556a0 (diff)
downloadglibc-ecf2661281c71a9752c7238ab93bc12b16cfff23.zip
glibc-ecf2661281c71a9752c7238ab93bc12b16cfff23.tar.gz
glibc-ecf2661281c71a9752c7238ab93bc12b16cfff23.tar.bz2
linux: Only use 64-bit syscall if required for ppoll
For !__ASSUME_TIME64_SYSCALLS there is no need to issue a 64-bit syscall if the provided timeout fits in a 32-bit one. The 64-bit usage should be rare since the timeout is a relative one. This also avoids the need to use supports_time64() (which breaks the usage case of live migration like CRIU or similar). Checked on i686-linux-gnu on a 4.15 kernel and on a 5.11 kernel (with and without --enable-kernel=5.1) and on x86_64-linux-gnu. Reviewed-by: Lukasz Majewski <lukma@denx.de>
Diffstat (limited to 'sysdeps/unix/sysv/linux/tst-ppoll.c')
-rw-r--r--sysdeps/unix/sysv/linux/tst-ppoll.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/sysdeps/unix/sysv/linux/tst-ppoll.c b/sysdeps/unix/sysv/linux/tst-ppoll.c
index 9fe6ad0..e21e2fc 100644
--- a/sysdeps/unix/sysv/linux/tst-ppoll.c
+++ b/sysdeps/unix/sysv/linux/tst-ppoll.c
@@ -19,9 +19,11 @@
#include <time.h>
#include <poll.h>
#include <errno.h>
+#include <intprops.h>
#include <support/check.h>
#include <support/xtime.h>
#include <support/timespec.h>
+#include <support/support.h>
#include <stdbool.h>
static int test_ppoll_timeout (bool zero_tmo)
@@ -41,6 +43,16 @@ static int test_ppoll_timeout (bool zero_tmo)
return 0;
}
+static void
+test_ppoll_large_timeout (void)
+{
+ support_create_timer (0, 100000000, false, NULL);
+ struct timespec ts = { TYPE_MAXIMUM (time_t), 0 };
+ struct pollfd fds = { -1, 0, 0 };
+ TEST_COMPARE (ppoll (&fds, 1, &ts, 0), -1);
+ TEST_VERIFY (errno == EINTR || errno == EOVERFLOW);
+}
+
static int
do_test (void)
{
@@ -50,6 +62,9 @@ do_test (void)
/* Check if ppoll exits after specified timeout. */
test_ppoll_timeout (false);
+ /* Check if ppoll with large timeout. */
+ test_ppoll_large_timeout ();
+
return 0;
}