aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2006-01-03 23:19:03 +0000
committerUlrich Drepper <drepper@redhat.com>2006-01-03 23:19:03 +0000
commit6d3aff23e2c64b64fe68fe88360185e17b3e936a (patch)
tree47755ce70732719bd318f1203454e287f8805d5d
parent1c50f6b6602a07f052249c6fe6dbab48357b68bd (diff)
downloadglibc-6d3aff23e2c64b64fe68fe88360185e17b3e936a.zip
glibc-6d3aff23e2c64b64fe68fe88360185e17b3e936a.tar.gz
glibc-6d3aff23e2c64b64fe68fe88360185e17b3e936a.tar.bz2
lio_listio should emit an event for each individual request in
addition to the global event. * sysdeps/pthread/lio_listio.c (lio_listio): Renamed to lio_listio_internal. Remove mode parameter check. Only set sigevent type ti SIGEV_NONE if LIO_NO_INDIVIDUAL_EVENT is set. (__lio_listio_21): New function. Compatiblity version which sets LIO_NO_INDIVIDUAL_EVENT before calling lio_listio_internal. (__lio_listio_item_notify): New function. * sysdeps/pthread/lio_listio64.c: Define __lio_listio_21 and __lio_listio_item_notify macros. * sysdeps/pthread/Versions: New file. * rt/tst-aio2.c: Adjust test for new semantics of lio_listio. * include/aio.h: Define LIO_NO_INDIVIDUAL_EVENT. * Versions.def: Add GLIBC_2.4 for librt. * rt/Versions: Whitespace fix. * sysdeps/pthread/aio_misc.c: Likewise.
-rw-r--r--ChangeLog18
-rw-r--r--Versions.def1
-rw-r--r--include/aio.h8
-rw-r--r--rt/Versions2
-rw-r--r--rt/tst-aio2.c25
-rw-r--r--sysdeps/pthread/Versions5
-rw-r--r--sysdeps/pthread/aio_misc.c5
-rw-r--r--sysdeps/pthread/lio_listio.c77
-rw-r--r--sysdeps/pthread/lio_listio64.c4
9 files changed, 117 insertions, 28 deletions
diff --git a/ChangeLog b/ChangeLog
index 004e344..792e4cd 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,23 @@
2006-01-03 Ulrich Drepper <drepper@redhat.com>
+ lio_listio should emit an event for each individual request in
+ addition to the global event.
+ * sysdeps/pthread/lio_listio.c (lio_listio): Renamed to
+ lio_listio_internal. Remove mode parameter check. Only set sigevent
+ type ti SIGEV_NONE if LIO_NO_INDIVIDUAL_EVENT is set.
+ (__lio_listio_21): New function. Compatiblity version which sets
+ LIO_NO_INDIVIDUAL_EVENT before calling lio_listio_internal.
+ (__lio_listio_item_notify): New function.
+ * sysdeps/pthread/lio_listio64.c: Define __lio_listio_21 and
+ __lio_listio_item_notify macros.
+ * sysdeps/pthread/Versions: New file.
+ * rt/tst-aio2.c: Adjust test for new semantics of lio_listio.
+ * include/aio.h: Define LIO_NO_INDIVIDUAL_EVENT.
+ * Versions.def: Add GLIBC_2.4 for librt.
+
+ * rt/Versions: Whitespace fix.
+ * sysdeps/pthread/aio_misc.c: Likewise.
+
* nscd/connections.c (nscd_init): Remove if block which should
have been removed as part of the -S option removal.
diff --git a/Versions.def b/Versions.def
index d7be703..062a947 100644
--- a/Versions.def
+++ b/Versions.def
@@ -95,6 +95,7 @@ librt {
GLIBC_2.3
GLIBC_2.3.3
GLIBC_2.3.4
+ GLIBC_2.4
}
libutil {
GLIBC_2.0
diff --git a/include/aio.h b/include/aio.h
index e3dc86f..1f28a40 100644
--- a/include/aio.h
+++ b/include/aio.h
@@ -1,6 +1,12 @@
#ifndef _AIO_H
#include <rt/aio.h>
-/* Now define the internal interfaces. */
+/* Now define the internal interfaces. */
extern void __aio_init (__const struct aioinit *__init);
+
+/* Flag to signal we need to be copmatible with glibc < 2.4 in
+ lio_listio and we do not issue events for each individual list
+ element. */
+#define LIO_NO_INDIVIDUAL_EVENT 128
+
#endif
diff --git a/rt/Versions b/rt/Versions
index a7d633d..51bb033 100644
--- a/rt/Versions
+++ b/rt/Versions
@@ -19,7 +19,7 @@ librt {
}
GLIBC_2.3.4 {
# m*
- mq_open; mq_close; mq_unlink; mq_getattr; mq_setattr;
+ mq_open; mq_close; mq_unlink; mq_getattr; mq_setattr;
mq_notify; mq_send; mq_receive; mq_timedsend; mq_timedreceive;
}
}
diff --git a/rt/tst-aio2.c b/rt/tst-aio2.c
index 1ff92ce..7907639 100644
--- a/rt/tst-aio2.c
+++ b/rt/tst-aio2.c
@@ -1,5 +1,5 @@
/* Test for notification mechanism in lio_listio.
- Copyright (C) 2000,02 Free Software Foundation, Inc.
+ Copyright (C) 2000, 2002, 2006 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 2000.
@@ -25,13 +25,19 @@
#include <unistd.h>
#include <errno.h>
-int flag;
+
+static pthread_barrier_t b;
static void
thrfct (sigval_t arg)
{
- flag = 1;
+ int e = pthread_barrier_wait (&b);
+ if (e != 0 && e != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ puts ("thread: barrier_wait failed");
+ exit (1);
+ }
}
@@ -53,6 +59,12 @@ do_test (int argc, char *argv[])
unlink (name);
+ if (pthread_barrier_init (&b, NULL, 2) != 0)
+ {
+ puts ("barrier_init failed");
+ return 1;
+ }
+
arr[0] = &cb;
cb.aio_fildes = fd;
@@ -77,9 +89,12 @@ do_test (int argc, char *argv[])
return 1;
}
- if (flag != 0)
+ puts ("lio_listio returned");
+
+ int e = pthread_barrier_wait (&b);
+ if (e != 0 && e != PTHREAD_BARRIER_SERIAL_THREAD)
{
- puts ("thread created, should not have happened");
+ puts ("barrier_wait failed");
return 1;
}
diff --git a/sysdeps/pthread/Versions b/sysdeps/pthread/Versions
new file mode 100644
index 0000000..a71cffb
--- /dev/null
+++ b/sysdeps/pthread/Versions
@@ -0,0 +1,5 @@
+librt {
+ GLIBC_2.4 {
+ lio_listio; lio_listio64;
+ }
+}
diff --git a/sysdeps/pthread/aio_misc.c b/sysdeps/pthread/aio_misc.c
index 5c9ccb4..3e1dbe9 100644
--- a/sysdeps/pthread/aio_misc.c
+++ b/sysdeps/pthread/aio_misc.c
@@ -1,5 +1,5 @@
/* Handle general operations.
- Copyright (C) 1997, 1998, 1999, 2000, 2001, 2003, 2004
+ Copyright (C) 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2006
Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
@@ -46,8 +46,7 @@ __aio_create_helper_thread (pthread_t *threadp, void *(*tf) (void *), void *arg)
(void) pthread_attr_destroy (&attr);
return ret;
-}
-
+}
#endif
static void add_request_to_runlist (struct requestlist *newrequest);
diff --git a/sysdeps/pthread/lio_listio.c b/sysdeps/pthread/lio_listio.c
index 29dc9d6..8158403 100644
--- a/sysdeps/pthread/lio_listio.c
+++ b/sysdeps/pthread/lio_listio.c
@@ -1,5 +1,5 @@
/* Enqueue and list of read or write requests.
- Copyright (C) 1997,1998,1999,2000,2001,2003,2005
+ Copyright (C) 1997,1998,1999,2000,2001,2003,2005,2006
Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
@@ -31,6 +31,9 @@
#define LIO_OPCODE_BASE 0
#endif
+#include <shlib-compat.h>
+
+
/* We need this special structure to handle asynchronous I/O. */
struct async_waitlist
{
@@ -40,12 +43,22 @@ struct async_waitlist
};
-int
-lio_listio (mode, list, nent, sig)
- int mode;
- struct aiocb *const list[];
- int nent;
- struct sigevent *sig;
+/* The code in glibc 2.1 to glibc 2.4 issued only one event when all
+ requests submitted with lio_listio finished. The existing practice
+ is to issue events for the individual requests as well. This is
+ what the new code does. */
+#if SHLIB_COMPAT (librt, GLIBC_2_1, GLIBC_2_4)
+# define LIO_MODE(mode) ((mode) & 127)
+# define NO_INDIVIDUAL_EVENT_P(mode) ((mode) & 128)
+#else
+# define LIO_MODE(mode) mode
+# define NO_INDIVIDUAL_EVENT_P(mode) 0
+#endif
+
+
+static int
+lio_listio_internal (int mode, struct aiocb *const list[], int nent,
+ struct sigevent *sig)
{
struct sigevent defsigev;
struct requestlist *requests[nent];
@@ -53,13 +66,6 @@ lio_listio (mode, list, nent, sig)
volatile int total = 0;
int result = 0;
- /* Check arguments. */
- if (mode != LIO_WAIT && mode != LIO_NOWAIT)
- {
- __set_errno (EINVAL);
- return -1;
- }
-
if (sig == NULL)
{
defsigev.sigev_notify = SIGEV_NONE;
@@ -74,7 +80,9 @@ lio_listio (mode, list, nent, sig)
for (cnt = 0; cnt < nent; ++cnt)
if (list[cnt] != NULL && list[cnt]->aio_lio_opcode != LIO_NOP)
{
- list[cnt]->aio_sigevent.sigev_notify = SIGEV_NONE;
+ if (NO_INDIVIDUAL_EVENT_P (mode))
+ list[cnt]->aio_sigevent.sigev_notify = SIGEV_NONE;
+
requests[cnt] = __aio_enqueue_request ((aiocb_union *) list[cnt],
(list[cnt]->aio_lio_opcode
| LIO_OPCODE_BASE));
@@ -100,7 +108,7 @@ lio_listio (mode, list, nent, sig)
locked forever. */
pthread_mutex_unlock (&__aio_requests_mutex);
- if (mode == LIO_NOWAIT)
+ if (LIO_MODE (mode) == LIO_NOWAIT)
{
#ifdef BROKEN_THREAD_SIGNALS
__aio_notify_only (sig,
@@ -112,7 +120,7 @@ lio_listio (mode, list, nent, sig)
return result;
}
- else if (mode == LIO_WAIT)
+ else if (LIO_MODE (mode) == LIO_WAIT)
{
pthread_cond_t cond = PTHREAD_COND_INITIALIZER;
struct waitlist waitlist[nent];
@@ -202,3 +210,38 @@ lio_listio (mode, list, nent, sig)
return result;
}
+
+
+#if SHLIB_COMPAT (librt, GLIBC_2_1, GLIBC_2_4)
+int
+attribute_compat_text_section
+__lio_listio_21 (int mode, struct aiocb *const list[], int nent,
+ struct sigevent *sig)
+{
+ /* Check arguments. */
+ if (mode != LIO_WAIT && mode != LIO_NOWAIT)
+ {
+ __set_errno (EINVAL);
+ return -1;
+ }
+
+ return lio_listio_internal (mode | LIO_NO_INDIVIDUAL_EVENT, list, nent, sig);
+}
+compat_symbol (librt, __lio_listio_21, lio_listio, GLIBC_2_1);
+#endif
+
+
+int
+__lio_listio_item_notify (int mode, struct aiocb *const list[], int nent,
+ struct sigevent *sig)
+{
+ /* Check arguments. */
+ if (mode != LIO_WAIT && mode != LIO_NOWAIT)
+ {
+ __set_errno (EINVAL);
+ return -1;
+ }
+
+ return lio_listio_internal (mode, list, nent, sig);
+}
+versioned_symbol (librt, __lio_listio_item_notify, lio_listio, GLIBC_2_4);
diff --git a/sysdeps/pthread/lio_listio64.c b/sysdeps/pthread/lio_listio64.c
index 4bec3f6..c6b7cf7 100644
--- a/sysdeps/pthread/lio_listio64.c
+++ b/sysdeps/pthread/lio_listio64.c
@@ -1,5 +1,5 @@
/* Enqueue and list of read or write requests, 64bit offset version.
- Copyright (C) 1997, 1998, 1999, 2003, 2005 Free Software Foundation, Inc.
+ Copyright (C) 1997,1998,1999,2003,2005,2006 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
@@ -27,6 +27,8 @@
#include <aio_misc.h>
#define lio_listio lio_listio64
+#define __lio_listio_21 __lio_listio64_21
+#define __lio_listio_item_notify __lio_listio64_item_notify
#define aiocb aiocb64
#define LIO_OPCODE_BASE 128
#include <lio_listio.c>