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