John Stultz | 16100f6 | 2017-05-03 11:12:18 -0700 | [diff] [blame] | 1 | /* |
John Stultz | 18814f6 | 2018-02-22 16:02:49 -0800 | [diff] [blame] | 2 | * Copyright (C) 2010-2017 ARM Limited. All rights reserved. |
John Stultz | 16100f6 | 2017-05-03 11:12:18 -0700 | [diff] [blame] | 3 | * |
| 4 | * Copyright (C) 2008 The Android Open Source Project |
| 5 | * |
| 6 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 7 | * you may not use this file except in compliance with the License. |
| 8 | * You may obtain a copy of the License at |
| 9 | * |
| 10 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | * |
| 12 | * Unless required by applicable law or agreed to in writing, software |
| 13 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 15 | * See the License for the specific language governing permissions and |
| 16 | * limitations under the License. |
| 17 | */ |
| 18 | |
| 19 | #ifndef GRALLOC_HELPER_H_ |
| 20 | #define GRALLOC_HELPER_H_ |
| 21 | |
| 22 | #include <sys/mman.h> |
John Stultz | 18814f6 | 2018-02-22 16:02:49 -0800 | [diff] [blame] | 23 | #include <android/log.h> |
John Stultz | 16100f6 | 2017-05-03 11:12:18 -0700 | [diff] [blame] | 24 | |
John Stultz | 18814f6 | 2018-02-22 16:02:49 -0800 | [diff] [blame] | 25 | #ifndef AWAR |
| 26 | #define AWAR(fmt, args...) \ |
| 27 | __android_log_print(ANDROID_LOG_WARN, "[Gralloc-Warning]", "%s:%d " fmt, __func__, __LINE__, ##args) |
| 28 | #endif |
| 29 | #ifndef AINF |
| 30 | #define AINF(fmt, args...) __android_log_print(ANDROID_LOG_INFO, "[Gralloc]", fmt, ##args) |
| 31 | #endif |
| 32 | #ifndef AERR |
| 33 | #define AERR(fmt, args...) \ |
| 34 | __android_log_print(ANDROID_LOG_ERROR, "[Gralloc-ERROR]", "%s:%d " fmt, __func__, __LINE__, ##args) |
| 35 | #endif |
| 36 | #ifndef AERR_IF |
| 37 | #define AERR_IF(eq, fmt, args...) \ |
| 38 | if ((eq)) \ |
| 39 | AERR(fmt, args) |
| 40 | #endif |
| 41 | |
| 42 | #define GRALLOC_ALIGN(value, base) (((value) + ((base)-1)) & ~((base)-1)) |
| 43 | |
Yi Kong | 7dc4b7a | 2022-07-15 02:23:53 +0800 | [diff] [blame] | 44 | #define GRALLOC_UNUSED(x) ((void)(x)) |
John Stultz | 16100f6 | 2017-05-03 11:12:18 -0700 | [diff] [blame] | 45 | |
| 46 | static inline size_t round_up_to_page_size(size_t x) |
| 47 | { |
John Stultz | 18814f6 | 2018-02-22 16:02:49 -0800 | [diff] [blame] | 48 | return (x + (PAGE_SIZE - 1)) & ~(PAGE_SIZE - 1); |
John Stultz | 16100f6 | 2017-05-03 11:12:18 -0700 | [diff] [blame] | 49 | } |
| 50 | |
| 51 | #endif /* GRALLOC_HELPER_H_ */ |