• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1  /*
2   * Copyright (C) 2016 The Android Open Source Project
3   *
4   * Licensed under the Apache License, Version 2.0 (the "License");
5   * you may not use this file except in compliance with the License.
6   * You may obtain a copy of the License at
7   *
8   *      http://www.apache.org/licenses/LICENSE-2.0
9   *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  
17  #ifndef _ASYNCIO_H
18  #define _ASYNCIO_H
19  
20  #include <linux/aio_abi.h>
21  #include <stdbool.h>
22  #include <stdint.h>
23  #include <sys/cdefs.h>
24  #include <sys/types.h>
25  #include <time.h>
26  #include <unistd.h>
27  
28  #ifdef __cplusplus
29  extern "C" {
30  #endif
31  
32  /**
33   * Provides kernel aio operations.
34   */
35  
36  int io_setup(unsigned nr, aio_context_t* ctxp);
37  int io_destroy(aio_context_t ctx);
38  int io_submit(aio_context_t ctx, long nr, struct iocb** iocbpp);
39  int io_getevents(aio_context_t ctx, long min_nr, long max_nr, struct io_event* events,
40                   struct timespec* timeout);
41  int io_cancel(aio_context_t ctx, struct iocb*, struct io_event* result);
42  
43  void io_prep_pread(struct iocb* iocb, int fd, void* buf, size_t count, long long offset);
44  void io_prep_pwrite(struct iocb* iocb, int fd, void* buf, size_t count, long long offset);
45  void io_prep(struct iocb* iocb, int fd, const void* buf, uint64_t count, int64_t offset, bool read);
46  
47  #ifdef __cplusplus
48  };
49  #endif
50  
51  #endif  // ASYNCIO_H
52