• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2025-2025 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 #ifndef MOCK_FFRT_API_C_EXECUTOR_TASK_H
16 #define MOCK_FFRT_API_C_EXECUTOR_TASK_H
17 
18 #include <stdint.h>
19 #include <stdbool.h>
20 #include <sys/epoll.h>
21 #include "type_def_ext.h"
22 #include "c/timer.h"
23 
24 typedef struct ffrt_executor_task {
25     uintptr_t reserved[2];
26     uintptr_t type;
27     void *wq[2];
28 } ffrt_executor_task_t;
29 
30 typedef enum {
31     ffrt_normal_task = 0,
32     ffrt_io_task = 1,
33     ffrt_uv_task,
34     ffrt_queue_task,
35     ffrt_xpu_task,
36     ffrt_invalid_task,
37 } ffrt_executor_task_type_t;
38 
39 typedef void (*ffrt_executor_task_func)(ffrt_executor_task_t *data, ffrt_qos_t qos);
40 
ffrt_executor_task_register_func(ffrt_executor_task_func func,ffrt_executor_task_type_t type)41 inline FFRT_C_API void ffrt_executor_task_register_func(ffrt_executor_task_func func, ffrt_executor_task_type_t type)
42 {}
43 
ffrt_executor_task_submit(ffrt_executor_task_t * task,const ffrt_task_attr_t * attr)44 inline FFRT_C_API void ffrt_executor_task_submit(ffrt_executor_task_t *task, const ffrt_task_attr_t *attr)
45 {}
46 
ffrt_executor_task_cancel(ffrt_executor_task_t * task,const ffrt_qos_t qos)47 inline FFRT_C_API int ffrt_executor_task_cancel(ffrt_executor_task_t *task, const ffrt_qos_t qos)
48 {
49     return 0;
50 }
51 
ffrt_poller_wakeup(ffrt_qos_t qos)52 inline FFRT_C_API void ffrt_poller_wakeup(ffrt_qos_t qos)
53 {}
54 
ffrt_epoll_get_count(ffrt_qos_t qos)55 inline FFRT_C_API uint8_t ffrt_epoll_get_count(ffrt_qos_t qos)
56 {
57     return 0;
58 }
59 
ffrt_timer_query(ffrt_qos_t qos,ffrt_timer_t handle)60 inline FFRT_C_API ffrt_timer_query_t ffrt_timer_query(ffrt_qos_t qos, ffrt_timer_t handle)
61 {
62     return {};
63 }
64 
ffrt_epoll_ctl(ffrt_qos_t qos,int op,int fd,uint32_t events,void * data,ffrt_poller_cb cb)65 inline FFRT_C_API int ffrt_epoll_ctl(ffrt_qos_t qos, int op, int fd, uint32_t events, void *data, ffrt_poller_cb cb)
66 {
67     return 0;
68 }
69 
ffrt_epoll_wait(ffrt_qos_t qos,struct epoll_event * events,int max_events,int timeout)70 inline FFRT_C_API int ffrt_epoll_wait(ffrt_qos_t qos, struct epoll_event *events, int max_events, int timeout)
71 {
72     return 0;
73 }
74 
ffrt_epoll_get_wait_time(void * taskHandle)75 inline FFRT_C_API uint64_t ffrt_epoll_get_wait_time(void *taskHandle)
76 {
77     return 0;
78 }
79 
ffrt_submit_coroutine(void * co,ffrt_coroutine_ptr_t exec,ffrt_function_t destroy,const ffrt_deps_t * in_deps,const ffrt_deps_t * out_deps,const ffrt_task_attr_t * attr)80 inline FFRT_C_API void ffrt_submit_coroutine(void *co, ffrt_coroutine_ptr_t exec, ffrt_function_t destroy,
81     const ffrt_deps_t *in_deps, const ffrt_deps_t *out_deps, const ffrt_task_attr_t *attr)
82 {}
83 
ffrt_wake_coroutine(void * task)84 inline FFRT_C_API void ffrt_wake_coroutine(void *task)
85 {}
86 
ffrt_get_current_task(void)87 inline FFRT_C_API void *ffrt_get_current_task(void)
88 {
89     return nullptr;
90 }
91 
ffrt_get_current_coroutine_stack(void ** stack_addr,size_t * size)92 inline FFRT_C_API bool ffrt_get_current_coroutine_stack(void **stack_addr, size_t *size)
93 {
94     return true;
95 }
96 
ffrt_get_cur_task(void)97 inline FFRT_C_API void *ffrt_get_cur_task(void)
98 {
99     return nullptr;
100 }
101 
ffrt_task_attr_set_local(ffrt_task_attr_t * attr,bool task_local)102 inline FFRT_C_API void ffrt_task_attr_set_local(ffrt_task_attr_t *attr, bool task_local)
103 {}
104 
ffrt_task_attr_get_local(ffrt_task_attr_t * attr)105 inline FFRT_C_API bool ffrt_task_attr_get_local(ffrt_task_attr_t *attr)
106 {
107     return true;
108 }
109 
ffrt_task_get_tid(void * task_handle)110 inline FFRT_C_API pthread_t ffrt_task_get_tid(void *task_handle)
111 {
112     return {};
113 }
114 
ffrt_get_cur_cached_task_id(void)115 inline FFRT_C_API uint64_t ffrt_get_cur_cached_task_id(void)
116 {
117     return 0;
118 }
119 #endif