about summary refs log tree commit diff
path: root/misc
diff options
context:
space:
mode:
authorFlorian Weimer <fweimer@redhat.com>2021-07-21 11:42:31 +0200
committerFlorian Weimer <fweimer@redhat.com>2021-07-21 11:58:09 +0200
commit82c395d91ea4f69120d453aeec398e3042cad5fc (patch)
tree303dc68a9a65b06962c834932cd02c72f35a2432 /misc
parent39e8eb597303fb8bea07d87f82f4df1cf1586c1c (diff)
downloadglibc-82c395d91ea4f69120d453aeec398e3042cad5fc.tar.gz
glibc-82c395d91ea4f69120d453aeec398e3042cad5fc.tar.xz
glibc-82c395d91ea4f69120d453aeec398e3042cad5fc.zip
misc: Add time64 alias for ioctl
Reviewed-by: Lukasz Majewski <lukma@denx.de>
Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
Diffstat (limited to 'misc')
-rw-r--r--misc/Makefile7
-rw-r--r--misc/sys/ioctl.h10
-rw-r--r--misc/tst-ioctl-time64.c1
-rw-r--r--misc/tst-ioctl.c41
4 files changed, 57 insertions, 2 deletions
diff --git a/misc/Makefile b/misc/Makefile
index ae03e26f1b..22923efde9 100644
--- a/misc/Makefile
+++ b/misc/Makefile
@@ -88,11 +88,14 @@ tests := tst-dirname tst-tsearch tst-fdset tst-mntent tst-hsearch \
 	 tst-preadvwritev tst-preadvwritev64 tst-makedev tst-empty \
 	 tst-preadvwritev2 tst-preadvwritev64v2 tst-warn-wide \
 	 tst-ldbl-warn tst-ldbl-error tst-dbl-efgcvt tst-ldbl-efgcvt \
-	 tst-mntent-autofs tst-syscalls tst-mntent-escape tst-select
+	 tst-mntent-autofs tst-syscalls tst-mntent-escape tst-select \
+	 tst-ioctl
 
 tests-time64 := \
   tst-select-time64 \
-  tst-pselect-time64
+  tst-pselect-time64 \
+  tst-ioctl-time64 \
+  # tests-time64
 
 # Tests which need libdl.
 ifeq (yes,$(build-shared))
diff --git a/misc/sys/ioctl.h b/misc/sys/ioctl.h
index ddd204d95f..6884d9925f 100644
--- a/misc/sys/ioctl.h
+++ b/misc/sys/ioctl.h
@@ -38,7 +38,17 @@ __BEGIN_DECLS
 /* Perform the I/O control operation specified by REQUEST on FD.
    One argument may follow; its presence and type depend on REQUEST.
    Return value depends on REQUEST.  Usually -1 indicates error.  */
+#ifndef __USE_TIME_BITS64
 extern int ioctl (int __fd, unsigned long int __request, ...) __THROW;
+#else
+# ifdef __REDIRECT
+extern int __REDIRECT (ioctl, (int __fd, unsigned long int __request, ...),
+		       __ioctl_time64) __THROW;
+# else
+extern int __ioctl_time64 (int __fd, unsigned long int __request, ...) __THROW;
+#  define ioctl __ioctl_time64
+# endif
+#endif
 
 __END_DECLS
 
diff --git a/misc/tst-ioctl-time64.c b/misc/tst-ioctl-time64.c
new file mode 100644
index 0000000000..c73e8f649b
--- /dev/null
+++ b/misc/tst-ioctl-time64.c
@@ -0,0 +1 @@
+#include "tst-ioctl.c"
diff --git a/misc/tst-ioctl.c b/misc/tst-ioctl.c
new file mode 100644
index 0000000000..a09b8ae836
--- /dev/null
+++ b/misc/tst-ioctl.c
@@ -0,0 +1,41 @@
+/* Smoke test for ioctl.
+   Copyright (C) 2021 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <https://www.gnu.org/licenses/>.  */
+
+#include <support/check.h>
+#include <support/xunistd.h>
+#include <sys/ioctl.h>
+#include <sys/socket.h>
+
+static int
+do_test (void)
+{
+  int pair[2];
+  TEST_COMPARE (socketpair (AF_UNIX, SOCK_STREAM, 0, pair), 0);
+  TEST_COMPARE (write (pair[0], "buffer", sizeof ("buffer")),
+                sizeof ("buffer"));
+  int value;
+  TEST_COMPARE (ioctl (pair[1], FIONREAD, &value), 0);
+  TEST_COMPARE (value, sizeof ("buffer"));
+  TEST_COMPARE (ioctl (pair[0], FIONREAD, &value), 0);
+  TEST_COMPARE (value, 0);
+  xclose (pair[0]);
+  xclose (pair[1]);
+  return 0;
+}
+
+#include <support/test-driver.c>