Home | History | Annotate | Download | only in dumpstate
      1 /*
      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 
     35 #ifndef MYLOGW
     36 #define MYLOGW(...)               \
     37     fprintf(stderr, __VA_ARGS__); \
     38     ALOGW(__VA_ARGS__);
     39 #endif
     40 
     41 #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
     51 const uint64_t NANOS_PER_SEC = 1000000000;
     52 uint64_t Nanotime();
     53 
     54 // Switches to non-root user and group.
     55 bool DropRootUser();
     56 
     57 // TODO: move to .cpp as static once is not used by utils.cpp anymore.
     58 int DumpFileFromFdToFd(const std::string& title, const std::string& path_string, int fd, int out_fd,
     59                        bool dry_run = false);
     60 
     61 #endif  // FRAMEWORK_NATIVE_CMD_DUMPSTATE_INTERNAL_H_
     62