Debian Codegraph @

debian/rust-vendor/openssl-src/openssl/include/internal/rio_notifier.h

raw
1 /*
2 * Copyright 2024-2025 The OpenSSL Project Authors. All Rights Reserved.
3 *
4 * Licensed under the Apache License 2.0 (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 #ifndef OSSL_RIO_NOTIFIER_H
10 #define OSSL_RIO_NOTIFIER_H
11
12 #include "internal/common.h"
13 #include "internal/sockets.h"
14
15 /*
16 * Pollable Notifier
17 * =================
18 *
19 * RIO_NOTIFIER provides an OS-pollable resource which can be plugged into an
20 * OS's socket polling APIs to allow socket polling calls to be woken
21 * artificially by other threads.
22 */
23 #define RIO_NOTIFIER_METHOD_SOCKET 1
24 #define RIO_NOTIFIER_METHOD_SOCKETPAIR 2
25
26 #if !defined(RIO_NOTIFIER_METHOD)
27 #if defined(OPENSSL_SYS_WINDOWS)
28 #define RIO_NOTIFIER_METHOD RIO_NOTIFIER_METHOD_SOCKET
29 #elif defined(OPENSSL_SYS_UNIX)
30 #define RIO_NOTIFIER_METHOD RIO_NOTIFIER_METHOD_SOCKETPAIR
31 #else
32 #define RIO_NOTIFIER_METHOD RIO_NOTIFIER_METHOD_SOCKET
33 #endif
34 #endif
35
36 typedef struct rio_notifier_st {
37 int rfd, wfd;
38 } RIO_NOTIFIER;
39
40 /*
41 * Initialises a RIO_NOTIFIER. Returns 1 on success or 0 on failure.
42 */
43 int ossl_rio_notifier_init(RIO_NOTIFIER *nfy);
44
45 /*
46 * Cleans up a RIO_NOTIFIER, tearing down any allocated resources.
47 */
48 void ossl_rio_notifier_cleanup(RIO_NOTIFIER *nfy);
49
50 /*
51 * Signals a RIO_NOTIFIER, waking up any waiting threads.
52 */
53 int ossl_rio_notifier_signal(RIO_NOTIFIER *nfy);
54
55 /*
56 * Unsignals a RIO_NOTIFIER.
57 */
58 int ossl_rio_notifier_unsignal(RIO_NOTIFIER *nfy);
59
60 /*
61 * Returns an OS socket handle (FD or Win32 SOCKET) which can be polled for
62 * readability to determine when the notifier has been signalled.
63 */
64 static ossl_inline ossl_unused int ossl_rio_notifier_as_fd(RIO_NOTIFIER *nfy)
65 {
66 return nfy->rfd;
67 }
68
69 #endif