blob: c1ec55ee61e8175a7810326fb28e3a69ff53922e [file] [log] [blame]
Felipe Lemef0292972016-11-22 13:57:05 -08001/*
2 * Copyright (C) 2016 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#ifndef FRAMEWORK_NATIVE_CMD_DUMPSTATE_INTERNAL_H_
17#define FRAMEWORK_NATIVE_CMD_DUMPSTATE_INTERNAL_H_
18
19#include <cstdint>
20#include <string>
21
22// TODO: rename macros to DUMPSTATE_LOGXXX
23#ifndef MYLOGD
24#define MYLOGD(...) \
25 fprintf(stderr, __VA_ARGS__); \
26 ALOGD(__VA_ARGS__);
27#endif
28
29#ifndef MYLOGI
30#define MYLOGI(...) \
31 fprintf(stderr, __VA_ARGS__); \
32 ALOGI(__VA_ARGS__);
33#endif
34
Narayan Kamath8f788292017-05-25 13:20:39 +010035#ifndef MYLOGW
36#define MYLOGW(...) \
37 fprintf(stderr, __VA_ARGS__); \
38 ALOGW(__VA_ARGS__);
39#endif
40
Felipe Lemef0292972016-11-22 13:57:05 -080041#ifndef MYLOGE
42#define MYLOGE(...) \
43 fprintf(stderr, __VA_ARGS__); \
44 ALOGE(__VA_ARGS__);
45#endif
46
47// Internal functions used by .cpp files on multiple build targets.
48// TODO: move to android::os::dumpstate::internal namespace
49
50// TODO: use functions from <chrono> instead
51const uint64_t NANOS_PER_SEC = 1000000000;
Hunter Knepshieldf0a39052020-01-03 14:53:04 -080052const uint64_t NANOS_PER_MILLI = 1000000;
Felipe Lemef0292972016-11-22 13:57:05 -080053uint64_t Nanotime();
54
55// Switches to non-root user and group.
56bool DropRootUser();
57
58// TODO: move to .cpp as static once is not used by utils.cpp anymore.
59int DumpFileFromFdToFd(const std::string& title, const std::string& path_string, int fd, int out_fd,
60 bool dry_run = false);
61
62#endif // FRAMEWORK_NATIVE_CMD_DUMPSTATE_INTERNAL_H_