GH919: Fix wrappers for two headers
[openssl.git] / engines / afalg / e_afalg.h
1 /*
2  * Copyright 2016 The OpenSSL Project Authors. All Rights Reserved.
3  *
4  * Licensed under the OpenSSL license (the "License").  You may not use
5  * this file except in compliance with the License.  You can obtain a copy
6  * in the file LICENSE in the source distribution or at
7  * https://www.openssl.org/source/license.html
8  */
9
10 #ifndef HEADER_AFALG_H
11 # define HEADER_AFALG_H
12
13 # ifdef ALG_DEBUG
14 #  define ALG_DGB(x, ...) fprintf(stderr, "ALG_DBG: " x, __VA_ARGS__)
15 #  define ALG_INFO(x, ...) fprintf(stderr, "ALG_INFO: " x, __VA_ARGS__)
16 #  define ALG_WARN(x, ...) fprintf(stderr, "ALG_WARN: " x, __VA_ARGS__)
17 # else
18 #  define ALG_DGB(x, ...)
19 #  define ALG_INFO(x, ...)
20 #  define ALG_WARN(x, ...)
21 # endif
22
23 # define ALG_ERR(x, ...) fprintf(stderr, "ALG_ERR: " x, __VA_ARGS__)
24 # define ALG_PERR(x, ...) \
25                 do { \
26                     fprintf(stderr, "ALG_PERR: " x, __VA_ARGS__); \
27                     perror(NULL); \
28                 } while(0)
29 # define ALG_PWARN(x, ...) \
30                 do { \
31                     fprintf(stderr, "ALG_PERR: " x, __VA_ARGS__); \
32                     perror(NULL); \
33                 } while(0)
34
35 # ifndef AES_BLOCK_SIZE
36 #  define AES_BLOCK_SIZE   16
37 # endif
38 # define AES_KEY_SIZE_128 16
39 # define AES_IV_LEN       16
40
41 # define MAX_INFLIGHTS 1
42
43 typedef enum {
44     MODE_UNINIT = 0,
45     MODE_SYNC,
46     MODE_ASYNC
47 } op_mode;
48
49 struct afalg_aio_st {
50     int efd;
51     op_mode mode;
52     aio_context_t aio_ctx;
53     struct io_event events[MAX_INFLIGHTS];
54     struct iocb cbt[MAX_INFLIGHTS];
55 };
56 typedef struct afalg_aio_st afalg_aio;
57
58 /*
59  * MAGIC Number to identify correct initialisation
60  * of afalg_ctx.
61  */
62 # define MAGIC_INIT_NUM 0x1890671
63
64 struct afalg_ctx_st {
65     int init_done;
66     int sfd;
67     int bfd;
68 # ifdef ALG_ZERO_COPY
69     int zc_pipe[2];
70 # endif
71     afalg_aio aio;
72 };
73
74 typedef struct afalg_ctx_st afalg_ctx;
75 #endif