]> dgit.raspbian.org Git - libaio.git/commitdiff
[PATCH libaio 22/26] Add time64 public functions on 32-bit architectures
authorGuillem Jover <guillem@hadrons.org>
Fri, 1 Mar 2024 00:52:51 +0000 (01:52 +0100)
committerPeter Michael Green <plugwash@raspbian.org>
Thu, 4 Jun 2026 18:31:38 +0000 (18:31 +0000)
This adds new time64 functions for io_getevents() and io_pgetevents()
that will get redirected when building with _TIME_BITS=64.

Ideally we should generate the .map file and not include these symbols
on 64-bit architectures, but this will do for now.

Signed-off-by: Guillem Jover <guillem@hadrons.org>
Gbp-Pq: Name 0022-Add-time64-public-functions-on-32-bit-architectures.patch

harness/Makefile
src/Makefile
src/compat-0_1.c
src/io_getevents.c
src/io_getevents_time64.c [new file with mode: 0644]
src/io_pgetevents.c
src/io_pgetevents_time64.c [new file with mode: 0644]
src/io_queue_wait.c
src/libaio.h
src/libaio.map

index ae4e45ea5429e820b7e77f8cbea5ce8df8cb445f..3f976506a99036e54134db0aee0ddeae551938c6 100644 (file)
@@ -6,7 +6,7 @@ PROGS:=$(PARTPROGS) $(EXTRAPROGS)
 HARNESS_SRCS:=main.c
 # io_queue.c
 
-MK_CPPFLAGS = -I../src $(CPPFLAGS)
+MK_CPPFLAGS = -I../src -D_FILE_OFFSET_BITS=64 -D_TIME_BITS=64 $(CPPFLAGS)
 CFLAGS ?= -Wall -Werror -g -O2
 MK_CFLAGS = $(CFLAGS)
 #-lpthread -lrt
index da18e8c7faf4225b06da9f88243b8e250304061c..e63e706d0c77157fcac9d2adecc200eaf5a36620 100644 (file)
@@ -2,7 +2,7 @@ prefix ?= /usr
 includedir ?= $(prefix)/include
 libdir ?= $(prefix)/lib
 
-MK_CPPFLAGS = -I. $(CPPFLAGS)
+MK_CPPFLAGS = -I. -D_FILE_OFFSET_BITS=64 -D_TIME_BITS=64 $(CPPFLAGS)
 CFLAGS ?= -Wall -g -fomit-frame-pointer -O2
 MK_CFLAGS = -fPIC $(CFLAGS)
 SO_CFLAGS = -shared $(MK_CFLAGS)
@@ -30,6 +30,7 @@ libaio_srcs += io_queue_wait.c io_queue_run.c
 libaio_srcs += aio_pgetevents.c aio_getevents.c
 libaio_srcs += io_getevents.c io_submit.c io_cancel.c
 libaio_srcs += io_setup.c io_destroy.c io_pgetevents.c
+libaio_srcs += io_pgetevents_time64.c io_getevents_time64.c
 
 # old symbols
 libaio_srcs += compat-0_1.c
index 25b789a48a3be5ad3e2fd600351a006b29e69c39..61df3b3547e919a52b029c9ecf8bb23908699f5c 100644 (file)
    License along with this library; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
  */
+
+/*
+ * On 32-bit systems these were using 32-bit struct timespec, keep these
+ * backward compatibility functions that way.
+ */
+#undef _TIME_BITS
+
 #include <stdlib.h>
 #include <asm/errno.h>
 
index c06e80388717f98abef67548346440f9e8e70d60..0b2d4488bdaf28d9757779b4ab0871040d351d64 100644 (file)
    License along with this library; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
  */
+
+/*
+ * On 32-bit systems these were using 32-bit struct timespec, keep this
+ * backward compatibility function that way.
+ */
+#undef _TIME_BITS
+
 #include <libaio.h>
 #include <errno.h>
 #include <stdlib.h>
diff --git a/src/io_getevents_time64.c b/src/io_getevents_time64.c
new file mode 100644 (file)
index 0000000..942743d
--- /dev/null
@@ -0,0 +1,37 @@
+/* io_getevents_time64.c
+   libaio Linux async I/O interface
+   Copyright 2002 Red Hat, Inc.
+   Copyright 2024 Guillem Jover <guillem@hadrons.org>
+
+   This 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 of the License, or (at your option) any later version.
+
+   This 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 this library; if not, write to the Free Software
+   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
+ */
+#include <libaio.h>
+#include <errno.h>
+#include <stdlib.h>
+#include <time.h>
+#include "syscall.h"
+#include "aio_time.h"
+
+#if __BITS_PER_LONG == 32
+int io_getevents_time64(io_context_t ctx, long min_nr, long nr,
+               struct io_event * events, struct timespec * timeout)
+{
+       struct __kernel_timespec kts;
+
+       if (timeout)
+               aio_get_timespec(&kts, timeout);
+       return aio_getevents(ctx, min_nr, nr, events, timeout ? &kts : NULL);
+}
+#endif
index d960a05f134c75cc37e4f653d98a0d9a50602098..50b8d1c5fc494d5690cdaf9c717a3e2c403a093d 100644 (file)
    License along with this library; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
  */
