]> git.ipfire.org Git - thirdparty/glibc.git/blame - rt/lio_listio.c
Update.
[thirdparty/glibc.git] / rt / lio_listio.c
CommitLineData
cbdee279
UD
1/* Enqueue and list of read or write requests.
2 Copyright (C) 1997 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4 Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
5
6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public License as
8 published by the Free Software Foundation; either version 2 of the
9 License, or (at your option) any later version.
10
11 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details.
15
16 You should have received a copy of the GNU Library General Public
17 License along with the GNU C Library; see the file COPYING.LIB. If not,
18 write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. */
20
21#include <aio.h>
22#include <errno.h>
23#include <semaphore.h>
24
25#include "aio_misc.h"
26
27
28int
29lio_listio (mode, list, nent, sig)
30 int mode;
31 struct aiocb *const list[];
32 int nent;
33 struct sigevent *sig;
34{
35 int cnt;
36 int total = 0;
37 int result = 0;
38
39 /* Check arguments. */
40 if (mode != LIO_WAIT && mode != LIO_NOWAIT)
41 {
42 __set_errno (EINVAL);
43 return -1;
44 }
45
46 /* Request the semaphore. */
47 sem_wait (&__aio_requests_sema);
48
49 /* Now we can enqueue all requests. Since we already acquired the
50 semaphore the enqueue function need not do this. */
51 for (cnt = 0; cnt < nent; ++cnt)
52 if (list[cnt] != NULL && list[cnt]->aio_lio_opcode != LIO_NOP)
53 if (__aio_enqueue_request ((aiocb_union *) list[cnt],
54 list[cnt]->aio_lio_opcode, 0) >= 0)
55 /* Successfully enqueued. */
56 ++total;
57 else
58 /* Signal that we've seen an error. `errno' and the error code
59 of the aiocb will tell more. */
60 result = -1;
61
62
63
64 /* Release the semaphore. */
65 sem_post (&__aio_requests_sema);
66
67 return result;
68}