This is the mail archive of the libc-alpha@sources.redhat.com mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[patch] aio_return


Greetings,

Enclosed you will find patches for the aio_return function. 
The goal of the patch is to come into POSIX 1003.1 compliance
as defined by:

http://www.opengroup.org/onlinepubs/007904975/functions/aio_return.html

Additionally a new testcase is included which fits into the glibc
test harness.

The authors of this code are Amos Waterland and myself both of the
IBM LTC.

Fixed in this patch is the following bug:

1) Check that the aio control block pointer is real. 

------------------
--- glibc-2.2.5/rt/aio_return.c	Fri Jul  6 04:55:39 2001
+++ glibc/rt/aio_return.c	Mon Jun 10 14:39:53 2002
@@ -29,12 +29,19 @@
 /* And undo the hack.  */
 #undef aio_return64
 
+#include <errno.h>
 
 ssize_t
 aio_return (aiocbp)
      struct aiocb *aiocbp;
 {
-  return aiocbp->__return_value;
+  if (aiocbp)
+    {
+    return aiocbp->__return_value;
+    }
+
+  __set_errno(EINVAL);
+  return -1;
 }
 
 weak_alias (aio_return, aio_return64)
------------------
diff -uN --exclude=CVS glibc-2.2.5/rt/tst-aio_return.c glibc/rt/tst-aio_return.c
--- glibc-2.2.5/rt/tst-aio_return.c	Thu Jan  1 00:00:00 1970
+++ glibc/rt/tst-aio_return.c	Wed Jun 12 00:16:22 2002
@@ -0,0 +1,98 @@
+/* Tests for AIO in librt.
+   Copyright (C) 2002 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Tom Gall (tom_gall@vnet.ibm.com) and 
+   Amos Waterland <apw@us.ibm.com>, 2002.
+
+   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, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <aio.h>
+#include <errno.h>
+#include <error.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/stat.h>
+
+/* Prototype for our test function.  */
+extern void do_prepare (int argc, char *argv[]);
+extern int do_test (int argc, char *argv[]);
+
+
+/* We might need a bit longer timeout.  */
+#define TIMEOUT 20 /* sec */
+
+/* This defines the `main' function and some more.  */
+#include <test-skeleton.c>
+
+
+/* These are for the temporary file we generate.  */
+char *name;
+int fd;
+
+#define FMT "taio_fildes: %i\treturn: %i\n"
+#define FMT2 "aio_fildes: 0x0\treturn: %i\n"
+
+void
+do_prepare (int argc, char *argv[])
+{
+}
+
+int
+do_test (int argc, char *argv[])
+{
+/* 
+ * test a couple of corner cases
+ */
+  int r;
+  struct aiocb cb;
+  char errorstring[255];
+
+  cb.aio_offset = 0;
+  cb.aio_buf = NULL;
+  cb.aio_nbytes = 0;
+  cb.aio_reqprio = 0;
+  cb.aio_sigevent.sigev_notify = SIGEV_NONE;
+
+  /* case: cb.aio_fildes is valid */
+  errno = 0; cb.aio_fildes = 1;
+  r = aio_return( &cb ); 
+  if (errno!=0)
+    {
+      sprintf(errorstring,FMT, cb.aio_fildes, r);
+      error(0,errno, errorstring);
+    }
+
+  /* case: cb.aio_fildes is not valid  but that doesn't matter*/
+  errno = 0; cb.aio_fildes = -1;
+  r = aio_return(  &cb );
+  if (errno!=0)
+    {
+      sprintf(errorstring,FMT, cb.aio_fildes, r);
+      error(0,errno, errorstring);
+    }
+
+  /* case: cb is null */
+  errno = 0; 
+  r = aio_return( NULL );
+  if (errno!=EINVAL)
+    {
+      sprintf(errorstring,FMT2, r);
+      error(0,errno, errorstring);
+    } 
+
+ return 0;
+}
------------------
Regards,

Tom

Tom Gall - PPC64, PPC, Embedded  "Where's the ka-boom? There was
Linux Technology Center           supposed to be an earth
(w) tom_gall@vnet.ibm.com         shattering ka-boom!"
(w) 507-253-4558                 -- Marvin Martian
(h) tgall@rochcivictheatre.org
http://www.ibm.com/linux/ltc


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]