diff options
author | Chih-Hung Hsieh <chh@google.com> | 2020-08-19 16:30:16 -0700 |
---|---|---|
committer | Chih-Hung Hsieh <chh@google.com> | 2020-08-19 16:30:16 -0700 |
commit | f84c1a94e3396b228caf7c88d3723742b25a15af (patch) | |
tree | 468bf7eab7129a2a06f7b4ccc3777197956bda5a /profcollectd/libprofcollectd/lib.rs | |
parent | 3e6ed7b638b50791996c94dadaefdff5757a0f48 (diff) | |
download | extras-f84c1a94e3396b228caf7c88d3723742b25a15af.tar.gz |
Move include/libprofcollectd.rs
* It shouldn't be C++ export_include_dirs.
* Rust library source file is usually lib.rs in its own or src directory.
Bug: 163175424
Test: make
Change-Id: Ia4a7e7f43ce03b2d9d5fd18a0d3f3f36e633abe5
Diffstat (limited to 'profcollectd/libprofcollectd/lib.rs')
-rw-r--r-- | profcollectd/libprofcollectd/lib.rs | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/profcollectd/libprofcollectd/lib.rs b/profcollectd/libprofcollectd/lib.rs new file mode 100644 index 00000000..90bca990 --- /dev/null +++ b/profcollectd/libprofcollectd/lib.rs @@ -0,0 +1,62 @@ +// +// Copyright (C) 2020 The Android Open Source Project +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +//! Safe Rust interface over the libprofcollectd_bindgen FFI functions. +//! The methods are safe to call since they do not touch or modify Rust side's +//! memory or threads. + +/// Initialise profcollectd service. +/// * `start` - Immediately schedule collection after service is initialised. +pub fn init_service(start: bool) { + unsafe { + profcollectd_bindgen::InitService(start); + } +} + +/// Schedule periodic profile collection. +pub fn schedule_collection() { + unsafe { + profcollectd_bindgen::ScheduleCollection(); + } +} + +/// Terminate periodic profile collection. +pub fn terminate_collection() { + unsafe { + profcollectd_bindgen::TerminateCollection(); + } +} + +/// Immediately schedule a one-off trace. +pub fn trace_once() { + unsafe { + profcollectd_bindgen::TraceOnce(); + } +} + +/// Process the profiles. +pub fn process() { + unsafe { + profcollectd_bindgen::Process(); + } +} + +/// Read configs from environment variables. +pub fn read_config() { + unsafe { + profcollectd_bindgen::ReadConfig(); + } +} |