blob: ddff19dd5a02541aec1723953795bd42140a355e [file] [log] [blame]
Mark Salyzyn018a96d2016-03-01 13:45:42 -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
Tom Cherrybab52202019-01-15 17:47:48 -080017#pragma once
Mark Salyzyn018a96d2016-03-01 13:45:42 -080018
Mark Salyzyndb8a2662016-10-10 07:27:42 -070019#include <stdatomic.h>
Tom Cherry121292d2020-01-14 09:52:10 -080020#include <sys/cdefs.h>
Mark Salyzyn018a96d2016-03-01 13:45:42 -080021
Mark Salyzynaeaaf812016-09-30 13:30:33 -070022#include <log/log.h>
Mark Salyzyn018a96d2016-03-01 13:45:42 -080023
Tom Cherry6f6ef392019-01-16 14:17:08 -080024#include "uio.h"
Mark Salyzyn018a96d2016-03-01 13:45:42 -080025
26__BEGIN_DECLS
27
Tom Cherry828db1a2019-11-14 10:39:40 -080028struct logger_list {
Tom Cherry026ddde2019-11-18 15:13:47 -080029 atomic_int fd;
Mark Salyzyn018a96d2016-03-01 13:45:42 -080030 int mode;
31 unsigned int tail;
32 log_time start;
33 pid_t pid;
Tom Cherry9156c532019-11-14 08:56:39 -080034 uint32_t log_mask;
Mark Salyzyn018a96d2016-03-01 13:45:42 -080035};
36
Tom Cherry9156c532019-11-14 08:56:39 -080037// Format for a 'logger' entry: uintptr_t where only the bottom 32 bits are used.
38// bit 31: Set if this 'logger' is for logd.
39// bit 30: Set if this 'logger' is for pmsg
40// bits 0-2: the decimal value of the log buffer.
41// Other bits are unused.
Mark Salyzyn018a96d2016-03-01 13:45:42 -080042
Greg Kaiser9829e7f2019-11-19 06:53:22 -080043#define LOGGER_LOGD (1U << 31)
44#define LOGGER_PMSG (1U << 30)
45#define LOGGER_LOG_ID_MASK ((1U << 3) - 1)
Mark Salyzyn018a96d2016-03-01 13:45:42 -080046
Tom Cherry9156c532019-11-14 08:56:39 -080047inline bool android_logger_is_logd(struct logger* logger) {
48 return reinterpret_cast<uintptr_t>(logger) & LOGGER_LOGD;
49}
Mark Salyzyn018a96d2016-03-01 13:45:42 -080050
Mark Salyzyn018a96d2016-03-01 13:45:42 -080051__END_DECLS