blob: 17017337d2d1bd9329ce96eb8706054fb25e3039 [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
24#include "log_portability.h"
Tom Cherry6f6ef392019-01-16 14:17:08 -080025#include "uio.h"
Mark Salyzyn018a96d2016-03-01 13:45:42 -080026
27__BEGIN_DECLS
28
Tom Cherry828db1a2019-11-14 10:39:40 -080029struct logger_list {
Tom Cherry026ddde2019-11-18 15:13:47 -080030 atomic_int fd;
Mark Salyzyn018a96d2016-03-01 13:45:42 -080031 int mode;
32 unsigned int tail;
33 log_time start;
34 pid_t pid;
Tom Cherry9156c532019-11-14 08:56:39 -080035 uint32_t log_mask;
Mark Salyzyn018a96d2016-03-01 13:45:42 -080036};
37
Tom Cherry9156c532019-11-14 08:56:39 -080038// Format for a 'logger' entry: uintptr_t where only the bottom 32 bits are used.
39// bit 31: Set if this 'logger' is for logd.
40// bit 30: Set if this 'logger' is for pmsg
41// bits 0-2: the decimal value of the log buffer.
42// Other bits are unused.
Mark Salyzyn018a96d2016-03-01 13:45:42 -080043
Greg Kaiser9829e7f2019-11-19 06:53:22 -080044#define LOGGER_LOGD (1U << 31)
45#define LOGGER_PMSG (1U << 30)
46#define LOGGER_LOG_ID_MASK ((1U << 3) - 1)
Mark Salyzyn018a96d2016-03-01 13:45:42 -080047
Tom Cherry9156c532019-11-14 08:56:39 -080048inline bool android_logger_is_logd(struct logger* logger) {
49 return reinterpret_cast<uintptr_t>(logger) & LOGGER_LOGD;
50}
Mark Salyzyn018a96d2016-03-01 13:45:42 -080051
Mark Salyzyn018a96d2016-03-01 13:45:42 -080052__END_DECLS