| Mark Salyzyn | 018a96d | 2016-03-01 13:45:42 -0800 | [diff] [blame] | 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 |  | 
| Tom Cherry | bab5220 | 2019-01-15 17:47:48 -0800 | [diff] [blame] | 17 | #pragma once | 
| Mark Salyzyn | 018a96d | 2016-03-01 13:45:42 -0800 | [diff] [blame] | 18 |  | 
| Mark Salyzyn | db8a266 | 2016-10-10 07:27:42 -0700 | [diff] [blame] | 19 | #include <stdatomic.h> | 
| Tom Cherry | 121292d | 2020-01-14 09:52:10 -0800 | [diff] [blame] | 20 | #include <sys/cdefs.h> | 
| Mark Salyzyn | 018a96d | 2016-03-01 13:45:42 -0800 | [diff] [blame] | 21 |  | 
| Mark Salyzyn | aeaaf81 | 2016-09-30 13:30:33 -0700 | [diff] [blame] | 22 | #include <log/log.h> | 
| Mark Salyzyn | 018a96d | 2016-03-01 13:45:42 -0800 | [diff] [blame] | 23 |  | 
| Tom Cherry | 6f6ef39 | 2019-01-16 14:17:08 -0800 | [diff] [blame] | 24 | #include "uio.h" | 
| Mark Salyzyn | 018a96d | 2016-03-01 13:45:42 -0800 | [diff] [blame] | 25 |  | 
|  | 26 | __BEGIN_DECLS | 
|  | 27 |  | 
| Tom Cherry | 828db1a | 2019-11-14 10:39:40 -0800 | [diff] [blame] | 28 | struct logger_list { | 
| Tom Cherry | 026ddde | 2019-11-18 15:13:47 -0800 | [diff] [blame] | 29 | atomic_int fd; | 
| Mark Salyzyn | 018a96d | 2016-03-01 13:45:42 -0800 | [diff] [blame] | 30 | int mode; | 
|  | 31 | unsigned int tail; | 
|  | 32 | log_time start; | 
|  | 33 | pid_t pid; | 
| Tom Cherry | 9156c53 | 2019-11-14 08:56:39 -0800 | [diff] [blame] | 34 | uint32_t log_mask; | 
| Mark Salyzyn | 018a96d | 2016-03-01 13:45:42 -0800 | [diff] [blame] | 35 | }; | 
|  | 36 |  | 
| Tom Cherry | 9156c53 | 2019-11-14 08:56:39 -0800 | [diff] [blame] | 37 | // 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 Salyzyn | 018a96d | 2016-03-01 13:45:42 -0800 | [diff] [blame] | 42 |  | 
| Greg Kaiser | 9829e7f | 2019-11-19 06:53:22 -0800 | [diff] [blame] | 43 | #define LOGGER_LOGD (1U << 31) | 
|  | 44 | #define LOGGER_PMSG (1U << 30) | 
|  | 45 | #define LOGGER_LOG_ID_MASK ((1U << 3) - 1) | 
| Mark Salyzyn | 018a96d | 2016-03-01 13:45:42 -0800 | [diff] [blame] | 46 |  | 
| Tom Cherry | 9156c53 | 2019-11-14 08:56:39 -0800 | [diff] [blame] | 47 | inline bool android_logger_is_logd(struct logger* logger) { | 
|  | 48 | return reinterpret_cast<uintptr_t>(logger) & LOGGER_LOGD; | 
|  | 49 | } | 
| Mark Salyzyn | 018a96d | 2016-03-01 13:45:42 -0800 | [diff] [blame] | 50 |  | 
| Mark Salyzyn | 018a96d | 2016-03-01 13:45:42 -0800 | [diff] [blame] | 51 | __END_DECLS |