xref: /aosp_15_r20/system/chre/platform/include/chre/platform/event_loop_hooks.h (revision 84e339476a462649f82315436d70fd732297a399)
1 /*
2  * Copyright (C) 2024 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 CHRE_PLATFORM_EVENT_LOOP_HOOKS_H_
18 #define CHRE_PLATFORM_EVENT_LOOP_HOOKS_H_
19 
20 /**
21  * @file
22  * Include a platform-specific event-loop configuration header if it exists.
23  * This header can optionally override the default macros defined below.
24  *
25  * TODO(b/380327627): Move the conentents of this file to chre/variant/config.h
26  * once CHRE team migrates platforms to use the variant config pattern and
27  * they address b/376532038.
28  */
29 #ifdef CHRE_PLATFORM_EVENT_LOOP_CONFIG_HEADER
30 #include CHRE_PLATFORM_EVENT_LOOP_CONFIG_HEADER
31 #endif  // CHRE_PLATFORM_EVENT_LOOP_CONFIG_HEADER
32 
33 /**
34  * @param eventLoop Pointer to the current EventLoop instance that is used to
35  *        deliver events to nanoapps.
36  * @param eventType Event type identifier, which implies the type of eventData
37  * @param eventData The data that failed to be posted
38  * @param freeCallback Function to invoke to when the event has been processed
39  *        by all recipients; this must be safe to call immediately, to handle
40  *        the case where CHRE is shutting down
41  * @param senderInstanceId The instance ID of the sender of this event
42  * @param targetInstanceId targetInstanceId The instance ID of the destination
43  *        of this event
44  * @param targetGroupMask Mask used to limit the recipients that are
45  *        registered to receive this event
46  *
47  * @since v1.11
48  * @note FATAL_ERROR is called after this macro is executed
49  */
50 #ifndef CHRE_HANDLE_FAILED_SYSTEM_EVENT_ENQUEUE
51 #define CHRE_HANDLE_FAILED_SYSTEM_EVENT_ENQUEUE(                     \
52     eventLoop, eventType, eventData, freeCallback, senderInstanceId, \
53     targetInstanceId, targetGroupMask)                               \
54   do {                                                               \
55   } while (0)
56 #endif  // !CHRE_HANDLE_FAILED_SYSTEM_EVENT_ENQUEUE
57 
58 /**
59  * @param eventLoop Pointer to the current EventLoop instance that is used to
60  *        deliver events to nanoapps.
61  * @param eventType Event type identifier, which implies the type of eventData
62  * @param eventData The data that failed to be posted
63  * @param callback Function to invoke from the context of the CHRE thread
64  * @param extraData Additional arbitrary data to provide to the callback
65  *
66  * @since v1.11
67  * @note FATAL_ERROR is called after this macro is executed
68  */
69 #ifndef CHRE_HANDLE_EVENT_QUEUE_FULL_DURING_SYSTEM_POST
70 #define CHRE_HANDLE_EVENT_QUEUE_FULL_DURING_SYSTEM_POST(  \
71     eventLoop, eventType, eventData, callback, extraData) \
72   do {                                                    \
73   } while (0)
74 #endif  // !CHRE_HANDLE_EVENT_QUEUE_FULL_DURING_SYSTEM_POST
75 
76 /**
77  * @param eventLoop Pointer to the current EventLoop instance that is used to
78  *        deliver events to nanoapps.
79  * @param eventType Event type identifier, which implies the type of eventData
80  * @param eventData The data that failed to be posted
81  * @param freeCallback Function to invoke to when the event has been processed
82  *        by all recipients; this must be safe to call immediately, to handle
83  *        the case where CHRE is shutting down
84  * @param senderInstanceId The instance ID of the sender of this event
85  * @param targetInstanceId targetInstanceId The instance ID of the destination
86  *        of this event
87  * @param targetGroupMask Mask used to limit the recipients that are
88  *        registered to receive this event
89  *
90  * @since v1.11
91  * @note Upon return, the freeCallaback will be invoked if not nullptr.
92  */
93 #ifndef CHRE_HANDLE_LOW_PRIORITY_ENQUEUE_FAILURE
94 #define CHRE_HANDLE_LOW_PRIORITY_ENQUEUE_FAILURE(                    \
95     eventLoop, eventType, eventData, freeCallback, senderInstanceId, \
96     targetInstanceId, targetGroupMask)                               \
97   do {                                                               \
98   } while (0)
99 #endif  // !CHRE_HANDLE_LOW_PRIORITY_ENQUEUE_FAILURE
100 
101 #endif  // CHRE_PLATFORM_EVENT_LOOP_HOOKS_H_
102