1209bc2fbSopenharmony_ci/* 2209bc2fbSopenharmony_ci * Copyright (C) 2022 Huawei Device Co., Ltd. 3209bc2fbSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 4209bc2fbSopenharmony_ci * you may not use this file except in compliance with the License. 5209bc2fbSopenharmony_ci * You may obtain a copy of the License at 6209bc2fbSopenharmony_ci * 7209bc2fbSopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 8209bc2fbSopenharmony_ci * 9209bc2fbSopenharmony_ci * Unless required by applicable law or agreed to in writing, software 10209bc2fbSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 11209bc2fbSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12209bc2fbSopenharmony_ci * See the License for the specific language governing permissions and 13209bc2fbSopenharmony_ci * limitations under the License. 14209bc2fbSopenharmony_ci */ 15209bc2fbSopenharmony_ci 16209bc2fbSopenharmony_ci #![allow(missing_docs)] 17209bc2fbSopenharmony_ci 18209bc2fbSopenharmony_ciuse std::ffi::{c_char, c_void}; 19209bc2fbSopenharmony_ci 20209bc2fbSopenharmony_citype XCollieCallbackRust = extern "C" fn(arg: *mut c_void); 21209bc2fbSopenharmony_ci 22209bc2fbSopenharmony_ciextern "C" { 23209bc2fbSopenharmony_ci#[allow(unused)] 24209bc2fbSopenharmony_ci pub fn SetTimerRust( 25209bc2fbSopenharmony_ci data: *const c_char, 26209bc2fbSopenharmony_ci timeout: u32, 27209bc2fbSopenharmony_ci func: XCollieCallbackRust, 28209bc2fbSopenharmony_ci arg: *mut c_void, 29209bc2fbSopenharmony_ci flag: u32, 30209bc2fbSopenharmony_ci ) -> i32; 31209bc2fbSopenharmony_ci 32209bc2fbSopenharmony_ci#[allow(unused)] 33209bc2fbSopenharmony_ci fn CancelTimerRust(id: i32); 34209bc2fbSopenharmony_ci} 35209bc2fbSopenharmony_ci 36209bc2fbSopenharmony_ci/** 37209bc2fbSopenharmony_ci* # Safety 38209bc2fbSopenharmony_ci*/ 39209bc2fbSopenharmony_ci#[allow(unused)] 40209bc2fbSopenharmony_cipub unsafe fn set_timer( 41209bc2fbSopenharmony_ci data: *const c_char, 42209bc2fbSopenharmony_ci timeout: u32, 43209bc2fbSopenharmony_ci func: XCollieCallbackRust, 44209bc2fbSopenharmony_ci arg: *mut c_void, 45209bc2fbSopenharmony_ci flag: u32, 46209bc2fbSopenharmony_ci) -> i32 { 47209bc2fbSopenharmony_ci unsafe { SetTimerRust(data, timeout, func, arg, flag) } 48209bc2fbSopenharmony_ci} 49209bc2fbSopenharmony_ci 50209bc2fbSopenharmony_ci#[allow(unused)] 51209bc2fbSopenharmony_cipub fn cancel_timer(id: i32) { 52209bc2fbSopenharmony_ci unsafe { CancelTimerRust(id) }; 53209bc2fbSopenharmony_ci} 54