+
+/*
+ * On 32-bit systems these were using 32-bit struct timespec, keep this
+ * backward compatibility function that way.
+ */
+#undef _TIME_BITS
+
 #include <libaio.h>
 #include <errno.h>
 #include <stdlib.h>
diff --git a/src/io_pgetevents_time64.c b/src/io_pgetevents_time64.c
new file mode 100644 (file)
index 0000000..55e4ad1
--- /dev/null
@@ -0,0 +1,39 @@
+/*
+   libaio Linux async I/O interface
+   Copyright 2018 Christoph Hellwig.
+   Copyright 2024 Guillem Jover <guillem@hadrons.org>
+
+   This 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 of the License, or (at your option) any later version.
+
+   This 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 this library; if not, write to the Free Software
+   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
+ */
+#include <libaio.h>
+#include <errno.h>
+#include <stdlib.h>
+#include <time.h>
+#include <signal.h>
+#include "aio_time.h"
+
+#if __BITS_PER_LONG == 32
+int io_pgetevents_time64(io_context_t ctx, long min_nr, long nr,
+               struct io_event *events, struct timespec *timeout,
+               sigset_t *sigmask)
+{
+       struct __kernel_timespec kts;
+
+       if (timeout)
+               aio_get_timespec(&kts, timeout);
+       return aio_pgetevents(ctx, min_nr, nr, events, timeout ? &kts : NULL,
+                       sigmask);
+}
+#endif
index b4bb23622cd3f5213e8d81840defb522eb4875ef..fe89291a69dd400318bfd6a2240b094686457aa7 100644 (file)
    License along with this library; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
  */
+
+/*
+ * On 32-bit systems these were using 32-bit struct timespec, keep this
+ * backward compatibility function that way.
+ */
+#undef _TIME_BITS
+
 #define NO_SYSCALL_ERRNO
 #include <sys/types.h>
 #include <libaio.h>
index 3304bf7acef44b972a104b17fd07b8a09dc782a4..feeee378aa76bada6cf95e212a34d1ce7912d58e 100644 (file)
@@ -27,6 +27,7 @@
 extern "C" {
 #endif
 
+#include <linux/types.h>
 #include <sys/types.h>
 #include <string.h>
 #include <signal.h>
@@ -50,6 +51,12 @@ typedef enum io_iocb_cmd {
        IO_CMD_PWRITEV = 8,
 } io_iocb_cmd_t;
 
+#define LIBAIO_STRING(x) #x
+
+#define LIBAIO_REDIRECT(name, proto, alias) name proto __asm__(LIBAIO_ASMNAME(#alias))
+#define LIBAIO_ASMNAME(cname) LIBAIO_ASMNAME_PREFIX(__USER_LABEL_PREFIX__, cname)
+#define LIBAIO_ASMNAME_PREFIX(prefix, cname) LIBAIO_STRING(prefix) cname
+
 /* little endian, 32 bits */
 #if defined(__i386__) || \
     (defined(__x86_64__) && defined(__ILP32__)) || \
@@ -178,6 +185,17 @@ extern int io_getevents(io_context_t ctx, long min_nr, long nr,
 extern int io_pgetevents(io_context_t ctx, long min_nr, long nr,
                struct io_event *events, struct timespec *timeout,
                sigset_t *sigmask);
+#if __BITS_PER_LONG == 32 && defined(_TIME_BITS) && _TIME_BITS == 64
+extern int LIBAIO_REDIRECT(io_getevents, (io_context_t ctx,
+               long min_nr, long nr,
+               struct io_event *events, struct timespec *timeout),
+               io_getevents_time64);
+extern int LIBAIO_REDIRECT(io_pgetevents, (io_context_t ctx,
+               long min_nr, long nr,
+               struct io_event *events, struct timespec *timeout,
+               sigset_t *sigmask),
+               io_pgetevents_time64);
+#endif
 
 
 static inline void io_set_callback(struct iocb *iocb, io_callback_t cb)
index ec9d13b5f2c882a8085e92a6f03bf83c76d623ab..74b2c0878a7895c65a6fe21fddec0bf2b2160dff 100644 (file)
@@ -25,3 +25,9 @@ LIBAIO_0.5 {
        global:
                io_pgetevents;
 } LIBAIO_0.4;
+
+LIBAIO_0.6 {
+       global:
+               io_getevents_time64;
+               io_pgetevents_time64;
+} LIBAIO_0.5;