1 /* 2 * Copyright (c) 2023 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 16 /** 17 * @file type_def.h 18 * 19 * @brief Declares common types. 20 * 21 * @since 10 22 */ 23 #ifndef FFRT_INNER_API_C_TYPE_DEF_H 24 #define FFRT_INNER_API_C_TYPE_DEF_H 25 #include <stdint.h> 26 #include "c/type_def.h" 27 28 #ifdef __cplusplus 29 #define FFRT_C_API extern "C" 30 #else 31 #define FFRT_C_API 32 #endif 33 34 /** 35 * @brief Enumerates the task QoS types. 36 * 37 */ 38 typedef enum { 39 ffrt_qos_deadline_request = 4, 40 ffrt_qos_user_interactive, 41 ffrt_qos_max = ffrt_qos_user_interactive, 42 } ffrt_inner_qos_default_t; 43 44 typedef enum { 45 ffrt_stack_protect_weak, 46 ffrt_stack_protect_strong 47 } ffrt_stack_protect_t; 48 49 typedef enum { 50 ffrt_thread_attr_storage_size = 64, 51 } ffrt_inner_storage_size_t; 52 53 typedef struct { 54 uint32_t storage[(ffrt_thread_attr_storage_size + sizeof(uint32_t) - 1) / sizeof(uint32_t)]; 55 } ffrt_thread_attr_t; 56 57 #define MAX_CPUMAP_LENGTH 100 // this is in c and code style 58 typedef struct { 59 int shares; 60 int latency_nice; 61 int uclamp_min; 62 int uclamp_max; 63 int vip_prio; 64 char cpumap[MAX_CPUMAP_LENGTH]; 65 } ffrt_os_sched_attr; 66 67 typedef void* ffrt_thread_t; 68 69 typedef void* ffrt_interval_t; 70 71 typedef enum { 72 ffrt_sys_event_type_read, 73 } ffrt_sys_event_type_t; 74 75 typedef enum { 76 ffrt_sys_event_status_no_timeout, 77 ffrt_sys_event_status_timeout 78 } ffrt_sys_event_status_t; 79 80 typedef void* ffrt_sys_event_handle_t; 81 82 typedef void* ffrt_config_t; 83 84 typedef enum { 85 ffrt_coroutine_stackless, 86 ffrt_coroutine_with_stack, 87 } ffrt_coroutine_t; 88 89 typedef enum { 90 ffrt_coroutine_pending = 0, 91 ffrt_coroutine_ready = 1, 92 } ffrt_coroutine_ret_t; 93 94 typedef ffrt_coroutine_ret_t(*ffrt_coroutine_ptr_t)(void*); 95 96 typedef struct { 97 int fd; 98 void* data; 99 void(*cb)(void*, uint32_t); 100 } ffrt_poller_t; 101 102 typedef enum { 103 ffrt_timer_notfound = -1, 104 ffrt_timer_not_executed = 0, 105 ffrt_timer_executed = 1, 106 } ffrt_timer_query_t; 107 108 typedef enum { 109 ffrt_sched_default_mode = 0, 110 ffrt_sched_performance_mode, 111 ffrt_sched_energy_saving_mode, 112 } ffrt_sched_mode; 113 114 #ifdef __cplusplus 115 namespace ffrt { 116 enum qos_inner_default { 117 qos_deadline_request = ffrt_qos_deadline_request, 118 qos_user_interactive = ffrt_qos_user_interactive, 119 qos_max = ffrt_qos_max, 120 }; 121 122 enum class stack_protect { 123 weak = ffrt_stack_protect_weak, 124 strong = ffrt_stack_protect_strong, 125 }; 126 127 enum class sched_mode_type : uint8_t { 128 sched_default_mode = ffrt_sched_default_mode, 129 sched_performance_mode = ffrt_sched_performance_mode, 130 sched_energy_saving_mode = ffrt_sched_energy_saving_mode, 131 }; 132 } 133 #endif 134 #endif 135